From 07a0af2aaef1931e6a4cda7173f04c53fd74e0f6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 6 May 2021 21:51:03 -0600 Subject: [PATCH] Add required webpack config to load Safari support modules See https://github.com/matrix-org/matrix-react-sdk/pull/5989 --- webpack.config.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index 560beec121..9d7fa703d9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -47,6 +47,11 @@ module.exports = (env, argv) => { return { ...development, + node: { + // Mock out the NodeFS module: The opus decoder imports this wrongly. + fs: 'empty', + }, + entry: { "bundle": "./src/vector/index.ts", "indexeddb-worker": "./src/vector/indexeddb-worker.js", @@ -278,6 +283,43 @@ module.exports = (env, argv) => { outputPath: '.', }, }, + { + // This is from the same place as the encoderWorker above, but only needed + // for Safari support. + test: /decoderWorker\.min\.js$/, + loader: "file-loader", + type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725 + options: { + // We deliberately override the name so it makes sense in debugging + name: 'opus-decoderWorker.min.[hash:7].[ext]', + outputPath: '.', + }, + }, + { + // This is from the same place as the encoderWorker above, but only needed + // for Safari support. + test: /decoderWorker\.min\.wasm$/, + loader: "file-loader", + type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725 + 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. + name: 'decoderWorker.min.wasm', + outputPath: '.', + }, + }, + { + // This is from the same place as the encoderWorker above, but only needed + // for Safari support. + test: /waveWorker\.min\.js$/, + loader: "file-loader", + type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725 + options: { + // We deliberately override the name so it makes sense in debugging + name: 'wave-encoderWorker.min.[hash:7].[ext]', + outputPath: '.', + }, + }, { // cache-bust languages.json file placed in // element-web/webapp/i18n during build by copy-res.js