-
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
ESM rewritten relative paths are wrong #2246
Comments
I think this is correct behaviour, cause esbuild will bundle all file into single file, the structure looks like
However I found potential bug for here is my build script build({
entryPoints: ['./src/test.ts'],
format: 'esm',
external: ['./node_modules/*'],
platform: "node",
target: "node16.13",
outdir: 'dist',
outbase: '.',
bundle: true
}) |
Thanks, yes, it feels like the expected behaviour should be the import path is relative to |
I second that |
This general type of issue has been reported before: #1958 and #2164. I tried to support the "mark all packages as external" use case by reusing an existing mechanism ( |
Yes thank you that would fix it! Also big thank you for all your time making esbuild! |
Do you know when you will release this version? I ask out of curiosity as we are considering using esbuild and it is currently blocking us. |
You've probably got something sorted now, but if not this plugin @evanw wrote fixes this for me. Any imports that don't start with "/" or "./" or "../" are left alone |
@evanw not sure about that plugin, but it would be great if this just worked out of the box. |
Given a structure like this
when I run the following
then the import paths are all rewritten to be relative as
../node_modules
which is correct for the top level but it wrong for all levels below. I've tried reading the docs carefully and various incantations ofoutbase
etc but haven't been able to get it to work. I'm also somewhat unclear as to why it's rewriting them at all, as presumably leaving external imports untouched would work?In the
dist
dir I see the following✅ correct
🚫 broken
🚫 broken
The text was updated successfully, but these errors were encountered: