Skip to content

Commit a0c8871

Browse files
authored
Test: Improve available-plugins compat-data check (#16693)
* test: improve available-plugins comat-data check * fix: incorrect syntax-unicode-sets-regex entry
1 parent 782e0ea commit a0c8871

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

packages/babel-preset-env/src/available-plugins.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ if (!process.env.BABEL_8_BREAKING) {
234234
// syntax enabled by default, we can safely skip enabling it.
235235
if (!USE_ESM) {
236236
// @ts-expect-error unknown key
237-
legacyBabel7SyntaxPluginsLoaders["unicode-sets-regex"] = IS_STANDALONE
238-
? e()
239-
: () => require("@babel/plugin-syntax-unicode-sets-regex");
237+
legacyBabel7SyntaxPluginsLoaders["syntax-unicode-sets-regex"] =
238+
IS_STANDALONE
239+
? e()
240+
: () => require("@babel/plugin-syntax-unicode-sets-regex");
240241
}
241242

242243
Object.assign(availablePlugins, legacyBabel7SyntaxPluginsLoaders);

packages/babel-preset-env/test/index.skip-bundled.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// eslint-disable-next-line import/extensions
22
import compatData from "@babel/compat-data/plugins";
3+
// eslint-disable-next-line import/extensions
4+
import bugfixesData from "@babel/compat-data/plugin-bugfixes";
35
import * as babel from "@babel/core";
46

57
import { USE_ESM, itBabel7, itBabel8, describeBabel7NoESM } from "$repo-utils";
@@ -312,13 +314,27 @@ describe("babel-preset-env", () => {
312314
});
313315

314316
it("available-plugins is in sync with @babel/compat-data", () => {
315-
const arrAvailablePlugins = Object.keys(availablePlugins).sort();
316-
const arrCompatData = Object.keys(compatData)
317-
// TODO(Babel 8): Remove this .map
318-
.map(name => name.replace("proposal-", "transform-"))
317+
const arrAvailablePlugins = Object.keys(availablePlugins)
318+
.filter(
319+
name =>
320+
// 1. The syntax plugins are always enabled, they don't have compat-data entries
321+
// 2. The modules transforms are for non-ES module systems, they don't have compat-data entries
322+
// 3. The dynamic import transform is controlled by the modules option and the API caller support
323+
!(
324+
name.startsWith("syntax-") ||
325+
name.startsWith("transform-modules-") ||
326+
name === "transform-dynamic-import"
327+
),
328+
)
319329
.sort();
330+
const arrCompatData = [
331+
...Object.keys(compatData),
332+
...Object.keys(bugfixesData),
333+
].sort();
320334

321-
expect(arrAvailablePlugins).toEqual(expect.arrayContaining(arrCompatData));
335+
for (const plugin of arrAvailablePlugins) {
336+
expect(arrCompatData).toContain(plugin);
337+
}
322338
});
323339

324340
describe("debug", () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy