Skip to content

Commit

Permalink
fix: Fix the problem that esbuild service cannot be detected due to c…
Browse files Browse the repository at this point in the history
…hildcompiler in webpack For example, mini CSS extract plugin

Among the common plugins in webpack, many plugins create child-compiler to build their own chunks.
However, the value of $esbuildservice is not correctly assigned, which causes errors in the
compilation of webpack on the child-compiler,For example, mini CSS extract plugin

Closes privatenumber#16
  • Loading branch information
zhusjfaker committed Aug 5, 2020
1 parent 8e1e6b9 commit 70dad27
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugin.js
Expand Up @@ -13,6 +13,15 @@ class ESBuildPlugin {
}
}

compiler.hooks.thisCompilation.tap('esbuild', (compilation) => {
compilation.hooks.childCompiler.tap(
'esbuild',
(childCompiler, _compilerName, _compilerIndex) => {
childCompiler.$esbuildService = compiler.$esbuildService
}
)
})

compiler.hooks.run.tapPromise('esbuild', async () => {
await startService()
})
Expand Down

0 comments on commit 70dad27

Please sign in to comment.