|
1 | 1 | // eslint-disable-next-line import/extensions
|
2 | 2 | import compatData from "@babel/compat-data/plugins";
|
| 3 | +// eslint-disable-next-line import/extensions |
| 4 | +import bugfixesData from "@babel/compat-data/plugin-bugfixes"; |
3 | 5 | import * as babel from "@babel/core";
|
4 | 6 |
|
5 | 7 | import { USE_ESM, itBabel7, itBabel8, describeBabel7NoESM } from "$repo-utils";
|
@@ -312,13 +314,27 @@ describe("babel-preset-env", () => {
|
312 | 314 | });
|
313 | 315 |
|
314 | 316 | 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 | + ) |
319 | 329 | .sort();
|
| 330 | + const arrCompatData = [ |
| 331 | + ...Object.keys(compatData), |
| 332 | + ...Object.keys(bugfixesData), |
| 333 | + ].sort(); |
320 | 334 |
|
321 |
| - expect(arrAvailablePlugins).toEqual(expect.arrayContaining(arrCompatData)); |
| 335 | + for (const plugin of arrAvailablePlugins) { |
| 336 | + expect(arrCompatData).toContain(plugin); |
| 337 | + } |
322 | 338 | });
|
323 | 339 |
|
324 | 340 | describe("debug", () => {
|
|
0 commit comments