code100x / cms

https://app.100xdevs.com/
615 stars 830 forks source link

Migrating to Turborepo (incrementally) #234

Open aryanprince opened 3 months ago

aryanprince commented 3 months ago

Summary

To migrate the current repo to a monorepo setup using Turborepo. This will allow us to have multiple different applications (like marketing, Discord Bot, so on) in the same repo, while having shared common packages between each other.

Pros

  1. Improved DX for repetitive tasks such as building, linting, and formatting.
  2. Will allow us to keep the main 100x dashboard, (future) Discord Bot, marketing sites, and other apps in the future in one place. Ensuring all apps can share packages across each other (such as various configs and Tailwind for example).
  3. Saving both time and money in CI - by leveraging Turborepo's Remote Cache.
  4. Improved local dev experience since build caches can be reused by all contributors.
  5. ...and not to mention, every other benefit of having a monorepo fundamentally such as allowing shared packages to be updated locally and seeing live changes on the apps importing shared packages.

Cons

  1. Deployments will need to be updated to new directory inside the monorepo (updating deployment directory to apps/web for example)
  2. Will need to update the Docker Compose script to ensure it works with the new Turborepo setup.

The Plan

Make a very minimal migration to Turborepo. By this, I mean we use a 2 step approach to the migration in order to keep minimal diffs and manageable PRs/reviews.

My Experience

I've incrementally migrated from a single Next.js app to a monorepo setup with Turborepo with 3 different Next.js apps here.

aryanprince commented 3 months ago

@hkirat If this is something on the roadmap, can I be assigned to this as I’ve already initiated work on it? Thanks.

hkirat commented 3 months ago

this is great

aryanprince commented 3 months ago

Progress

For now, I have managed to successfully migrate the entire codebase to Turborepo (with pnpm workspaces). Everything works well in my fork for the time being (link here). However, there are several blockers that need to be addressed before I submit my PR.

Blockers

There are currently 2 blocking issues/PRs:

  1. There are a large number of conflicting ESLint and Prettier config rules.

PR #244 plans to fix this blocker.

  1. There are missing migration files from the last DB schema change (part of merged PR #170).

PR #242 plans to solve this minor issue.


I will make my PR after these changes have been merged to ensure minimal overlapping changes and cleaner diff during the (huge - around 195 files currently) monorepo migration PR.