-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior of the external
option
#2542
Comments
Why not simply write |
@Septh the examples I gave here are just a fraction of the whole codebase. Because the dependencies are spread out accross many |
I can confirm this issue happens for UUID as well. I think this happens for all the packages that use the When you tell ESBuild to generate a commonjs bundle, you get a bundle that might include commonJS imports of ESM exports which results in a I think this is important and needs to be investigated. I would love to make a PR for this if @evanw could give me a hint as to where to start looking. |
@evanw I looked at the I'm using
which would be imported as |
I have encountered two unexpected behaviors of the
external
option.esbuild config for both cases:
For all the reproduction examples: run
npm i && npm run build
in the terminal and check theapps/myApp/out
folder for the output.Input:
Output:
In this case I would expect that
react
is marked as external (because its resolved path matches one of theexternal
paths).So the expected output would be:
node_modules
is marked as external incorrectly (Reproduction https://stackblitz.com/edit/node-cwpdcm):Here I have installed a local package, which means the folder in the
node_modules
directory is just a symlink to the real folder.package.json
Input:
Output:
In this case the import
@repo/myLib
resolves to/home/projects/node-cwpdcm/libs/myLib/index.ts
and not to../../../node_modules/@repo/myLib/
. (I checked that with a plugin which logs all resolved paths with theonLoad
callback). Because neither the resolved nor the import path matches any of theexternal
paths I would expect this import not to be external.Side note: with
preserveSymlinks: true
the resolved path is/home/projects/node-vaswvk/node_modules/@repo/myLib/index.ts
which then again should be marked as external.These cases might only be unexpected because I don't know how the
external
option behaves internally. To be honest I would expect theexternal
option to be an array of globs / regex expressions / strings instead of just an array of strings (where the strings are relative paths but still can have a wildcard, but only one)The text was updated successfully, but these errors were encountered: