Skip to content

Commit

Permalink
Fix exports is undefined (#826) (#841) (#847)
Browse files Browse the repository at this point in the history
* Add allowTopLevelThis=true option for @babel/plugin-transform-modules-commonjs

* remove override babel.config.js for build

---------

(cherry picked from commit be25b8b)

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 639df0d)

Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: bowenlan-amzn <bowenlan23@gmail.com>
  • Loading branch information
opensearch-trigger-bot[bot] and bowenlan-amzn committed Sep 22, 2023
1 parent a2bdf5e commit 6aece6f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@

// babelrc doesn't respect NODE_PATH anymore but using require does.
// Alternative to install them locally in node_modules
module.exports = {
presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")],
plugins: [
[require("@babel/plugin-transform-runtime"), { regenerator: true }],
require("@babel/plugin-proposal-class-properties"),
require("@babel/plugin-proposal-object-rest-spread"),
],
module.exports = function (api) {
// ensure env is test so that this config won't impact build or dev server
if (api.env("test")) {
return {
presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")],
plugins: [
[require("@babel/plugin-transform-runtime"), { regenerator: true }],
require("@babel/plugin-proposal-class-properties"),
require("@babel/plugin-proposal-object-rest-spread"),
[require("@babel/plugin-transform-modules-commonjs"), { allowTopLevelThis: true }],
],
};
}
return {};
};

0 comments on commit 6aece6f

Please sign in to comment.