Skip to content
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

Cannot find module 'webpack/lib/RuleSet' #359

Closed
DrGor opened this issue Oct 14, 2019 · 8 comments
Closed

Cannot find module 'webpack/lib/RuleSet' #359

DrGor opened this issue Oct 14, 2019 · 8 comments

Comments

@DrGor
Copy link

DrGor commented Oct 14, 2019

Do you want to request a feature, report a bug or ask a question?
bug
What is the current behavior?
throws an error: Cannot find module 'webpack/lib/RuleSet'
What is the expected behavior?
works with webpack 5

Please tell us about your environment:

  • Node.js version: ?
  • webpack version: 5
  • svg-sprite-loader version: v4.1.6
  • OS type & version: ?

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
Please see webpack/webpack#9802 (comment) and vuejs/vue-loader#1427 (comment)
In a nutshell, webpack needs to be added as a dependency.

@Lyrkan
Copy link

Lyrkan commented Oct 14, 2019

@DrGor

Please see webpack/webpack#9802 (comment) and vuejs/vue-loader#1427 (comment)
In a nutshell, webpack needs to be added as a dependency.

As noted in my comment in the Webpack thread the problem comes from the removal of RuleSet in Webpack 5 (webpack/webpack#9138).

The solution from that vue-loader issue only applies to Webpack <= 4 in which this class was present (it didn't really make sense to use the loader without Webpack anyway...).

What I meant by "vue-loader has the same issue" is that its code will also have to be changed in order to make it work with Webpack 5.

@DrGor
Copy link
Author

DrGor commented Oct 14, 2019

@Lyrkan

I have no experience with vue-loader, but I can see they still use RuleSet, see it here https://github.com/vuejs/vue-loader/blob/master/lib/plugin.js

and their library is marked as compatible with Webpack 5, see here: https://github.com/vuejs/vue-loader/blob/master/package.json#L37

and I also can't find any open issues around RuleSet in their repo.
So I am confused :)

@Lyrkan
Copy link

Lyrkan commented Oct 14, 2019

I have no experience with vue-loader, but I can see they still use RuleSet, see it here vuejs/vue-loader:lib/plugin.js@master

Yep, that's exactly what I was referring to :)

and their library is marked as compatible with Webpack 5, see here: vuejs/vue-loader:package.json@master#L37

That line was changed in january, before the RuleSet class was removed.

and I also can't find any open issues around RuleSet in their repo.

I couldn't find one either, so there you go: vuejs/vue-loader#1599

@mayako21126
Copy link

here is my pr add support for webpack5 to add support for webpack5。Hope it helps you guys

@dkrnl
Copy link

dkrnl commented Oct 11, 2020

@zhongzhong0505
Copy link

any updates?

@izaika
Copy link

izaika commented Dec 4, 2020

Found a workaround without forking or publishing packages.
In the root of your project directory (where your package.json file situated) create two files:

// funcMock.js
module.exports = () => {}

// prebuild.sh

#!/bin/bash

cat ./funcMock.js > ./node_modules/svg-sprite-loader/lib/utils/get-matched-rule.js

Make sure prebuild.sh has enough permissions to be executed (sudo chmod 777 ./prebuild.sh)

change your build (or start) script in package json so it executes sh file before compiling by webpack: ./prebuild.sh && webpack --config webpack.config.js

And it works

@glen-84
Copy link

glen-84 commented Dec 6, 2020

Fixed in v5.1.1 (?).

/cc @d3x42.

@d3x42 d3x42 closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants