SplitChunksPlugin fails to split during build
See original GitHub issueBug report
webpack build fails due to a change in mini-css-extract-plugin.
webpack: 5.58.0 mini-css-extract-plugin: 2.4.0
Relevant webpack.config.js part:
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: module => module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]
}
}
}
Actual Behavior
The following errors is thrown during build:
TypeError: Cannot read property '1' of null
Expected Behavior
Build should pass successfully.
How Do We Reproduce?
Clone my repo and attempt to build:
https://github.com/theninthsky/flyingnotes-client/tree/9f5ad8717cb45f995855e363d745248f6b5637e9
Please paste the results of npx webpack-cli info
here, and mention other relevant information
Build works perfectly with version 2.3.0.
System: OS: Windows 10 10.0.19043 CPU: (4) x64 Intel® Core™ i3-8130U CPU @ 2.20GHz Memory: 834.43 MB / 3.91 GB Binaries: Node: 14.15.5 - C:\Program Files\nodejs\node.EXE npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 94.0.4606.81 Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.38) Internet Explorer: 11.0.19041.1202 Packages: babel-loader: ^8.2.2 => 8.2.2 copy-webpack-plugin: ^9.0.1 => 9.0.1 css-loader: ^6.3.0 => 6.3.0 css-minimizer-webpack-plugin: ^3.1.1 => 3.1.1 eslint-webpack-plugin: ^3.0.1 => 3.0.1 html-webpack-plugin: ^5.3.2 => 5.3.2 postcss-loader: ^6.1.1 => 6.1.1 sass-loader: ^12.1.0 => 12.1.0 webpack: ^5.58.0 => 5.58.0 webpack-cli: ^4.9.0 => 4.9.0 webpack-dev-server: ^4.3.1 => 4.3.1 workbox-webpack-plugin: ^6.3.0 => 6.3.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
I’ll try to create a demo repo by tomorrow.
Expected, please add additional check, not all modules can
match
.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
So it can be changed due internal changes, please consider to use typescript to avoid these problem in future, feel free to feedback