From aed1d9db1248bc6f000d1f90696a2d182db2c34a Mon Sep 17 00:00:00 2001 From: Alekos Filini Date: Mon, 1 Nov 2021 15:32:05 +0000 Subject: [PATCH 1/2] Correctly report errors during the first compilation Errors are ignored the first time the Rust code is compiled. This causes `yarn run build` on downstream projects to succeed even when compilation actually failed. --- plugin.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin.js b/plugin.js index df1597d..c870f2a 100644 --- a/plugin.js +++ b/plugin.js @@ -107,16 +107,16 @@ class WasmPackPlugin { let first = true compiler.hooks.thisCompilation.tap('WasmPackPlugin', (compilation) => { + // This is needed in order to gracefully handle errors in Webpack, + // since Webpack has its own custom error system. + if (this.error != null) { + compilation.errors.push(this.error) + } + // Super hacky, needed to workaround a bug in Webpack which causes // thisCompilation to be triggered twice on the first compilation. if (first) { first = false - } else { - // This is needed in order to gracefully handle errors in Webpack, - // since Webpack has its own custom error system. - if (this.error != null) { - compilation.errors.push(this.error) - } } }) } From 9c4d6061b2a3b4f03d60a27296aff73a1d39bc4a Mon Sep 17 00:00:00 2001 From: Alekos Filini Date: Mon, 1 Nov 2021 17:05:22 +0000 Subject: [PATCH 2/2] Remove unused code --- plugin.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugin.js b/plugin.js index c870f2a..e29bce2 100644 --- a/plugin.js +++ b/plugin.js @@ -104,20 +104,12 @@ class WasmPackPlugin { }) }) - let first = true - compiler.hooks.thisCompilation.tap('WasmPackPlugin', (compilation) => { // This is needed in order to gracefully handle errors in Webpack, // since Webpack has its own custom error system. if (this.error != null) { compilation.errors.push(this.error) } - - // Super hacky, needed to workaround a bug in Webpack which causes - // thisCompilation to be triggered twice on the first compilation. - if (first) { - first = false - } }) }