JoosepAlviste/serieslist

Split into packages and use nx

Closed this issue · 1 comments

Improvements for working with nx and monorepos:

  • Add generator for creating new packages
  • Update TypeScript to v5 so that we can use the "bundler" module resolution configuration.
  • Set up and double check nx job caching for each script:
    • lint
    • build
    • tsc
    • test
    • test:coverage
    • test:watch
    • test:e2e
    • migrate and migrate:test, input is probably the migrations?
    • Codegen in FE depends on BE GraphQL schema
  • Since we're bundling the API files when building, then we need to fix the various prod scripts: migrate:prod, start:prod, start:jobs:prod
  • Look into distributed caching
  • Have a base Docker image with the build dependencies that we can just extend
  • Package.json linting with syncpack, we already have it installed but it probably doesn't make sense to run it in CI
  • Try to use nx environment variable handling instead of our custom approach. This means that we'll have to run everything from the root of the project, through nx, though. Not sure how I feel about that...
  • Use a custom nx executor for deployment so that a package.json and a pnpm-lock.yaml file are created in the dist folder, including only the dependencies required for the deployed application (api or webapp). We're currently using pnpm deploy, but that's not taking full advantage of nx as we need to copy ALL files in the Dockerfile, not just the ones that are relevant to us. Maybe the nx way of deploying could improve this?
  • Try building each package rather than exporting source files. We probably need declarationMap so that go to definition goes to the source, not the type definition in dist. This means that we could probably get rid of esbuild. We could also use absolute imports in packages.
    • This means that during dev mode we need to run watch on all the packages

Extract packages and apps:

  • Prettier config
  • ESLint config
  • Type utils
  • TypeScript config
  • Logger, Pino configuration. Also start using it in the FE Fastify server.
  • Split e2e tests to a separate project
  • Split mock TMDB server to separate project
  • UI components
    • We should have 1 theme in the UI package with the colors and basic values, and then 1 theme in the app, including the more specific variables
    • Maybe also 1 "base" theme?
  • Factories
  • Split background job to separate project, probably requires extracting some business logic to a package
  • Formatting things
  • Maybe some business logic

Current problems with the new set up:

  • Duplicated small utility functions, gotta figure out a package for those (or multiple packages)
  • Duplicated configuration files. All packages and projects need a .eslintrc.json, .prettierrc.json, tsconfig.json and so on
  • Duplicated set up for tools like the logger, db connection, maybe some others?
  • Duplicated Vitest config

Resources:

I think that we can consider this done for now and create tasks out of the un-checked items if we want to implement any of them.