

When you run Expo for these platforms, all of node_modules are automatically transpiled with Metro.

If you use Expo and use the expo-yarn-workspaces or package, you can just use internal packages as long as you are targeting iOS or Android. If you use Next.js, you can satisfy these constraints with the next-transpile-modules plugin which will tell Next.js to run certain dependencies through its Webpack/Babel/TypeScript pipelines. I have personally tested this pattern with several different meta frameworks (see below), but I'm sure that it works with others as well. You should never publish an internal package to NPM.Īs far as I can tell, this internal package pattern works with all Yarn/NPM/PNPM workspace implementations regardless of whether you are using Turborepo or some other tool.The consuming application of an internal package must transpile and typecheck it.Once you do this, this package can then be used without project references or a TypeScript build step (either via tsc or esbuild etc) as long as you adhere to 2 rules: What isn't so obvious, though, is that you can just point the types field directly to raw source code. This last sentence is obvious once you read it twice. tsx file as its own valid type declaration. Well.what if you didn't need to? "Internal" TypeScript PackagesĪs it turns out, you might not even need references or even an interim TypeScript build step with a pattern I am about to show you, which I dub "internal packages."Īn "internal package" is a TypeScript package without a tsconfig.json with both its types and main fields in its package.json pointing to the package's untranspiled entry point (e.g./src/index.tsx).Īs it turns out, the TypeScript Language Server (in VSCode) and Type Checker can treat both a raw.
ESBUILD YARN WORKSPACES UPDATE
Once you add references to your project you now need to continuously update them whenever you add or remove packages.

