Update preset-env builtin-definitions (#10929)
* chore: build corejs3-proposals.json from core-js-compat * fix: include finished proposals by default * update test fixtures * update test fixtures * chore: rename scripts * fix: add standarized entries for finished proposals * refactor: remove unused finished proposals json * revert test fixtures update * test against corejs 3.6 * fix: move corejs builtin definitions to babel/compat-data
This commit is contained in:
parent
31b0506040
commit
1613418f9b
4
packages/babel-compat-data/corejs3-shipped-proposals.js
Normal file
4
packages/babel-compat-data/corejs3-shipped-proposals.js
Normal file
@ -0,0 +1,4 @@
|
||||
// Node < 13.3 doesn't support export maps in package.json.
|
||||
// Use this proxy file as a fallback.
|
||||
|
||||
module.exports = require("./data/corejs3-shipped-proposals.json");
|
||||
@ -0,0 +1,5 @@
|
||||
[
|
||||
"esnext.global-this",
|
||||
"esnext.promise.all-settled",
|
||||
"esnext.string.match-all"
|
||||
]
|
||||
@ -12,10 +12,11 @@
|
||||
"./plugins": "./data/plugins.json",
|
||||
"./native-modules": "./data/native-modules.json",
|
||||
"./corejs2-built-ins": "./data/corejs2-built-ins.json",
|
||||
"./corejs3-shipped-proposals": "./data/corejs3-shipped-proposals",
|
||||
"./overlapping-plugins": "./data/overlapping-plugins.json"
|
||||
},
|
||||
"scripts": {
|
||||
"build-data": "./scripts/download-compat-table.sh; node ./scripts/build-data.js; node ./scripts/build-modules-support.js; node ./scripts/build-overlapping-plugins.js"
|
||||
"build-data": "./scripts/download-compat-table.sh; node ./scripts/build-data.js; node ./scripts/build-modules-support.js; node ./scripts/build-overlapping-plugins.js; node ./scripts/build-corejs3-proposals.js"
|
||||
},
|
||||
"keywords": [
|
||||
"babel",
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
const data = require("core-js-compat/data.json");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const features = Object.keys(data);
|
||||
|
||||
const shippedProposals = features.filter(feature => {
|
||||
return feature.startsWith("esnext.") && Object.keys(data[feature]).length > 0;
|
||||
});
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, "../data/corejs3-shipped-proposals.json"),
|
||||
JSON.stringify(shippedProposals, undefined, 2) + "\n"
|
||||
);
|
||||
|
||||
const finishedProposals = shippedProposals.filter(feature => {
|
||||
return features.includes(feature.replace("esnext.", "es."));
|
||||
});
|
||||
|
||||
const builtInDefinitionsPath = path.join(
|
||||
__dirname,
|
||||
"../../babel-preset-env/src/polyfills/corejs3/built-in-definitions.js"
|
||||
);
|
||||
|
||||
const builtInDefinitions = fs.readFileSync(builtInDefinitionsPath, "utf-8");
|
||||
|
||||
for (const feature of finishedProposals) {
|
||||
const standarizedName = feature.replace("esnext.", "es.");
|
||||
if (!builtInDefinitions.includes(standarizedName)) {
|
||||
console.log(
|
||||
`${feature} is now standarized as ${standarizedName}, please add "${standarizedName}" to "${builtInDefinitionsPath}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ export const BuiltIns: ObjectMap<string[]> = {
|
||||
compositeKey: ["esnext.composite-key"],
|
||||
compositeSymbol: ["esnext.composite-symbol", ...SymbolDependencies],
|
||||
fetch: PromiseDependencies,
|
||||
globalThis: ["esnext.global-this"],
|
||||
globalThis: ["es.global-this", "esnext.global-this"],
|
||||
parseFloat: ["es.parse-float"],
|
||||
parseInt: ["es.parse-int"],
|
||||
queueMicrotask: ["web.queue-microtask"],
|
||||
@ -205,7 +205,7 @@ export const InstanceProperties: ObjectMap<string[]> = {
|
||||
lastItem: ["esnext.array.last-item"],
|
||||
link: ["es.string.link"],
|
||||
match: ["es.string.match", "es.regexp.exec"],
|
||||
matchAll: ["esnext.string.match-all"],
|
||||
matchAll: ["es.string.match-all", "esnext.string.match-all"],
|
||||
map: ["es.array.map"],
|
||||
name: ["es.function.name"],
|
||||
padEnd: ["es.string.pad-end"],
|
||||
@ -355,6 +355,7 @@ export const StaticProperties: ObjectMap<ObjectMap<string | string[]>> = {
|
||||
Promise: {
|
||||
all: PromiseDependenciesWithIterators,
|
||||
allSettled: [
|
||||
"es.promise.all-settled",
|
||||
"esnext.promise.all-settled",
|
||||
...PromiseDependenciesWithIterators,
|
||||
],
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
|
||||
export default (["esnext.global-this", "esnext.string.match-all"]: string[]);
|
||||
@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import corejs3Polyfills from "core-js-compat/data";
|
||||
import corejs3ShippedProposalsList from "./shipped-proposals";
|
||||
import corejs3ShippedProposalsList from "@babel/compat-data/corejs3-shipped-proposals";
|
||||
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
|
||||
import { filterItems } from "@babel/helper-compilation-targets";
|
||||
import {
|
||||
@ -39,7 +39,7 @@ const corejs3PolyfillsWithoutProposals = Object.keys(corejs3Polyfills)
|
||||
return memo;
|
||||
}, {});
|
||||
|
||||
const corejs3PolyfillsWithShippedProposals = corejs3ShippedProposalsList.reduce(
|
||||
const corejs3PolyfillsWithShippedProposals = (corejs3ShippedProposalsList: string[]).reduce(
|
||||
(memo, key) => {
|
||||
memo[key] = corejs3Polyfills[key];
|
||||
return memo;
|
||||
|
||||
@ -24,3 +24,6 @@ const foo = new Promise((resolve) => {
|
||||
queueMicrotask(() => globalThis);
|
||||
|
||||
Observable.from(10);
|
||||
|
||||
Promise.allSettled([]);
|
||||
S.matchAll();
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"../../../../lib",
|
||||
{
|
||||
"useBuiltIns": "usage",
|
||||
"corejs": 3,
|
||||
"corejs": "3.6",
|
||||
"modules": false
|
||||
}
|
||||
]
|
||||
|
||||
@ -4,12 +4,15 @@ import "core-js/modules/es.symbol.iterator";
|
||||
import "core-js/modules/es.symbol.match";
|
||||
import "core-js/modules/es.array.from";
|
||||
import "core-js/modules/es.array.iterator";
|
||||
import "core-js/modules/es.global-this";
|
||||
import "core-js/modules/es.map";
|
||||
import "core-js/modules/es.object.to-string";
|
||||
import "core-js/modules/es.promise";
|
||||
import "core-js/modules/es.promise.all-settled";
|
||||
import "core-js/modules/es.regexp.exec";
|
||||
import "core-js/modules/es.string.iterator";
|
||||
import "core-js/modules/es.string.match";
|
||||
import "core-js/modules/es.string.match-all";
|
||||
import "core-js/modules/web.dom-collections.iterator";
|
||||
import "core-js/modules/web.queue-microtask";
|
||||
Array.from; // static method
|
||||
@ -49,3 +52,5 @@ queueMicrotask(function () {
|
||||
return globalThis;
|
||||
});
|
||||
Observable.from(10);
|
||||
Promise.allSettled([]);
|
||||
S.matchAll();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user