-
-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[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
Showing
3 changed files
with
27 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters