evanw / esbuild

An extremely fast bundler for the web

Home Page:https://esbuild.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Request] Generate an importmap tag

SparK-Cruz opened this issue · comments

commented

Basically if something is going to import files dynamically (like lazy loading a module) the imports are not replaced on those.
For those cases the import of npm libraries will fail.
Generating an importmap type script tag with a list of bundled modules all pointing to the bundled files in public folders fixes the issue.

I'm not sure what esbuild need to do here. Can you provide a minimal showcase about how did you use esbuild and what you expect to happen?

If you externalizes some modules and want esbuild to generate an importmap that resolves the module to bundled file, like "react": "/public/bundled-react.js". It is impossible since esbuild doesn't know this extra information as it even doesn't bundle the externalized module, neither does it know the bundled file name.