Dynamic imports generates wrong Chunks with folder structure `Comment/index.js` and `import './Comment'`
See original GitHub issueDo you want to request a feature or report a bug? Bug
What is the current behavior?
When using
import(/* webpackChunkName: 'asyncComponents/[request]' */ `./asyncComponents/${name}`)
with this folder structure:
.
└── asyncComponents
└── Comment
├── index.js
└── styles.css
You would expect the imported chunk name to be asyncComponents/Comment-index
or ideally simply asyncComponents/Comment
. Instead it’s asyncComponents/Post-.
styles.css
for example gets a chunk named: asyncComponents/Page-styles
If the current behavior is a bug, please provide the steps to reproduce.
Use
import(/* webpackChunkName: 'asyncComponents/[request]' */ `./asyncComponents/${name}`)
with the above folder structure and check out the chunk names
What is the expected behavior?
Generate same chunk names (Button
) as with static compiling
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System. node 8.2.1 webpack 3.5.4 macOS 10.12.6
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Dynamic Imports: Am I missing something? - Stack Overflow
@Ernesto's answer offers one way of code splitting by using react-loadable with the babel-dynamic-import plugin, however, if your Webpack ...
Read more >import() - JavaScript - MDN Web Docs - Mozilla
The import() syntax, commonly called dynamic import, is a function-like expression that allows loading an ECMAScript module asynchronously ...
Read more >Demistifying webpack's 'import' function: using dynamic ...
webpack will generate a chunk for each file in the animals directory. This is the lazy option's behaviour. What happens in this example...
Read more >Dynamic imports - The Modern JavaScript Tutorial
First, we can't dynamically generate any parameters of import . The module path must be a primitive string, can't be a function call....
Read more >babel-plugin-path-chunk-name - npm
By default, webpack will generate dynamic chunks named with numeric value, say 0.js . · It's troublesome to add magic comments: webpackChunkName ...
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
Thanks for your report. It would be great if you reduce your issue to a small reproducible example. Best put this example into a github repository together with instructions how to get to the problem.
There are some new issues with this. I had
react-universal-component + webpack-flush-chunks + babel-plugin-universal-import
working fine until webpack started spitting out chunks with slashes in the file names for where the path went, while the universal component expects hyphens.