-
Notifications
You must be signed in to change notification settings - Fork 272
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
Wrong webpack installation gets loaded in nested node project #461
Comments
@d3x42 I'm trying to fix this myself, but realised I'd basically be reverting #440 (I was going to add a webpack version check to the |
Thanks @d3x42, I've put through another PR #463 that resolves this problem by forcing |
Seems to be fine, i hope it won't affect other users |
Do you want to request a feature, report a bug or ask a question?
Report a bug
What is the current behavior?
Consider this project structure:
If we invoke webpack on
project_b
, the plugin will require files from thewebpack@4
installation located insideproject_a
. (Specifically:webpack/lib/RuleSet
).Why is this an issue?
While this may sound like a corner case, this setup is caused by working within a yarn workspaces monorepo structure (which is not that uncommon these days). Yarn workspaces hoists certain dependencies to the top level, so it's important that apps prefer to use their local
node_modules
folder before looking up the tree.Using the wrong version of webpack causes unexpected issues, particularly when using a complicated webpack config as in the case of vue projects.
What is the expected behavior?
In the above scenario the plugin should not require any webpack files from
project_a
because a webpack installation exists withinproject_b
, and their versions differ.If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code.
The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code).
It you don't want to create a repository - create a gist with multiple files
Run the following commands:
You should see output similar to the following:

The test code injects the "Loaded webpack v4..." message into
webpack/lib/RuleSet
within the v4 webpack installation. The message should not show because the file should not be loaded, the plugin should use webpack v5 from theproject_b
node_modules.If this is a feature request, what is motivation or use case for changing the behavior?
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
The issue exists here:
https://github.com/JetBrains/svg-sprite-loader/blob/master/lib/utils/get-matched-rule.js
Because it tries to resolve webpack v4 first and this will succeed because webpack v4 does indeed exist but at a level higher than expected.
Related issues:
#437
#417
The text was updated successfully, but these errors were encountered: