Skip to content

Commit

Permalink
add checkWasmTypes flag, enabled it only in production
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 4, 2018
1 parent 591521b commit 78b3193
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/WebpackOptionsApply.js
Expand Up @@ -340,6 +340,9 @@ class WebpackOptionsApply extends OptionsApply {
if (options.optimization.noEmitOnErrors) {
new NoEmitOnErrorsPlugin().apply(compiler);
}
if (options.optimization.checkWasmTypes) {
new WasmFinalizeExportsPlugin().apply(compiler);
}
if (options.optimization.namedModules) {
new NamedModulesPlugin().apply(compiler);
}
Expand All @@ -361,11 +364,6 @@ class WebpackOptionsApply extends OptionsApply {
new SizeLimitsPlugin(options.performance).apply(compiler);
}

// FIXME(sven): this should be conditional
// if (options.optimization.jsIncompatibleExports) {
new WasmFinalizeExportsPlugin().apply(compiler);
// }

new TemplatedPathPlugin().apply(compiler);

new RecordIdsPlugin({
Expand Down
3 changes: 3 additions & 0 deletions lib/WebpackOptionsDefaulter.js
Expand Up @@ -254,6 +254,9 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("optimization.noEmitOnErrors", "make", options =>
isProductionLikeMode(options)
);
this.set("optimization.checkWasmTypes", "make", options =>
isProductionLikeMode(options)
);
this.set(
"optimization.namedModules",
"make",
Expand Down
4 changes: 4 additions & 0 deletions schemas/WebpackOptions.json
Expand Up @@ -1542,6 +1542,10 @@
"description": "Avoid emitting assets when errors occur",
"type": "boolean"
},
"checkWasmTypes": {
"description": "Check for incompatible wasm types when importing/exporting from/to ESM",
"type": "boolean"
},
"namedModules": {
"description": "Use readable module identifiers for better debugging",
"type": "boolean"
Expand Down
2 changes: 1 addition & 1 deletion test/cases/wasm/js-incompatible-type/test.filter.js
@@ -1,5 +1,5 @@
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");

module.exports = function(config) {
return supportsWebAssembly();
return supportsWebAssembly() && config.mode === "production";
};

0 comments on commit 78b3193

Please sign in to comment.