You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ webpack
[webpack-cli] TypeError: Cannot read property 'ensureChunkHandlers' of undefined
at /Users/sergio/src/test/mini-css-extract-plugin-bug/node_modules/mini-css-extract-plugin/dist/index.js:322:88
at Hook.eval [as call] (eval at create (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
at Hook.CALL_DELEGATE [as _call] (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/tapable/lib/Hook.js:14:14)
at Compiler.newCompilation (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/webpack/lib/Compiler.js:987:30)
at /Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/webpack/lib/Compiler.js:1029:29
at Hook.eval [as callAsync] (eval at create (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/tapable/lib/Hook.js:18:14)
at Compiler.compile (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/webpack/lib/Compiler.js:1024:28)
at /Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/webpack/lib/Compiler.js:471:12
at Compiler.readRecords (/Users/sergio/src/test/mini-css-extract-plugin-bug/app/node_modules/webpack/lib/Compiler.js:866:11)
Note that both <root> and app depend on [email protected]., but the package manager hoists it to a common location. Because how the node module resolution algorithm works, this setup is valid (and in fact, quite common for monorepos).
Now imagine a webpack compilation inside app that uses new MiniCssExtractPlugin() (details about what the config does are not relevant). This is what happens:
A new webpack 5 compilation is started, it loads MiniCssExtractPlugin
Expected Behavior
It can bundle my app without crashing.
Actual Behavior
Crashes with:
How Do We Reproduce?
See reproduction repo in https://github.com/scinos/mini-css-extract-plugin-bug
Description
This is what I think it is happening:
In a monorepo with multiple versions of webpack, depending on where
mini-css-extract-plugin
physically is, it can fail. Example:Note that both
<root>
andapp
depend on[email protected].
, but the package manager hoists it to a common location. Because how the node module resolution algorithm works, this setup is valid (and in fact, quite common for monorepos).Now imagine a webpack compilation inside
app
that usesnew MiniCssExtractPlugin()
(details about what the config does are not relevant). This is what happens:MiniCssExtractPlugin
import webpack from 'webpack';
(https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L3). As the plugin resides in<root>/node_modules/mini-css-extract-plugin
, it loads<root>/node_modules/webpack
which is webpack 4compiler
was created using webpack 4 (https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L106). It wasn't, so it assumes webpack 5.isWebpack4===false
, butwebpack
does point to[email protected]
The text was updated successfully, but these errors were encountered: