From e1f36a6761445c649067c3e0363b8f406c93f4b6 Mon Sep 17 00:00:00 2001 From: Sevil Yilmaz Date: Mon, 4 Oct 2021 15:23:15 +0200 Subject: [PATCH] fix(plugin): use compiler.webpack when possible Applies the fix (f7ee30b1d0d2398b78cac521000d9710d7972cad) that fixes the same issue on v15. Related to #1781 --- src/pluginWebpack5.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pluginWebpack5.ts b/src/pluginWebpack5.ts index 6cb83945b..0ffec99e5 100644 --- a/src/pluginWebpack5.ts +++ b/src/pluginWebpack5.ts @@ -98,14 +98,16 @@ class VueLoaderPlugin implements Plugin { static NS = NS apply(compiler: Compiler) { + // @ts-ignore + const normalModule = compiler.webpack.NormalModule || NormalModule + // add NS marker so that the loader can detect and report missing plugin compiler.hooks.compilation.tap(id, (compilation) => { - NormalModule.getCompilationHooks(compilation).loader.tap( - id, - (loaderContext: any) => { + normalModule + .getCompilationHooks(compilation) + .loader.tap(id, (loaderContext: any) => { loaderContext[NS] = true - } - ) + }) }) const rules = compiler.options.module!.rules