Use native Wasm+Webpack support for Rust codecs

This delegates loading of Wasm modules to Webpack itself, making wrapper code simpler.

Emscripten-generated modules are still using custom loading glue as they're not compatible with Webpack.
This commit is contained in:
Ingvar Stepanyan
2019-08-05 14:50:18 +01:00
parent b8f801333d
commit 8e857cd393
14 changed files with 100 additions and 308 deletions

View File

@@ -147,8 +147,9 @@ module.exports = async function (_, env) {
loader: 'exports-loader'
},
{
// For some reason using `include` here breaks the build.
test: /[/\\]codecs[/\\].*\.wasm$/,
// Emscripten modules don't work with Webpack's Wasm loader.
test: /\.wasm$/,
exclude: /_bg\.wasm$/,
// This is needed to make webpack NOT process wasm files.
// See https://github.com/webpack/webpack/issues/6725
type: 'javascript/auto',
@@ -157,6 +158,11 @@ module.exports = async function (_, env) {
name: '[name].[hash:5].[ext]',
},
},
{
// Wasm modules generated by Rust + wasm-pack work great with Webpack.
test: /_bg\.wasm$/,
type: 'webassembly/experimental',
},
{
test: /\.(png|svg|jpg|gif)$/,
loader: 'file-loader',