Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract targets parser and compat data from preset-env #10899

Merged
merged 4 commits into from Jan 10, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -20,6 +20,8 @@ dist
package-lock.json
!/.github/actions/*/package-lock.json

/packages/babel-compat-data/build

/packages/babel-runtime/helpers/*.js
!/packages/babel-runtime/helpers/toArray.js
!/packages/babel-runtime/helpers/iterableToArray.js
@@ -1,5 +1,7 @@
package.json
packages/babel-preset-env/data
packages/babel-compat-data/data
packages/babel-compat-data/scripts/data/overlapping-plugins.js
packages/*/test/fixtures/**/input.*
packages/*/test/fixtures/**/exec.*
packages/*/test/fixtures/**/output.*
@@ -181,7 +181,12 @@ function buildRollup(packages) {
},
}),
rollupCommonJs({
include: [/node_modules/, "packages/babel-preset-env/data/**"],
include: [
/node_modules/,
"packages/babel-preset-env/data/*.js",
// Rollup doesn't read export maps, so it loads the cjs fallback
"packages/babel-compat-data/*.js",
],
namedExports: {
"babel-plugin-dynamic-import-node/utils.js": [
"createDynamicImportTransform",
@@ -30,24 +30,16 @@ module.exports = function(api) {
switch (env) {
// Configs used during bundling builds.
case "rollup":
convertESM = false;
ignoreLib = false;
// rollup-commonjs will converts node_modules to ESM
unambiguousSources.push(
"**/node_modules",
// todo: remove this after it is rewritten into ESM
"packages/babel-preset-env/data"
);
envOpts.targets = {
node: nodeVersion,
};
break;
case "standalone":
convertESM = false;
ignoreLib = false;
unambiguousSources.push(
"**/node_modules",
"packages/babel-preset-env/data"
"packages/babel-preset-env/data",
"packages/babel-compat-data"
);
// targets to browserslists: defaults
break;
@@ -0,0 +1,4 @@
scripts
src
test
*.log
@@ -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/corejs2-built-ins.json");
@@ -0,0 +1,12 @@
{
"es6.module": {
"edge": "16",
"firefox": "60",
"chrome": "61",
"safari": "10.1",
"opera": "48",
"ios_saf": "10.3",
"and_chr": "74",
"and_ff": "66"
}
}
@@ -0,0 +1,3 @@
{
"transform-regenerator": []
}
File renamed without changes.
@@ -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/native-modules.json");
@@ -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/overlapping-plugins.json");
@@ -0,0 +1,36 @@
{
"name": "@babel/compat-data",
"version": "0.0.0",
"author": "The Babel Team (https://babeljs.io/team)",
"license": "MIT",
"description": "",

This comment has been minimized.

Copy link
@JLHwung

JLHwung Jan 8, 2020

Contributor

Maybe "Engine compat data used in @babel/preset-env"?

"repository": "https://github.com/babel/babel/tree/master/packages/babel-compat-data",
"publishConfig": {
"access": "public"
},
"exports": {
"./plugins": "./data/plugins.json",
"./native-modules": "./data/native-modules.json",
"./corejs2-built-ins": "./data/corejs2-built-ins.json",
"./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"
},
"keywords": [
"babel",
"compat-table",
"compat-data"
],
"dependencies": {
"browserslist": "^4.8.2",
"invariant": "^2.2.4",
"semver": "^7.1.1"
},
"devDependencies": {
"caniuse-db": "1.0.30000969",
"electron-to-chromium": "1.3.113",
"lodash": "^4.17.15",
"@babel/helper-compilation-targets": "^0.0.0"
}
}
@@ -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/plugins.json");
@@ -7,7 +7,7 @@ const flattenDeep = require("lodash/flattenDeep");
const isEqual = require("lodash/isEqual");
const mapValues = require("lodash/mapValues");
const pickBy = require("lodash/pickBy");
const unreleasedLabels = require("../data/unreleased-labels");
const { unreleasedLabels } = require("babel/helper-compilation-targets");
const electronToChromiumVersions = require("electron-to-chromium").versions;

const electronToChromiumKeys = Object.keys(
@@ -293,7 +293,7 @@ const generateData = (environments, features) => {
["plugin", "corejs2-built-in"].forEach(target => {
const newData = generateData(
environments,
require(`../data/${target}-features`)
require(`./data/${target}-features`)
);
const dataPath = path.join(__dirname, `../data/${target}s.json`);

@@ -0,0 +1,15 @@
"use strict";

const fs = require("fs");
const overlappingPlugins = require("./data/overlapping-plugins");

fs.writeFileSync(
__dirname + "/../data/overlapping-plugins.json",
JSON.stringify(overlappingPlugins, replacer, 2)
);

function replacer(key, val) {
if (val instanceof Set) return Array.from(val);
if (val instanceof Map) return Object.fromEntries(val);
return val;
}
@@ -26,15 +26,16 @@ const typedArrayMethods = [
"typed arrays / %TypedArray%[Symbol.species]",
];

const es = {
module.exports = {
// compat-table missing babel6 mapping
// "es6.array.concat": {
// features: [
// "well-known symbols / Symbol.isConcatSpreadable",
// "well-known symbols / Symbol.species, Array.prototype.concat",
// ]
// },
"es6.array.copy-within": "Array.prototype methods / Array.prototype.copyWithin",
"es6.array.copy-within":
"Array.prototype methods / Array.prototype.copyWithin",
"es6.array.every": "Array methods / Array.prototype.every",
"es6.array.fill": "Array.prototype methods / Array.prototype.fill",
"es6.array.filter": {
@@ -46,7 +47,8 @@ const es = {
},
"es6.array.find": "Array.prototype methods / Array.prototype.find",
"es6.array.find-index": "Array.prototype methods / Array.prototype.findIndex",
"es7.array.flat-map": "Array.prototype.{flat, flatMap} / Array.prototype.flatMap",
"es7.array.flat-map":
"Array.prototype.{flat, flatMap} / Array.prototype.flatMap",
"es6.array.for-each": "Array methods / Array.prototype.forEach",
"es6.array.from": "Array static methods / Array.from",
"es7.array.includes": "Array.prototype.includes",
@@ -90,8 +92,8 @@ const es = {
"es6.function.has-instance": "well-known symbols / Symbol.hasInstance",
"es6.function.name": {
features: [
"function \"name\" property / function statements",
"function \"name\" property / function expressions",
'function "name" property / function statements',
'function "name" property / function expressions',
],
},

@@ -174,13 +176,19 @@ const es = {
],
},
"es6.object.define-property": "Object static methods / Object.defineProperty",
"es6.object.define-properties": "Object static methods / Object.defineProperties",
"es6.object.define-properties":
"Object static methods / Object.defineProperties",
"es7.object.entries": "Object static methods / Object.entries",
"es6.object.freeze": "Object static methods accept primitives / Object.freeze",
"es6.object.get-own-property-descriptor": "Object static methods accept primitives / Object.getOwnPropertyDescriptor",
"es7.object.get-own-property-descriptors": "Object static methods / Object.getOwnPropertyDescriptors",
"es6.object.get-own-property-names": "Object static methods accept primitives / Object.getOwnPropertyNames",
"es6.object.get-prototype-of": "Object static methods accept primitives / Object.getPrototypeOf",
"es6.object.freeze":
"Object static methods accept primitives / Object.freeze",
"es6.object.get-own-property-descriptor":
"Object static methods accept primitives / Object.getOwnPropertyDescriptor",
"es7.object.get-own-property-descriptors":
"Object static methods / Object.getOwnPropertyDescriptors",
"es6.object.get-own-property-names":
"Object static methods accept primitives / Object.getOwnPropertyNames",
"es6.object.get-prototype-of":
"Object static methods accept primitives / Object.getPrototypeOf",
"es7.object.lookup-getter": {
features: [
"Object.prototype getter/setter methods / __lookupGetter__",
@@ -199,15 +207,20 @@ const es = {
"Object.prototype getter/setter methods / __lookupSetter__, data properties can shadow accessors",
],
},
"es6.object.prevent-extensions": "Object static methods accept primitives / Object.preventExtensions",
"es6.object.prevent-extensions":
"Object static methods accept primitives / Object.preventExtensions",
"es6.object.to-string": "well-known symbols / Symbol.toStringTag",
"es6.object.is": "Object static methods / Object.is",
"es6.object.is-frozen": "Object static methods accept primitives / Object.isFrozen",
"es6.object.is-sealed": "Object static methods accept primitives / Object.isSealed",
"es6.object.is-extensible": "Object static methods accept primitives / Object.isExtensible",
"es6.object.is-frozen":
"Object static methods accept primitives / Object.isFrozen",
"es6.object.is-sealed":
"Object static methods accept primitives / Object.isSealed",
"es6.object.is-extensible":
"Object static methods accept primitives / Object.isExtensible",
"es6.object.keys": "Object static methods accept primitives / Object.keys",
"es6.object.seal": "Object static methods accept primitives / Object.seal",
"es6.object.set-prototype-of": "Object static methods / Object.setPrototypeOf",
"es6.object.set-prototype-of":
"Object static methods / Object.setPrototypeOf",
"es7.object.values": "Object static methods / Object.values",

"es6.promise": {
@@ -224,7 +237,8 @@ const es = {
"es6.reflect.define-property": "Reflect / Reflect.defineProperty",
"es6.reflect.delete-property": "Reflect / Reflect.deleteProperty",
"es6.reflect.get": "Reflect / Reflect.get",
"es6.reflect.get-own-property-descriptor": "Reflect / Reflect.getOwnPropertyDescriptor",
"es6.reflect.get-own-property-descriptor":
"Reflect / Reflect.getOwnPropertyDescriptor",
"es6.reflect.get-prototype-of": "Reflect / Reflect.getPrototypeOf",
"es6.reflect.has": "Reflect / Reflect.has",
"es6.reflect.is-extensible": "Reflect / Reflect.isExtensible",
@@ -240,11 +254,16 @@ const es = {
],
},
"es6.regexp.flags": "RegExp.prototype properties / RegExp.prototype.flags",
"es6.regexp.match": "RegExp.prototype properties / RegExp.prototype[Symbol.match]",
"es6.regexp.replace": "RegExp.prototype properties / RegExp.prototype[Symbol.replace]",
"es6.regexp.split": "RegExp.prototype properties / RegExp.prototype[Symbol.split]",
"es6.regexp.search": "RegExp.prototype properties / RegExp.prototype[Symbol.search]",
"es6.regexp.to-string": "miscellaneous / RegExp.prototype.toString generic and uses \"flags\" property",
"es6.regexp.match":
"RegExp.prototype properties / RegExp.prototype[Symbol.match]",
"es6.regexp.replace":
"RegExp.prototype properties / RegExp.prototype[Symbol.replace]",
"es6.regexp.split":
"RegExp.prototype properties / RegExp.prototype[Symbol.split]",
"es6.regexp.search":
"RegExp.prototype properties / RegExp.prototype[Symbol.search]",
"es6.regexp.to-string":
'miscellaneous / RegExp.prototype.toString generic and uses "flags" property',

// This is explicit due to prevent the stage-1 Set proposals under the
// category "Set methods" from being included.
@@ -295,23 +314,27 @@ const es = {
"es6.string.big": "String.prototype HTML methods",
"es6.string.blink": "String.prototype HTML methods",
"es6.string.bold": "String.prototype HTML methods",
"es6.string.code-point-at": "String.prototype methods / String.prototype.codePointAt",
"es6.string.ends-with": "String.prototype methods / String.prototype.endsWith",
"es6.string.code-point-at":
"String.prototype methods / String.prototype.codePointAt",
"es6.string.ends-with":
"String.prototype methods / String.prototype.endsWith",
"es6.string.fixed": "String.prototype HTML methods",
"es6.string.fontcolor": "String.prototype HTML methods",
"es6.string.fontsize": "String.prototype HTML methods",
"es6.string.from-code-point": "String static methods / String.fromCodePoint",
"es6.string.includes": "String.prototype methods / String.prototype.includes",
"es6.string.italics": "String.prototype HTML methods",
"es6.string.iterator": "String.prototype methods / String.prototype[Symbol.iterator]",
"es6.string.iterator":
"String.prototype methods / String.prototype[Symbol.iterator]",
"es6.string.link": "String.prototype HTML methods",
// "String.prototype methods / String.prototype.normalize" not implemented
"es7.string.pad-start": "String padding / String.prototype.padStart",
"es7.string.pad-end": "String padding / String.prototype.padEnd",
"es6.string.raw": "String static methods / String.raw",
"es6.string.repeat": "String.prototype methods / String.prototype.repeat",
"es6.string.small": "String.prototype HTML methods",
"es6.string.starts-with": "String.prototype methods / String.prototype.startsWith",
"es6.string.starts-with":
"String.prototype methods / String.prototype.startsWith",
"es6.string.strike": "String.prototype HTML methods",
"es6.string.sub": "String.prototype HTML methods",
"es6.string.sup": "String.prototype HTML methods",
@@ -353,7 +376,3 @@ const es = {

"es6.weak-set": "WeakSet",
};

const proposals = require("./shipped-proposals").builtIns;

module.exports = Object.assign({}, es, proposals);
@@ -4,13 +4,13 @@ module.exports = new Map();

// async -> regenerator is better than async -> generator -> regenerator
ifIncluded("transform-regenerator")
// https://github.com/babel/babel/issues/10678
// Temporarly disabled: https://github.com/babel/babel/issues/10678
// .isUnnecessary("transform-async-to-generator");

function ifIncluded(name) {
const set = new Set();
module.exports.set(name, set);
return {
isUnnecessary(name) { set.add(name); return this; }
isUnnecessary(name) { set.add(name); return this; },
};
}
@@ -1,4 +1,4 @@
const es = {
module.exports = {
"transform-template-literals": {
features: ["template literals"],
},
@@ -65,10 +65,7 @@ const es = {
],
},
"transform-destructuring": {
features: [
"destructuring, assignment",
"destructuring, declarations",
],
features: ["destructuring, assignment", "destructuring, declarations"],
},
"transform-block-scoping": {
features: ["const", "let"],
@@ -98,11 +95,9 @@ const es = {
"proposal-json-strings": "JSON superset",
"proposal-optional-catch-binding": "optional catch binding",
"transform-named-capturing-groups-regex": "RegExp named capture groups",
"transform-member-expression-literals": "Object/array literal extensions / Reserved words as property names",
"transform-property-literals": "Object/array literal extensions / Reserved words as property names",
"transform-member-expression-literals":
"Object/array literal extensions / Reserved words as property names",
"transform-property-literals":
"Object/array literal extensions / Reserved words as property names",
"transform-reserved-words": "Miscellaneous / Unreserved words",
};

const proposals = require("./shipped-proposals").features;

module.exports = Object.assign({}, es, proposals);
@@ -0,0 +1,3 @@
src
test
*.log
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.