This is a demo project that compiles a package with tsup, using named and default exports, as well as a subpath export.
It showcases an error related to the usage of default exports.
cd packages/package-a
pnpm check
After running this you should see this:
Build tools:
- @arethetypeswrong/cli@^0.12.2
- typescript@^5.2.2
π€¨ CommonJS module simulates a default export with exports.default and exports.__esModule, but does not also set module.exports for compatibility with Node. Node, and some bundlers under certain conditions, do not respect the __esModule marker, so accessing the intended default export will require a .default property access on the default import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSOnlyExportsDefault.md
βββββββββββββββββββββ¬ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β β "package-a" β "package-a/second-entrypoint" β "package-a/package.json" β
βββββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β node10 β π€¨ CJS default export β π’ β π’ (JSON) β
βββββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β node16 (from CJS) β π€¨ CJS default export β π€¨ CJS default export β π’ (JSON) β
βββββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β node16 (from ESM) β π’ (ESM) β π’ (ESM) β π’ (JSON) β
βββββββββββββββββββββΌββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββ€
β bundler β π’ β π’ β π’ (JSON) β
βββββββββββββββββββββ΄ββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ
βELIFECYCLEβ Command failed with exit code 1.