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 fe8a7e2 commit 86b0c75
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion 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 Down Expand Up @@ -101,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 86b0c75

Please sign in to comment.