Skip to content

Commit 07a0af2

Browse files
committed
Add required webpack config to load Safari support modules
See matrix-org/matrix-react-sdk#5989
1 parent 7cfec92 commit 07a0af2

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Diff for: webpack.config.js

+42
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ module.exports = (env, argv) => {
4747
return {
4848
...development,
4949

50+
node: {
51+
// Mock out the NodeFS module: The opus decoder imports this wrongly.
52+
fs: 'empty',
53+
},
54+
5055
entry: {
5156
"bundle": "./src/vector/index.ts",
5257
"indexeddb-worker": "./src/vector/indexeddb-worker.js",
@@ -278,6 +283,43 @@ module.exports = (env, argv) => {
278283
outputPath: '.',
279284
},
280285
},
286+
{
287+
// This is from the same place as the encoderWorker above, but only needed
288+
// for Safari support.
289+
test: /decoderWorker\.min\.js$/,
290+
loader: "file-loader",
291+
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
292+
options: {
293+
// We deliberately override the name so it makes sense in debugging
294+
name: 'opus-decoderWorker.min.[hash:7].[ext]',
295+
outputPath: '.',
296+
},
297+
},
298+
{
299+
// This is from the same place as the encoderWorker above, but only needed
300+
// for Safari support.
301+
test: /decoderWorker\.min\.wasm$/,
302+
loader: "file-loader",
303+
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
304+
options: {
305+
// We deliberately don't change the name because the decoderWorker has this
306+
// hardcoded. This is here to avoid the default wasm rule from adding a hash.
307+
name: 'decoderWorker.min.wasm',
308+
outputPath: '.',
309+
},
310+
},
311+
{
312+
// This is from the same place as the encoderWorker above, but only needed
313+
// for Safari support.
314+
test: /waveWorker\.min\.js$/,
315+
loader: "file-loader",
316+
type: "javascript/auto", // https://github.com/webpack/webpack/issues/6725
317+
options: {
318+
// We deliberately override the name so it makes sense in debugging
319+
name: 'wave-encoderWorker.min.[hash:7].[ext]',
320+
outputPath: '.',
321+
},
322+
},
281323
{
282324
// cache-bust languages.json file placed in
283325
// element-web/webapp/i18n during build by copy-res.js

0 commit comments

Comments
 (0)