2018-06-29 16:03:21 +08:00
|
|
|
const { CachedSource } = require("webpack-sources");
|
|
|
|
|
|
|
|
/** @typedef {import("../../../lib/Compilation")} Compilation */
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.wat$/,
|
|
|
|
loader: "wast-loader",
|
2019-05-24 18:30:43 +08:00
|
|
|
type: "webassembly/async-experimental"
|
2018-06-29 16:03:21 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
function() {
|
|
|
|
this.hooks.compilation.tap(
|
|
|
|
"Test",
|
|
|
|
/**
|
|
|
|
* @param {Compilation} compilation Compilation
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
compilation => {
|
|
|
|
compilation.moduleTemplates.webassembly.hooks.package.tap(
|
|
|
|
"Test",
|
|
|
|
source => {
|
|
|
|
// this is important to make each returned value a new instance
|
|
|
|
return new CachedSource(source);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|