Skip to content

Commit 820d23c

Browse files
authored
fix(plugin): use compiler.webpack when possible (#1884)
1 parent 2eccc0e commit 820d23c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/pluginWebpack5.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ class VueLoaderPlugin implements Plugin {
9898
static NS = NS
9999

100100
apply(compiler: Compiler) {
101+
// @ts-ignore
102+
const normalModule = compiler.webpack.NormalModule || NormalModule
103+
101104
// add NS marker so that the loader can detect and report missing plugin
102105
compiler.hooks.compilation.tap(id, (compilation) => {
103-
NormalModule.getCompilationHooks(compilation).loader.tap(
104-
id,
105-
(loaderContext: any) => {
106+
normalModule
107+
.getCompilationHooks(compilation)
108+
.loader.tap(id, (loaderContext: any) => {
106109
loaderContext[NS] = true
107-
}
108-
)
110+
})
109111
})
110112

111113
const rules = compiler.options.module!.rules

0 commit comments

Comments
 (0)