Skip to content

Commit

Permalink
fix: support webpack multi-compiler (#431)
Browse files Browse the repository at this point in the history
Closes: #426
  • Loading branch information
piotr-oles committed May 28, 2020
1 parent 9b3b9dd commit 503a948
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/hooks/tapAfterCompileToGetIssues.ts
Expand Up @@ -13,6 +13,11 @@ function tapAfterCompileToGetIssues(
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);

compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', async (compilation) => {
if (compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}

let issues: Issue[] | undefined = [];

try {
Expand Down
5 changes: 5 additions & 0 deletions src/hooks/tapDoneToAsyncGetIssues.ts
Expand Up @@ -17,6 +17,11 @@ function tapDoneToAsyncGetIssues(
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);

compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', async (stats) => {
if (stats.compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}

const report = state.report;
let issues: Issue[] | undefined;

Expand Down
5 changes: 5 additions & 0 deletions src/hooks/tapDoneToCollectRemoved.ts
Expand Up @@ -9,6 +9,11 @@ function tapDoneToCollectRemoved(
state: ForkTsCheckerWebpackPluginState
) {
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => {
if (stats.compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}

state.removedFiles = [];

// the new watcher is defined after done hook
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/tapStartToConnectAndRunReporter.ts
Expand Up @@ -18,7 +18,7 @@ function tapStartToConnectAndRunReporter(
) {
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);

compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', (compiler) => {
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
if (!state.initialized) {
state.initialized = true;

Expand All @@ -27,7 +27,7 @@ function tapStartToConnectAndRunReporter(
}
});

compiler.hooks.watchRun.tap('ForkTsCheckerWebpackPlugin', async (compiler) => {
compiler.hooks.watchRun.tap('ForkTsCheckerWebpackPlugin', async () => {
if (!state.initialized) {
state.initialized = true;

Expand All @@ -42,6 +42,11 @@ function tapStartToConnectAndRunReporter(
});

compiler.hooks.compilation.tap('ForkTsCheckerWebpackPlugin', async (compilation) => {
if (compilation.compiler !== compiler) {
// run only for the compiler that the plugin was registered for
return;
}

let change: FilesChange = {};

if (state.watching) {
Expand Down

0 comments on commit 503a948

Please sign in to comment.