
This pattern has been working fine for my use cases so far (especially while using esbuild). Which might look strange at first, given that it’s uncompiled code… see “You might not need TypeScript project references” on the Turborepo blog for an explanation.

NETLIFY YARN WORKSPACES CODE
I expect people usually use the IDE integration to type-check the code anyway and explicitly invoke the tsc CLI only in specific use cases (such as pre-commit hooks).Įach workspace’s package.json is pointing the main and types entry to src/index.ts. The tsc CLI is used only to type-check the codebase (without emitting the compiled files - since they’re handled by esbuild). Be it for building, testing, or running CLI scripts, the compilation is instantaneous compared to the native TypeScript compiler (you can quickly test the difference by temporarily swapping esbuild with tsc). packages/eslint-config: Shared ESLint config.Īll the workspaces use esbuild to compile the TypeScript codebase.packages/jest-config: Shared Jest config that uses esbuild to compile your tests and your codebase.It uses nodemon to reload the server in development mode. It’s a Node.js Express server that exposes two routes that invoke isEven and isOdd. package/server: Depends on both packages/is-odd and packages/is-even.It includes a CLI script and a test file. It’s a Node.js module that exposes an isOdd function that tells if the input number is odd (by invoking isEven and checking if it’s false).

NETLIFY YARN WORKSPACES HOW TO
While learning esbuild, I haven’t found many examples of how to integrate it within TypeScript monorepos. I’ve been using esbuilt for a couple of TypeScript projects and have been surprised by how well it performs. While the native TypeScript compiler is not that slow (IMHO), it’s still something you need to take into account if you’re planning to build a large codebase.īut what if there was a way to speed up the TypeScript compilation by using a different compiler?Įnter esbuild: a fast JavaScript bundler that claims to be >10x faster than similar projects (webpack, rollup + terser, parcel 2). And using a monorepo helps in scaling your project(s).Ĭompared to plain JavaScript, however, TypeScript adds an additional compilation layer to your project, which may slow down the developer experience.

TypeScript improves the developer experience by adding type-checking and a deep IDE integration. TypeScript monorepos are a great way to organize medium-to-big size projects.
