-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin crashes when using in a repo with webpack 4 and webpack 5 #668
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: