Skip to content

Instantly share code, notes, and snippets.

@maou-shonen
Last active February 24, 2025 07:19
Show Gist options
  • Save maou-shonen/f5edfa6dadd798d0b002c4c006318c96 to your computer and use it in GitHub Desktop.
Save maou-shonen/f5edfa6dadd798d0b002c4c006318c96 to your computer and use it in GitHub Desktop.
monorepo typescript performance 2025
https://publish.reddit.com/embed?url=https://www.reddit.com/r/typescript/comments/1gfv564/comment/lun6u6i/
1. Enable Incremental and Composite
2. Set module and moduleResolution both to NodeNext
3. With typescript@beta, rewriteRelativeImportExtensions, erasableSyntaxOnly and Node 23, you can drop tsx
4. Enable isolatedModules, verbatimModuleSyntax and isolatedDeclarations
5. Enable skipDefaultLibCheck and skipLibCheck
6. Drop npm/yarn and switch to pnpm (or deno or bun or berry)
7. Configure ESLint to use strict-type-checked and stylistic-type-checked. These two contains performance-enhancing rules.
ESLint doesn't come with all performance rules out of the box, also enable those:
8. @typescript-eslint/consistent-type-exports
9. @typescript-eslint/consistent-type-imports with fixStyle: "separate-type-imports"
10. @typescript-eslint/no-import-type-side-effects
And then good luck migrating the project to these new constraints. Also you'll lose path aliases since that feature is deprecated.
But, most importantly, monorepos are hot garbage with JavaScript. Split individual packages where possible and split it into smaller monorepos where possible.
Avoid code generation such as Prisma, TRPC, Zenstack, Zod and GraphQL well, unless one of those projects fixed their shit since I've used them, you never know. The footgun will be immediately apparent when you'll try to enable isolatedDeclarations. This is the most important rule even if it doesn't do anything right now because it highlights performance sinks. If you can't turn it on because it would be too complicated, then you've uncovered that your entire project is basically doomed to have performance issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment