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

Webpack 5 compatibility: Missing module RuleSet #1599

Closed
Lyrkan opened this issue Oct 14, 2019 · 6 comments
Closed

Webpack 5 compatibility: Missing module RuleSet #1599

Lyrkan opened this issue Oct 14, 2019 · 6 comments

Comments

@Lyrkan
Copy link

Lyrkan commented Oct 14, 2019

Version

15.7.1

Reproduction link

https://github.com/Lyrkan/repro-vue-loader-webpack5

Steps to reproduce

  • Create a project that uses Webpack 5 and vue-loader 15.7.1
  • Try to run Webpack

What is expected?

No error

What is actually happening?

Error: Cannot find module 'webpack/lib/RuleSet'


Hi there,

Webpack 5 (that just got into beta) removed the RuleSet class that is currently used by the vue-loader plugin in the following PR: webpack/webpack#9138

This makes any attempt to use the plugin fail with a "Cannot find module webpack/lib/RuleSet" error.

@danyadev
Copy link

danyadev commented Nov 2, 2019

Any updates?

@18566246732
Copy link

18566246732 commented Nov 21, 2019

webpack5 has rewrited the ruleset module, which means the VueLoaderPlugin cannot use class Ruleset any more, instead, it should use the RuleSetCompiler.

here is my pr #1607, there are too many changes in VueLoaderPlugin, I think vue-loader needs a major version update to support webpack5. hope can get you guys attention, thanks

@18566246732
Copy link

18566246732 commented Nov 21, 2019

as a workaround, you can use this node package only for webpack5
vue-loader-plugin

@18566246732
Copy link

@sodatea Hi, I made a new pr according to your suggestions #1613

@lovetingyuan
Copy link

npm latest version is still 15.7.2, is it not released to npm?

@haoqunjiang
Copy link
Member

Seems an npm issue, as I've found several similar complaints on Twitter:

It seems to have taken effect after I've published v15.8.1

weaverryan added a commit to symfony/webpack-encore that referenced this issue Dec 31, 2020
This PR was squashed before being merged into the main branch.

Discussion
----------

Update Webpack to v5 (+ other dependencies)

Last week Webpack added a compat layer to its v5 alpha that allows the `mini-css-extract-plugin` to run on it (with deprecated messages). Since we include that plugin by default (and a lot of our tests relie on it) it was the main thing blocking us from preparing the migration.

---

I basically started from #564 which was updating some dependencies, enabling CSS HMR when needed and adding a `configureMiniCssExtractPlugin(...)` method, but with a few changes:
* no more inconsistent hashes checks for the `enableVersioning applies to js, css & manifest` test: it seems to be working fine by default
* no more embedding the `webpack-manifest-plugin` into our code: shellscape/webpack-manifest-plugin#167 is still an issue but @mastilver has been working on the project lately (which is why the plugin works with Webpack 5) and a fix has already been merged on the `next` branch, so it's probably only a matter of time now :). **Edit: Fixed in `webpack-manifest-plugin@^3.0.0-rc`**
* removal of Node 8 compatibility

So now, about the state of that PR:

**0 failing test left**:
* ~6 tests that will probably be fixed by webpack/webpack#10661 in `[email protected]`: `Uncaught Error: Error when running the browser: Error: Error when running the browser: ReferenceError: mod is not defined`~
* ~All the 7 tests related to the `vue-loader` are failing with a `Cannot find module 'webpack/lib/RuleSet` error message (see: vuejs/vue-loader#1599
* ~1 test related to the `webpack-manifest-plugin` issue previously mentioned~
* ~1 test related to `createSharedEntry()` which doesn't seem to work properly~
* ~1 test related to Babel that doesn't transform an arrow function as expected~

**A lot of deprecation notices** (but most, if not all, of them are triggered by vendors), for instance:
* `Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader`
* `Module.id: Use new ChunkGraph API`
* `Module.updateHash: Use new ChunkGraph API`
* `Chunk.modulesIterable: Use new ChunkGraph API`
* `ChunkGroup.getModuleIndex2 was renamed to getModulePostOrderIndex`
* `Compilation.chunks was changed from Array to Set (using Array method 'reduce' is deprecated)`
* `chunk.files was changed from Array to Set (using Array method 'reduce' is deprecated)`

**Some modules do not declare they are compatible with Webpack 5 yet** *(warning messages during `yarn install`)*: this shouldn't be an issue **unless** those modules require a major version upgrade to be officialy compatible (in which case breaking changes could impact us).

**We're still using `webpack-cli@3`** which may not support Webpack 5. It currently seems to be OK but we should probably upgrade to `webpack-cli@4` (currently in beta). I took a quick glance at it and it probably won't be an easy thing to do, mainly because of how our "runtime context" works and how the new version of the CLI calls Webpack (through another process).

Commits
-------

57f64fa Remove unusued files/constants related to versioning/shared entry
8d7843a Add removed Babel test back
216a5ca Update css-loader and style-loader
ddcd6d8 Merge branch 'main' into webpack5
444c37f Merge branch 'main' into webpack5
b292e76 Fix linting issues
d576b21 Remove deprecation caused by the DeletedUnusuedEntriesJSPlugin
b0f7190 Update some hashes in functional tests
4f6171b Update WebpackManifestPlugin to v3.0.0 and vue-loader to v16.1.0
9af90ee Remove wrong comment
50cea18 Bump min. Typescript version to 3.6.3
1d22520 Don't set hmr option for mini-css-extract-plugin (deprecated since 1.0.0)
564b147 Update Vue.js dependencies
8da531e Replace optimize-css-assets-webpack-plugin by css-minimizer-webpack-plugin
f3843ca Update Webpack to 5.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants