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 (#17)

* fix: Fix the problem that esbuild service cannot be detected due to childcompiler 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 #16

* tweaks

Co-authored-by: zhushijie.jayson <zhushijie.jayson@bytedance.com>
Co-authored-by: Kevin Titor <0x142857@gmail.com>
  • Loading branch information
3 people committed Aug 5, 2020
1 parent 8e1e6b9 commit 501f2ba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ class ESBuildPlugin {
}
}

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

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

0 comments on commit 501f2ba

Please sign in to comment.