adding splitChunks all is breaking the module exports
See original GitHub issue- Operating System: macOS mojave
- Node Version: v11.3.0
- NPM Version: 6.7.0
- webpack Version: 4.33.0
- mini-css-extract-plugin Version: 0.7.0
Expected Behavior
Having concatenated all CSS in the file should not break the module exports.
Actual Behavior
Adding the splitChunks optimization for a single css file is breaking the umd build exports.
Code
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.css$/,
chunks: 'all',
enforce: true,
},
},
},
},
How Do We Reproduce?
- create with umd build as output and configure the optimization rule and try and importing the component from the library. it fails with error
TypeError: Cannot read property <functionName> of undefined
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:29 (9 by maintainers)
Top Results From Across the Web
SplitChunksPlugin - webpack
splitChunks. This configuration object represents the default behavior of the SplitChunksPlugin . webpack.config.js module.exports = { //... optimization: ...
Read more >Webpack 5 splitChunks breaks WebpackDevServer
I don't know how to fix it with webpack@5, but downgrading to previous version of react-app is enough for me. Just add explicit...
Read more >Webpack (v4) Code Splitting using SplitChunksPlugin - Medium
When that promise resolves, it returns whatever that module is exporting. A module can be an npm module or a local file, anything...
Read more >Webpack 4: Step By Step: Split Chunks Plugin
It does not have to be all third party in one bundle. WebUi. webpack.config.js. In addition to just splitting the code ...
Read more >Using Webpack with React, Pt. 1 - Toptal
Then we'll add a module section to our Webpack config, making babel-loader responsible for loading JavaScript files: @@ -11,6 +11,25 @@ module.exports ......
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
Guys, I dont know a root problem, but I make this thing works for me. splitChunks all generates two files. 1 -
styles.css
itself. 2-styles.js
file with empty css files modules And the problem is - thisstyles.js
file is not used in main bundle fileindex.js
so in my html file
was
now
with
AutomaticPrefetchPlugin
for makes this work before main bundleAfter more digging, it looks like the extra JS file produced might be the cause?. Something isn’t getting executed.
1.index.js:
When this file gets generated, the main js file has different code generated:
Good:
Bad: