Error when using dynamic imports
See original GitHub issueIf I include the following in my worker code (assuming dummyModule.js just contains export default 1
)
const unusedImport = () => import('./dummyModule')
then I get this error:
./src/myWorker.ts (./node_modules/worker-plugin/dist/loader.js?{“name”:“0”}!./src/myWorker.ts) ChunkRenderError: Conflict: Multiple chunks emit assets to the same filename static/js/0.chunk.worker.js (chunks 0 and 0)
Is this something we can work around with worker-plugin’s options?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Error: Cannot find module with dynamic import #6680 - GitHub
When I try to load dynamic module with import('/path/to/my/module.js').then() it work, but when i try to import module with import(rootPath + ...
Read more >Dynamic Import, Code Splitting, Lazy Loading, and Error ...
You will encounter the error: “Cannot find module with dynamic import.” This error comes from Webpack, which is used by Create React App....
Read more >Uncaught Error: Cannot Find Module When Using Dynamic ...
Fully dynamic statements, such as import(foo), will fail because webpack requires at least some file location information.The import() must ...
Read more >Error: Cannot find module with dynamic import - Allen Kim
If you want component name as a variable const komponent = imported[`MyComponent`]; const btnCompFactory = this. cfr. resolveComponentFactory(komponent);
Read more >Confusing error message when using dynamic import with ...
The specifier could be resolved, the problem in this case is that there is no file corresponding to the resolved specifier ("resolving the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can work around this error by specifying a name in the worker’s options:
I’d consider this to be a good-enough workaround.
Bit by this issue as well, I was providing a name but a non-constant one, so plugin would still go for chunkname === ‘0’. I believe this is caused because ‘0’ chunk name (provided to
SingleEntryPlugin
) could eventually conflict with webpack ID-based chunk names (if you do dynamic imports or chunk splitting).Easy fix confirmed is to use something else like
'W' + workerId
as default name argument toloader.js
.Happy to PR this 1 line change if anyone with better webpack skills than mine can confirm it’s the right ™️ way to go.