-
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
Outputfile path varies based on dynamic imports #845
Comments
This is because dynamic imports are entry points too, and the directory structure that esbuild generates inside the output directory is by default relative to the lowest common ancestor directory of all entry points. If the default isn't suitable for you, you can specify it explicitly with the |
Thanks, using the I'm not sure the benefits of the doing the lowest common ancestor, but in order to use that in a more automated workflow, I would need a way to resolve where the entry point landed to reference it dynamically. Use case for this would be a site builder, e.g. Hugo, would do something like this: <script src="{{EntryPoint("./ts/app.ts")}}"> That would correlate to what the |
Ok, good to hear. Sounds like this issue is resolved for you then, so I'll close this issue.
It's just to have the default behavior do something reasonable. People naturally expect a single build to output a single file instead of a deep hierarchy, but at the same time don't want collisions between multiple entry points that have the same name in different subdirectories. The LCA approach naturally solves for both desires. AFAIK Rollup does this too.
Using |
I have some TS files which I'm bundling and when I add dynamic imports which are outside of the folder of the entry point, then the file for the entry point is output in a subfolder.
Example:
ts/app.ts
Then running:
esbuild ./ts/app.js --bundle --format=esm --splitting --minify --sourcemap --public-path=/js/module/ --outdir=public/js/module
Results in:
But with dynamic imports it is different.
ts/app.js
package.json
Then running the same command as above results in:
I am getting this from the CLI and from the Go API as well.
The path to app.js should be consistent, or short of that, expose it in the BuildResult.
The text was updated successfully, but these errors were encountered: