Skip to content

Commit

Permalink
Cleanup rust-crypto import and babel config.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Oct 8, 2024
1 parent 5c2ab29 commit c919571
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 9 additions & 6 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ module.exports = {
[
"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"
? []
: [
process.env.NODE_ENV !== "test"
? [
{
search: 'import("./rust-crypto")',
replace: 'import("./rust-crypto/index.js")',
search: "./rust-crypto/index.ts",
replace: "./rust-crypto/index.js",
},
],
]
: [],
},
],
],
Expand Down
4 changes: 1 addition & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2254,9 +2254,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
// importing rust-crypto will download the webassembly, so we delay it until we know it will be
// needed.
this.logger.debug("Downloading Rust crypto library");
// blocked on https://github.com/matrix-org/matrix-js-sdk/issues/4392 / https://github.com/babel/babel/issues/16750
// eslint-disable-next-line node/file-extension-in-import
const RustCrypto = await import("./rust-crypto");
const RustCrypto = await import("./rust-crypto/index.ts");

const rustCrypto = await RustCrypto.initRustCrypto({
logger: this.logger,
Expand Down

0 comments on commit c919571

Please sign in to comment.