From 2472b2f71d0d0a5ce56e067b7697a496a495ea7c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 11 May 2021 15:20:53 +0800 Subject: [PATCH] fix: check for compiler.webpack existence It's only available since webpack 5.1 --- lib/plugin-webpack5.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/plugin-webpack5.js b/lib/plugin-webpack5.js index c1eee5906..91126ffec 100644 --- a/lib/plugin-webpack5.js +++ b/lib/plugin-webpack5.js @@ -31,7 +31,9 @@ const ruleSetCompiler = new RuleSetCompiler([ class VueLoaderPlugin { apply (compiler) { - const normalModule = compiler.webpack.NormalModule || require("webpack/lib/NormalModule") + const normalModule = compiler.webpack + ? compiler.webpack.NormalModule + : require('webpack/lib/NormalModule') // add NS marker so that the loader can detect and report missing plugin compiler.hooks.compilation.tap(id, compilation => { const normalModuleLoader = normalModule.getCompilationHooks(compilation).loader