You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I noticed that an incorrect output hierarchy is produced when a plugin processes an import that's been included from a dynamic import. I came across this while trying to write a loader for WebWorkers until something like #312 is addressed.
I've attached a zip with a simple repro case where a root file src/index.js dynamically imports src/nested/dynamicImport.js which in turn imports src/nested/dependency.js. The build is written to the "dist" folder and I've written a plugin to process dependency.js and modify the contents. When the plugin is enabled src/nested/dependency.js is written to dist/dependency.js while dist/nested/dynamicImport.js is still trying to import from ./dependency.js. The files are written out in the correct spot if the plugin is disabled but of course the plugin is not run. Admittedly it's a bit convoluted to explain through text so hopefully the example makes it clear.
Here's the example project zip to reproduce the issue. After running npm install run node ./run-esbuild.js to generate the incorrect "dist" folder output. You can comment out the "plugins" line in "run-esbuild.js" and delete /dist before rerunning to see that the output structure is different.
Hopefully my explanation is clear. Let me know if I can explain anything better or if I'm just misunderstanding a feature! And of course thank you for maintaining this project!
The text was updated successfully, but these errors were encountered:
Import paths are only transformed by esbuild if they are in the file namespace. Otherwise they are preserved verbatim and are not transformed at all. The namespace feature lets you "take control" of path resolution and provide your own behavior for how paths work, so esbuild doesn't make any assumptions about how paths in non-file namespaces behave. For example, your paths might represent various non-file-system formats such as HTTP URLs or even arbitrary data. In your case you should be able to get this to work by just using the file namespace.
Hello! I noticed that an incorrect output hierarchy is produced when a plugin processes an import that's been included from a dynamic import. I came across this while trying to write a loader for WebWorkers until something like #312 is addressed.
I've attached a zip with a simple repro case where a root file
src/index.js
dynamically importssrc/nested/dynamicImport.js
which in turn importssrc/nested/dependency.js
. The build is written to the "dist" folder and I've written a plugin to processdependency.js
and modify the contents. When the plugin is enabledsrc/nested/dependency.js
is written todist/dependency.js
whiledist/nested/dynamicImport.js
is still trying to import from./dependency.js
. The files are written out in the correct spot if the plugin is disabled but of course the plugin is not run. Admittedly it's a bit convoluted to explain through text so hopefully the example makes it clear.Here's the example project zip to reproduce the issue. After running
npm install
runnode ./run-esbuild.js
to generate the incorrect "dist" folder output. You can comment out the "plugins" line in "run-esbuild.js" and delete /dist before rerunning to see that the output structure is different.esbuild-repro.zip
Hopefully my explanation is clear. Let me know if I can explain anything better or if I'm just misunderstanding a feature! And of course thank you for maintaining this project!
The text was updated successfully, but these errors were encountered: