When running esbuild in --bundle mode it seems to apply the tsconfig.json paths mapping before looking at package.json. This causes a condition where both the compiled JS output and original TS source are included in the final bundle. I believe that this is a violation of node's package specification: https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name
I've put together a very simple example of the issue at https://github.com/laverdet/esbuild-issue.
-> % git clone git@github.com:laverdet/esbuild-issue.git
[...]
-> % cd esbuild-issue
-> % npm run -s run
# node main.js
dist dist
-> % npm run -s build
# npx esbuild --bundle main.js | node --input-type module
dist source
We can see the execution result of the bundled esbuild output disagrees with nodejs's output. This causes very difficult to troubleshoot variation of the dual package hazard.
When running esbuild in
--bundlemode it seems to apply the tsconfig.jsonpathsmapping before looking at package.json. This causes a condition where both the compiled JS output and original TS source are included in the final bundle. I believe that this is a violation of node's package specification: https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-nameI've put together a very simple example of the issue at https://github.com/laverdet/esbuild-issue.
We can see the execution result of the bundled esbuild output disagrees with nodejs's output. This causes very difficult to troubleshoot variation of the dual package hazard.