Skip to content

Commit

Permalink
Preserve ESM for async imports to work correctly (#4187)
Browse files Browse the repository at this point in the history
* fix: fix lazy rust crypto import

* test: use "commonjs" for tests because of circular deps

* chore: revert commonjs for "module"

* refactor: remove unnecessary example

* refactor: add comments

Signed-off-by: Bayyr Oorjak <[email protected]>

* refactor: improve comment

Signed-off-by: Bayyr Oorjak <[email protected]>

Co-authored-by: Richard van der Hoff <[email protected]>

* Update babel.config.js

---------

Signed-off-by: Bayyr Oorjak <[email protected]>
Co-authored-by: Richard van der Hoff <[email protected]>
  • Loading branch information
ms-dosx86 and richvdh authored May 21, 2024
1 parent 93d9628 commit fd3a4d4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
22 changes: 0 additions & 22 deletions .babelrc

This file was deleted.

26 changes: 26 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
sourceMaps: true,
presets: [
[
"@babel/preset-env",
{
targets: {
esmodules: true,
},
// We want to output ES modules for the final build (mostly to ensure that
// async imports work correctly). However, jest doesn't support ES modules very
// well yet (see https://github.com/jestjs/jest/issues/9430), so we use commonjs
// when testing.
modules: process.env.NODE_ENV === "test" ? "commonjs" : false,
},
],
"@babel/preset-typescript",
],
plugins: [
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-runtime",
],
};
2 changes: 1 addition & 1 deletion src/models/MSC3089TreeSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { ISendEventResponse } from "../@types/requests";
import { FileType } from "../http-api";
import { KnownMembership } from "../@types/membership";
import { RoomPowerLevelsEventContent, SpaceChildEventContent } from "../@types/state_events";
import { EncryptedFile, FileContent } from "../@types/media";
import type { EncryptedFile, FileContent } from "../@types/media";

/**
* The recommended defaults for a tree space's power levels. Note that this
Expand Down

0 comments on commit fd3a4d4

Please sign in to comment.