From f7ee30b1d0d2398b78cac521000d9710d7972cad Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Tue, 11 May 2021 09:19:26 +0200 Subject: [PATCH] fix: [plugin] Use compiler.webpack when possible (#1822) fixes #1781 --- lib/plugin-webpack5.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plugin-webpack5.js b/lib/plugin-webpack5.js index 9b156ff12..c1eee5906 100644 --- a/lib/plugin-webpack5.js +++ b/lib/plugin-webpack5.js @@ -31,9 +31,10 @@ const ruleSetCompiler = new RuleSetCompiler([ class VueLoaderPlugin { apply (compiler) { + const normalModule = 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 = require('webpack/lib/NormalModule').getCompilationHooks(compilation).loader + const normalModuleLoader = normalModule.getCompilationHooks(compilation).loader normalModuleLoader.tap(id, loaderContext => { loaderContext[NS] = true })