Skip to content

Commit 59b53cf

Browse files
authored
Merge pull request #68 from wellcaffeinated/issue-67
Fix for #67
2 parents d7c85f9 + 7cfd8bd commit 59b53cf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ loader.pitch = function(request) {
6363
if (this.target!=='webworker' && this.target!=='web') {
6464
(new NodeTargetPlugin()).apply(worker.compiler);
6565
}
66+
67+
// webpack >= v4 supports webassembly
68+
let wasmPluginPath = null;
69+
try {
70+
wasmPluginPath = require.resolve(
71+
'webpack/lib/web/FetchCompileWasmTemplatePlugin'
72+
);
73+
} catch (_err) {
74+
// webpack <= v3, skipping
75+
}
76+
77+
if (wasmPluginPath) {
78+
// eslint-disable-next-line global-require, import/no-dynamic-require
79+
const FetchCompileWasmTemplatePlugin = require(wasmPluginPath);
80+
new FetchCompileWasmTemplatePlugin({
81+
mangleImports: this._compiler.options.optimization.mangleWasmImports,
82+
}).apply(worker.compiler);
83+
}
6684

6785
(new SingleEntryPlugin(this.context, `!!${path.resolve(__dirname, 'rpc-worker-loader.js')}!${request}`, 'main')).apply(worker.compiler);
6886

0 commit comments

Comments
 (0)