diff --git a/babel.config.cjs b/babel.config.cjs index d5c314af15..23ab202ae0 100644 --- a/babel.config.cjs +++ b/babel.config.cjs @@ -31,5 +31,22 @@ module.exports = { "@babel/plugin-transform-object-rest-spread", "@babel/plugin-syntax-dynamic-import", "@babel/plugin-transform-runtime", + [ + "search-and-replace", + { + // Since rewriteImportExtensions doesn't work on dynamic imports (yet), we need to manually replace + // the dynamic rust-crypto import. + // (see https://github.com/babel/babel/issues/16750) + rules: + process.env.NODE_ENV !== "test" + ? [ + { + search: "./rust-crypto/index.ts", + replace: "./rust-crypto/index.js", + }, + ] + : [], + }, + ], ], }; diff --git a/package.json b/package.json index 46687405ca..e2e274b8b2 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", "babel-jest": "^29.0.0", + "babel-plugin-search-and-replace": "^1.1.1", "debug": "^4.3.4", "eslint": "8.57.0", "eslint-config-google": "^0.14.0", diff --git a/src/client.ts b/src/client.ts index 3a9860b3a8..514586047a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -2254,9 +2254,7 @@ export class MatrixClient extends TypedEventEmitter