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
{{ message }}
Repository navigation
Web Dev Server with importMapsPlugin will not resolve import maps for dynamic imports. #2910
If you attempt to import a file using import('./module.js') and module.js includes an import path that requires importmap resolution, the import will fail with error 500
This breaks currently due to the rollup adapter logic, which by default fails on the unresolved imports.
We wrap rollup nodeResolve plugin, and when you have nodeResolve activated, it will break.
Locally you can write a simple plugin to workaround this, but it's far from ideal. E.g. smth like that:
// put the modules which will be resolved by Import Maps in runtimeconstimportMapsModules=['./module.js'];/** @returns {import('rollup').Plugin} */exportfunctionrollupPluginFixImportMapsModules(){return{name: 'rollup-plugin-fix-import-maps-modules',asyncresolveId(id){if(importMapsModules.includes(id)){returnnull;}returnundefined;},};}/** @returns {import('@web/dev-server-core').Plugin} */exportfunctionwdsPluginFixImportMapsModules(){return{name: 'wds-plugin-fix-import-maps-modules',asyncresolveImport({ source }){if(importMapsModules.includes(source)){returnsource;}returnundefined;},};}
For rollup there are better ways to solve it, but I'm using this workaround currently to reuse the list of modules between the 2.
I do have some ideas on how to solve it in a generic way, but it doesn't seem trivial.
Either way you either need to know about import maps in the WDS or you need to disable the failure on unresolved imports (I don't think it's a good idea).
Import maps can be checked by WDS using static analyses similar to how we do it in current Import Maps plugin, but with the recent support for dynamic Import Maps such logic will also not be a universal solution to this problem.
I'm currently actively working with Import Maps and exploring different ways of working with them, so keep posting here new findings and ideas.
Activity
bashmish commentedon Mar 24, 2025
This breaks currently due to the rollup adapter logic, which by default fails on the unresolved imports.
We wrap rollup nodeResolve plugin, and when you have nodeResolve activated, it will break.
Locally you can write a simple plugin to workaround this, but it's far from ideal. E.g. smth like that:
For rollup there are better ways to solve it, but I'm using this workaround currently to reuse the list of modules between the 2.
bashmish commentedon Mar 24, 2025
I do have some ideas on how to solve it in a generic way, but it doesn't seem trivial.
Either way you either need to know about import maps in the WDS or you need to disable the failure on unresolved imports (I don't think it's a good idea).
Import maps can be checked by WDS using static analyses similar to how we do it in current Import Maps plugin, but with the recent support for dynamic Import Maps such logic will also not be a universal solution to this problem.
I'm currently actively working with Import Maps and exploring different ways of working with them, so keep posting here new findings and ideas.