Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to nodejs export conditions from TS project references (#67)
* build: Switch to nodejs export conditions from TS project references Previously, typescript project references were used to wire imports between workspace packages. Now this is done by package.json export conditions. This nodejs feature has already been used to support consuming packages in both esm and cjs format. We add an artificial condition "_bundle", and use the respective bundler's export conditions feature https://esbuild.github.io/api/#conditions and https://www.typescriptlang.org/tsconfig#customConditions to achieve that IDE and TS compiler resolve any workspace package imports to their respective Typescript source file, not their build output .d.ts files. This has an additional benefit of reducing bundle size of cjs build. Previously, CJS build operated on ESM build output; They fed dist/index.js files to esbuild. This changes this so that esbuild directly operates on Typescript source files even in CJS build. As esbuild will have more information, it will be able to better tree-shake unused codes. * build: use _bundle export condition on esm bundle as well * chore: make prettier format json also used double quotes for interoparabilities with Windows * build: set forceConsistentCasingInFileNames * build: use import instead of _bundle Since package.json is re-written before publishing, we are free to point `import` condition to `.ts` source files. However, CLI tests need to be able to resolve to `dist/*.js` files, so a custom condition `prebuilt` pointing to those are kept in every package.json.
- Loading branch information