Skip to content

Commit fd3a4d4

Browse files
ms-dosx86richvdh
andauthored
Preserve ESM for async imports to work correctly (#4187)
* 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 <the.bayyr.oorjak@gmail.com> * refactor: improve comment Signed-off-by: Bayyr Oorjak <the.bayyr.oorjak@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Update babel.config.js --------- Signed-off-by: Bayyr Oorjak <the.bayyr.oorjak@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
1 parent 93d9628 commit fd3a4d4

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

.babelrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

babel.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
sourceMaps: true,
3+
presets: [
4+
[
5+
"@babel/preset-env",
6+
{
7+
targets: {
8+
esmodules: true,
9+
},
10+
// We want to output ES modules for the final build (mostly to ensure that
11+
// async imports work correctly). However, jest doesn't support ES modules very
12+
// well yet (see https://github.com/jestjs/jest/issues/9430), so we use commonjs
13+
// when testing.
14+
modules: process.env.NODE_ENV === "test" ? "commonjs" : false,
15+
},
16+
],
17+
"@babel/preset-typescript",
18+
],
19+
plugins: [
20+
"@babel/plugin-proposal-numeric-separator",
21+
"@babel/plugin-proposal-class-properties",
22+
"@babel/plugin-proposal-object-rest-spread",
23+
"@babel/plugin-syntax-dynamic-import",
24+
"@babel/plugin-transform-runtime",
25+
],
26+
};

src/models/MSC3089TreeSpace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { ISendEventResponse } from "../@types/requests";
3535
import { FileType } from "../http-api";
3636
import { KnownMembership } from "../@types/membership";
3737
import { RoomPowerLevelsEventContent, SpaceChildEventContent } from "../@types/state_events";
38-
import { EncryptedFile, FileContent } from "../@types/media";
38+
import type { EncryptedFile, FileContent } from "../@types/media";
3939

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

0 commit comments

Comments
 (0)