From 820d23cbf16013dae894e0d84ed9da6e58a37584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sevil=20Y=C4=B1lmaz?= Date: Sun, 10 Oct 2021 10:31:35 +0200 Subject: [PATCH] fix(plugin): use compiler.webpack when possible (#1884) --- 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