svg-sprite-loader icon indicating copy to clipboard operation
svg-sprite-loader copied to clipboard

SvgSpriteLoader is trying to guess you are using webpack 4 or 5

Open alivedise opened this issue 3 years ago • 1 comments

Do you want to request a feature, report a bug or ask a question? Bug What is the current behavior? In my environment I am using monorepo with some package using webpack 4 and some webpack 5.

See https://github.com/JetBrains/svg-sprite-loader/blob/master/lib/utils/get-matched-rule-4.js#L4

It seems svg-sprite-loader is trying to access 'webpack/lib/RuleSet' to see the user is having webpack 4(w/ RuleSet) or webpack 5(w/o RuleSet), but this is not 100% true in monorepo environment.

In this case when using SvgSpriteLoader/plugin to build, an error will show as

Error: Rule can only have one resource source What is the expected behavior? Maybe we should be able to let the user to choose different version of the plugin for webpack 4 or webpack 5 instead of doing a strange internal "guess".

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

If this is a feature request, what is motivation or use case for changing the behavior?

Please tell us about your environment:

  • Node.js version: ? 14
  • webpack version: ? 5.73.0 in a monorepo where has webpack 4.46.0 as well
  • svg-sprite-loader version: ? 6.0.11
  • OS type & version: ? mac

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

alivedise avatar Jul 20 '22 11:07 alivedise

14.17.0

TomorrowLM avatar Jul 14 '23 10:07 TomorrowLM