Skip to content

vue-loader crashes build if used together with html-webpack-plugin@next #1771

Closed
@jantimon

Description

@jantimon

Version

vue-loader: 16.1.1
html-webpack-plugin: 5.0.0-alpha.17

Reproduction link

https://codesandbox.io/s/html-webpack-plugin-5x-alpha-vue-6n1ub?file=/webpack.config.js:0-360

Steps to reproduce

Install the [email protected] and run the following webpack config

Code:

const HtmlWebpackPlugin = require("html-webpack-plugin");
const VueLoaderPlugin = require("vue-loader/lib/plugin");

module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: "vue-loader"
      }
    ]
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin()
  ]
};

What is happening?

I am not even using a .vue file in my project but the loader is kicking in and crashes the child compilation of the html-webpack-plugin with the following trace:

Error: Child compilation failed:\n' +
        "  Cannot read property 'slice' of undefined\n" +
        "  TypeError: Cannot read property 'slice' of undefined\n" +
        '  \n' +
        '  - plugin-webpack5.js:123 Object.resourceQuery [as fn]\n'
+
        '    [platform]/[vue-loader]/lib/plugin-webpack5.js:123:39\n
' +
        '  \n' +
        '  - RuleSetCompiler.js:99 execRule\n' +
        '    [platform]/[webpack]/lib/rules/RuleSetCompiler.js:99:21

So it looks like query is empty in

const parsed = qs.parse(query.slice(1))

Any idea why the vue-loader is having issues here?
It worked fine with [email protected]

Maybe using thisCompilation instead of compilation could fix it:

compiler.hooks.compilation.tap(id, compilation => {

However switching to thisCompilation might break the vue file compilation in childcompilers e.g. for ssr in the html-webpack-plugin similar to this react jsx example: https://codesandbox.io/s/html-webpack-plugin--jsx-sjbcq

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions