question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using dynamic imports

See original GitHub issue

If 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
FTWinstoncommented, Sep 24, 2019

I can work around this error by specifying a name in the worker’s options:

new Worker('./myWorker.ts', { name: 'mine', type: 'module' });

I’d consider this to be a good-enough workaround.

3reactions
gluckcommented, Mar 9, 2020

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 to loader.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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found