Merge pull request #17193 from vector-im/travis/voicemessages/safari

Add required webpack+jest config to load Safari support modules
This commit is contained in:
Travis Ralston 2021-05-11 10:12:36 -06:00 committed by GitHub
commit c00abd6add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View file

@ -167,7 +167,10 @@
"^react$": "<rootDir>/node_modules/react", "^react$": "<rootDir>/node_modules/react",
"^react-dom$": "<rootDir>/node_modules/react-dom", "^react-dom$": "<rootDir>/node_modules/react-dom",
"^matrix-js-sdk$": "<rootDir>/node_modules/matrix-js-sdk/src", "^matrix-js-sdk$": "<rootDir>/node_modules/matrix-js-sdk/src",
"^matrix-react-sdk$": "<rootDir>/node_modules/matrix-react-sdk/src" "^matrix-react-sdk$": "<rootDir>/node_modules/matrix-react-sdk/src",
"decoderWorker\\.min\\.js": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/empty.js",
"decoderWorker\\.min\\.wasm": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/empty.js",
"waveWorker\\.min\\.js": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/empty.js"
}, },
"transformIgnorePatterns": [ "transformIgnorePatterns": [
"/node_modules/(?!matrix-js-sdk).+$", "/node_modules/(?!matrix-js-sdk).+$",

View file

@ -47,6 +47,11 @@ module.exports = (env, argv) => {
return { return {
...development, ...development,
node: {
// Mock out the NodeFS module: The opus decoder imports this wrongly.
fs: 'empty',
},
entry: { entry: {
"bundle": "./src/vector/index.ts", "bundle": "./src/vector/index.ts",
"indexeddb-worker": "./src/vector/indexeddb-worker.js", "indexeddb-worker": "./src/vector/indexeddb-worker.js",
@ -278,6 +283,43 @@ module.exports = (env, argv) => {
outputPath: '.', 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 // cache-bust languages.json file placed in
// element-web/webapp/i18n during build by copy-res.js // element-web/webapp/i18n during build by copy-res.js