Skip to content

Commit

Permalink
Fix ESM build
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 22, 2023
1 parent 6094af7 commit 872e159
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/babel-preset-env/src/available-plugins.ts
@@ -1,5 +1,7 @@
/* eslint sort-keys: "error" */

declare const USE_ESM: boolean;

import syntaxAsyncGenerators from "@babel/plugin-syntax-async-generators";
import syntaxClassProperties from "@babel/plugin-syntax-class-properties";
import syntaxClassStaticBlock from "@babel/plugin-syntax-class-static-block";
Expand All @@ -16,7 +18,6 @@ import syntaxOptionalCatchBinding from "@babel/plugin-syntax-optional-catch-bind
import syntaxOptionalChaining from "@babel/plugin-syntax-optional-chaining";
import syntaxPrivatePropertyInObject from "@babel/plugin-syntax-private-property-in-object";
import syntaxTopLevelAwait from "@babel/plugin-syntax-top-level-await";
import syntaxUnicodeSetsRegex from "@babel/plugin-syntax-unicode-sets-regex";
import proposalAsyncGeneratorFunctions from "@babel/plugin-proposal-async-generator-functions";
import proposalClassProperties from "@babel/plugin-proposal-class-properties";
import proposalClassStaticBlock from "@babel/plugin-proposal-class-static-block";
Expand Down Expand Up @@ -102,7 +103,13 @@ export default {
"syntax-optional-chaining": () => syntaxOptionalChaining,
"syntax-private-property-in-object": () => syntaxPrivatePropertyInObject,
"syntax-top-level-await": () => syntaxTopLevelAwait,
"syntax-unicode-sets-regex": () => syntaxUnicodeSetsRegex,
// This is a CJS plugin that depends on a package from the monorepo, so it
// breaks using ESM. Given that ESM builds are new enough to have this
// syntax enabled by default, we can safely skip enabling it.
"syntax-unicode-sets-regex": USE_ESM
? null
: // eslint-disable-next-line no-restricted-globals
() => require("@babel/plugin-syntax-unicode-sets-regex"),
"transform-arrow-functions": () => transformArrowFunctions,
"transform-async-generator-functions": () => proposalAsyncGeneratorFunctions,
"transform-async-to-generator": () => transformAsyncToGenerator,
Expand Down

0 comments on commit 872e159

Please sign in to comment.