Allow using preset-env with newer versions of compat-data (#11201)
* Use ~ for preset-env's @babel/compat-data dependency * Revert "Use ~ for preset-env's @babel/compat-data dependency" This reverts commit e7d57c7894095d381670cddfbbce06bd2a480a32. * Allow using `preset-env` with newer versions of `compat-data`
This commit is contained in:
parent
a12001a0f9
commit
7127330f02
@ -6,7 +6,7 @@ import getOptionSpecificExcludesFor from "./get-option-specific-excludes";
|
|||||||
import { removeUnnecessaryItems } from "./filter-items";
|
import { removeUnnecessaryItems } from "./filter-items";
|
||||||
import moduleTransformations from "./module-transformations";
|
import moduleTransformations from "./module-transformations";
|
||||||
import normalizeOptions from "./normalize-options";
|
import normalizeOptions from "./normalize-options";
|
||||||
import pluginList from "@babel/compat-data/plugins";
|
import pluginList from "./plugins-compat-data";
|
||||||
import { proposalPlugins, pluginSyntaxMap } from "../data/shipped-proposals";
|
import { proposalPlugins, pluginSyntaxMap } from "../data/shipped-proposals";
|
||||||
import overlappingPlugins from "@babel/compat-data/overlapping-plugins";
|
import overlappingPlugins from "@babel/compat-data/overlapping-plugins";
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import findSuggestion from "levenary";
|
|||||||
import invariant from "invariant";
|
import invariant from "invariant";
|
||||||
import { coerce, SemVer } from "semver";
|
import { coerce, SemVer } from "semver";
|
||||||
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
|
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
|
||||||
import pluginsList from "@babel/compat-data/plugins";
|
import pluginsList from "./plugins-compat-data";
|
||||||
import moduleTransformations from "./module-transformations";
|
import moduleTransformations from "./module-transformations";
|
||||||
import { TopLevelOptions, ModulesOption, UseBuiltInsOption } from "./options";
|
import { TopLevelOptions, ModulesOption, UseBuiltInsOption } from "./options";
|
||||||
import { defaultWebIncludes } from "./polyfills/corejs2/get-platform-specific-default";
|
import { defaultWebIncludes } from "./polyfills/corejs2/get-platform-specific-default";
|
||||||
|
|||||||
13
packages/babel-preset-env/src/plugins-compat-data.js
Normal file
13
packages/babel-preset-env/src/plugins-compat-data.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// @flow
|
||||||
|
|
||||||
|
import plugins from "@babel/compat-data/plugins";
|
||||||
|
import availablePlugins from "./available-plugins";
|
||||||
|
|
||||||
|
const filtered = {};
|
||||||
|
for (const plugin of Object.keys(plugins)) {
|
||||||
|
if (Object.hasOwnProperty.call(availablePlugins, plugin)) {
|
||||||
|
filtered[plugin] = plugins[plugin];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { filtered as default };
|
||||||
@ -15,6 +15,9 @@ const removeRegeneratorEntryPlugin = require("../lib/polyfills/regenerator/entry
|
|||||||
.default;
|
.default;
|
||||||
const transformations = require("../lib/module-transformations").default;
|
const transformations = require("../lib/module-transformations").default;
|
||||||
|
|
||||||
|
const compatData = require("@babel/compat-data/plugins");
|
||||||
|
const availablePlugins = require("../lib/available-plugins").default;
|
||||||
|
|
||||||
describe("babel-preset-env", () => {
|
describe("babel-preset-env", () => {
|
||||||
describe("transformIncludesAndExcludes", () => {
|
describe("transformIncludesAndExcludes", () => {
|
||||||
it("should return in transforms array", () => {
|
it("should return in transforms array", () => {
|
||||||
@ -248,4 +251,11 @@ describe("babel-preset-env", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("available-plugins is in sync with @babel/compat-data", () => {
|
||||||
|
const arrAvailablePlugins = Object.keys(availablePlugins).sort();
|
||||||
|
const arrCompatData = Object.keys(compatData).sort();
|
||||||
|
|
||||||
|
expect(arrAvailablePlugins).toEqual(expect.arrayContaining(arrCompatData));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user