mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Constrain webpack config for olm.wasm
(#23633)
I've been experimenting with loading WebAssembly into EW, for which I need to use webpack's default wasm loader. Currently we're overriding that for *all* files called `*.wasm`, which is too broad. There are currently two `*.wasm` artifacts in EW: `decoderWorker.min.wasm`, and `olm.wasm`. `decoderWorker` has its own rule, so the `*.wasm` rule is only used for `olm.wasm`. So, let's tighten up the test for that rule so that it doesn't catch other innocent `.wasm`s in the cross-fire.
This commit is contained in:
parent
2a46122f28
commit
1b98601870
@ -369,9 +369,14 @@ module.exports = (env, argv) => {
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
// the olm library wants to load its own wasm, rather than have webpack do it.
|
||||
// We therefore use the `file-loader` to tell webpack to dump the contents to
|
||||
// a separate file and return the name, and override the default `type` for `.wasm` files
|
||||
// (which is `webassembly/experimental` under webpack 4) to stop webpack trying to interpret
|
||||
// the filename as webassembly. (see also https://github.com/webpack/webpack/issues/6725)
|
||||
test: /olm\.wasm$/,
|
||||
loader: "file-loader",
|
||||
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
|
||||
type: "javascript/auto",
|
||||
options: {
|
||||
name: '[name].[hash:7].[ext]',
|
||||
outputPath: '.',
|
||||
@ -382,7 +387,7 @@ module.exports = (env, argv) => {
|
||||
// We more or less just want it to be clear it's for opus and not something else.
|
||||
test: /encoderWorker\.min\.js$/,
|
||||
loader: "file-loader",
|
||||
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
|
||||
type: "javascript/auto",
|
||||
options: {
|
||||
// We deliberately override the name so it makes sense in debugging
|
||||
name: 'opus-encoderWorker.min.[hash:7].[ext]',
|
||||
@ -422,11 +427,11 @@ module.exports = (env, argv) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
// This is from the same place as the encoderWorker above, but only needed
|
||||
// for Safari support.
|
||||
// Same deal as olm.wasm: the decoderWorker wants to load the wasm artifact
|
||||
// itself.
|
||||
test: /decoderWorker\.min\.wasm$/,
|
||||
loader: "file-loader",
|
||||
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
|
||||
type: "javascript/auto",
|
||||
options: {
|
||||
// We deliberately don't change the name because the decoderWorker has this
|
||||
// hardcoded. This is here to avoid the default wasm rule from adding a hash.
|
||||
@ -652,6 +657,7 @@ module.exports = (env, argv) => {
|
||||
// chunks even after the app is redeployed.
|
||||
filename: "bundles/[hash]/[name].js",
|
||||
chunkFilename: "bundles/[hash]/[name].js",
|
||||
webassemblyModuleFilename: "bundles/[hash]/[modulehash].wasm",
|
||||
},
|
||||
|
||||
// configuration for the webpack-dev-server
|
||||
|
Loading…
Reference in New Issue
Block a user