JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.01k stars 272 forks source link

Webpack 5: Cannot find module 'webpack/lib/RuleSet' #437

Closed kamilmielnik closed 3 years ago

kamilmielnik commented 3 years ago

Do you want to request a feature, report a bug or ask a question?

Bug

What is the current behavior?

I'm getting the following error when using webpack 5:

./src/icons/download.svg
Error: Cannot find module 'webpack/lib/RuleSet'
Require stack:
- /home/kamil/projects/cv/node_modules/svg-sprite-loader/lib/utils/get-matched-rule-4.js
- /home/kamil/projects/cv/node_modules/svg-sprite-loader/lib/utils/get-matched-rule.js
- /home/kamil/projects/cv/node_modules/svg-sprite-loader/lib/utils/index.js
- /home/kamil/projects/cv/node_modules/svg-sprite-loader/lib/configurator.js
- /home/kamil/projects/cv/node_modules/svg-sprite-loader/lib/loader.js
- /home/kamil/projects/cv/node_modules/next/dist/compiled/webpack/bundle4.js
- /home/kamil/projects/cv/node_modules/next/dist/compiled/webpack/webpack.js
- /home/kamil/projects/cv/node_modules/next/dist/server/hot-reloader.js
- /home/kamil/projects/cv/node_modules/next/dist/server/next-dev-server.js
- /home/kamil/projects/cv/node_modules/next/dist/server/next.js
- /home/kamil/projects/cv/node_modules/next/dist/server/lib/start-server.js
- /home/kamil/projects/cv/node_modules/next/dist/cli/next-dev.js
- /home/kamil/projects/cv/node_modules/next/dist/bin/next

What is the expected behavior?

No error.

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.

  1. Clone this repo: https://github.com/kamilmielnik/cv
  2. Checkout this commit: https://github.com/kamilmielnik/cv/pull/5/commits/747bd11e66eaef5e7f86f09b10f41ccb788b68b4
  3. npm install
  4. npm run dev or npm run build

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)

Not sure if it has anything to do with me using Next.js, but things broke when I upgraded it from 10.0.2 to 10.0.7. Installing webpack explicitly didn't help. But this workaround fixes it: https://github.com/kamilmielnik/cv/pull/5/commits/d01d00784806da5154ac452f5e7ef9e45b0ebc37

d3x42 commented 3 years ago

I'm working on a fix, please try svg-sprite-loader@5.2.1-remove-get-webpack-version

rumsky commented 3 years ago

Same issue on webpack 4.44.1

kamilmielnik commented 3 years ago

@d3x42 I confirm that svg-sprite-loader@5.2.1-remove-get-webpack-version fixes the issue!