Skip to content

Webpack 5 compatibility: Options from some rules are applied to others #1620

Closed
@Lyrkan

Description

@Lyrkan

Version

15.8.3

Reproduction link

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

Steps to reproduce

  1. Create a basic project using the latest version of vue-loader and Webpack 5 with the three following rules :
  • { test: /\.js$/, use: [ { loader: 'babel-loader', options: {} } ] }
  • { test: /\.css$/, use: [ { loader: 'css-loader', options: { url: true } } ] } (url can be replaced by any option that exists in css-loader but not in babel-loader)
  • { test: /\.vue$/, loader: 'vue-loader' }
  1. Import a .vue file that contains a <script> tag

  2. Try to compile the project

What is expected?

Should compile fine

What is actually happening?

The build fails because the url option meant for the css-loader is passed to the babel-loader:

ERROR in ./src/App.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ruleSet[0].rules[0].use[0]!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
ReferenceError: Unknown option: .url. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

It does not happen when using Webpack 4
It does not happen either when not using Rule.use or when options is not specified in the babel-loader rule.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions