From c97848cd834274024c990de616430a615bc1e47a Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Sun, 11 Apr 2021 17:54:27 +0200 Subject: [PATCH] [plugin] Use compiler.webpack when possible (fixes #1781) See https://github.com/webpack/webpack/issues/12606 for more information. --- 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 })