Unable to use import() with magic comments
See original GitHub issueimport(/* webpackChunkName: "plugin" */ './plugin.js')
sets chunk [name]
the same as [id]
, so the output filename is 0.0.js
(in config: chunkFilename: '[id].[name].js'
)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:6
Top Results From Across the Web
angular8.0 dynamic import not support webpack magic ...
1 Answer 1 ... It's working when you build for development mode only. Make sure to set the flag namedChunks in Angular.json to...
Read more >How to use Webpack's new “magic comment” feature with ...
There is one problem with this. Currently require. resolveWeak can't resolve dynamic imports like import can. I.e. you can't have a string such ......
Read more >Fixing WebpackChunkName for Dynamic Imports - Time to Hack
If Magic Comments (or Any Comment) are not reaching the webpack, then they are lost in the transpiling process. This means I need...
Read more >Code Splitting - webpack
It isn't as flexible and can't be used to dynamically split code with the core ... The first and recommended approach is to...
Read more >How To Fix "Cannot use import statement outside module" in JS
Conclusion. Give these solutions a try and you should no longer have to deal with that error. If not, feel free to leave...
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 Free
Top 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
Make sure you set:
comments: true
in.babalrc
(this is the default)chunkFilename: '[name].....'
in your webpack configIf you are using typescript, also make sure:
removeComments: false
undercompilerOptions
intsconfig.json
module: esnext
intsconfig.json
This works for me and here is my commit for adding dynamic import (code split) support to my react-typescript project, hope it helps 😃
Thank you!! it was the
module": "esnext"
for me