Skip to content

Commit 78b3193

Browse files
committed
add checkWasmTypes flag, enabled it only in production
1 parent 591521b commit 78b3193

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/WebpackOptionsApply.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ class WebpackOptionsApply extends OptionsApply {
340340
if (options.optimization.noEmitOnErrors) {
341341
new NoEmitOnErrorsPlugin().apply(compiler);
342342
}
343+
if (options.optimization.checkWasmTypes) {
344+
new WasmFinalizeExportsPlugin().apply(compiler);
345+
}
343346
if (options.optimization.namedModules) {
344347
new NamedModulesPlugin().apply(compiler);
345348
}
@@ -361,11 +364,6 @@ class WebpackOptionsApply extends OptionsApply {
361364
new SizeLimitsPlugin(options.performance).apply(compiler);
362365
}
363366

364-
// FIXME(sven): this should be conditional
365-
// if (options.optimization.jsIncompatibleExports) {
366-
new WasmFinalizeExportsPlugin().apply(compiler);
367-
// }
368-
369367
new TemplatedPathPlugin().apply(compiler);
370368

371369
new RecordIdsPlugin({

lib/WebpackOptionsDefaulter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
254254
this.set("optimization.noEmitOnErrors", "make", options =>
255255
isProductionLikeMode(options)
256256
);
257+
this.set("optimization.checkWasmTypes", "make", options =>
258+
isProductionLikeMode(options)
259+
);
257260
this.set(
258261
"optimization.namedModules",
259262
"make",

schemas/WebpackOptions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,10 @@
15421542
"description": "Avoid emitting assets when errors occur",
15431543
"type": "boolean"
15441544
},
1545+
"checkWasmTypes": {
1546+
"description": "Check for incompatible wasm types when importing/exporting from/to ESM",
1547+
"type": "boolean"
1548+
},
15451549
"namedModules": {
15461550
"description": "Use readable module identifiers for better debugging",
15471551
"type": "boolean"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
22

33
module.exports = function(config) {
4-
return supportsWebAssembly();
4+
return supportsWebAssembly() && config.mode === "production";
55
};

0 commit comments

Comments
 (0)