Use the babel-plugin-polyfill-* packages in preset-env (#12583)

This commit is contained in:
Nicolò Ribaudo 2021-02-21 17:40:29 +01:00 committed by GitHub
parent 33fbf84fa3
commit 143ee801e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
177 changed files with 3060 additions and 3618 deletions

View File

@ -15,6 +15,7 @@ lib/file.js
lib/parser.js
lib/third-party-libs.js.flow
lib/preset-modules.js.flow
lib/babel-polyfills.js.flow
packages/babel-types/lib/index.js.flow
lib/babel-packages.js.flow
lib/package-json.js.flow

View File

@ -0,0 +1,9 @@
declare module "babel-plugin-polyfill-regenerator" {
declare module.exports: Function;
}
declare module "babel-plugin-polyfill-corejs2" {
declare module.exports: Function;
}
declare module "babel-plugin-polyfill-corejs3" {
declare module.exports: Function;
}

View File

@ -278,8 +278,16 @@ function run(task) {
}
if (validateLogs) {
validateFile(normalizeOutput(actualLogs.stdout), stdout.loc, stdout.code);
validateFile(normalizeOutput(actualLogs.stderr), stderr.loc, stderr.code);
validateFile(
normalizeOutput(actualLogs.stdout, /* normalizePathSeparator */ true),
stdout.loc,
stdout.code,
);
validateFile(
normalizeOutput(actualLogs.stderr, /* normalizePathSeparator */ true),
stderr.loc,
stderr.code,
);
}
}
@ -317,7 +325,7 @@ function validateFile(actualCode, expectedLoc, expectedCode) {
}
}
function normalizeOutput(code) {
function normalizeOutput(code, normalizePathSeparator) {
const projectRoot = path.resolve(__dirname, "../../../");
const cwdSymbol = "<CWD>";
let result = code
@ -337,6 +345,11 @@ function normalizeOutput(code) {
new RegExp(escapeRegExp(projectRoot.replace(/\\/g, "\\\\")), "g"),
cwdSymbol,
);
if (normalizePathSeparator) {
result = result.replace(/<CWD>[\w\\/.-]+/g, path =>
path.replace(/\\\\?/g, "/"),
);
}
}
return result;
}

View File

@ -27,7 +27,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"babel-plugin-polyfill-corejs3": "0.0.10",
"babel-plugin-polyfill-corejs3": "^0.1.0",
"core-js-pure": "^3.8.1"
}
}

View File

@ -30,7 +30,7 @@
"devDependencies": {
"@babel/core": "workspace:*",
"@babel/helper-plugin-test-runner": "workspace:*",
"babel-plugin-polyfill-es-shims": "0.0.10",
"babel-plugin-polyfill-es-shims": "^0.1.0",
"object.getownpropertydescriptors": "^2.1.1"
}
}

View File

@ -18,7 +18,6 @@
"dependencies": {
"@babel/compat-data": "workspace:^7.12.13",
"@babel/helper-compilation-targets": "workspace:^7.12.17",
"@babel/helper-module-imports": "workspace:^7.12.13",
"@babel/helper-plugin-utils": "workspace:^7.12.13",
"@babel/helper-validator-option": "workspace:^7.12.17",
"@babel/plugin-proposal-async-generator-functions": "workspace:^7.12.13",
@ -80,6 +79,9 @@
"@babel/plugin-transform-unicode-regex": "workspace:^7.12.13",
"@babel/preset-modules": "^0.1.3",
"@babel/types": "workspace:^7.12.17",
"babel-plugin-polyfill-corejs2": "^0.1.0",
"babel-plugin-polyfill-corejs3": "^0.1.0",
"babel-plugin-polyfill-regenerator": "^0.1.0",
"core-js-compat": "^3.9.0",
"semver": "^5.5.0"
},

View File

@ -34,10 +34,6 @@ export const logEntryPolyfills = (
polyfillTargets: Targets,
allBuiltInsList: { [key: string]: Targets },
) => {
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!importPolyfillIncluded) {
console.log(`\n[${filename}] Import of ${polyfillName} was not found.`);
return;

View File

@ -13,12 +13,12 @@ import {
} from "./plugins-compat-data";
import overlappingPlugins from "@babel/compat-data/overlapping-plugins";
import addCoreJS2UsagePlugin from "./polyfills/corejs2/usage-plugin";
import addCoreJS3UsagePlugin from "./polyfills/corejs3/usage-plugin";
import addRegeneratorUsagePlugin from "./polyfills/regenerator/usage-plugin";
import replaceCoreJS2EntryPlugin from "./polyfills/corejs2/entry-plugin";
import replaceCoreJS3EntryPlugin from "./polyfills/corejs3/entry-plugin";
import removeRegeneratorEntryPlugin from "./polyfills/regenerator/entry-plugin";
import removeRegeneratorEntryPlugin from "./polyfills/regenerator";
import legacyBabelPolyfillPlugin from "./polyfills/babel-polyfill";
import pluginCoreJS2 from "babel-plugin-polyfill-corejs2";
import pluginCoreJS3 from "babel-plugin-polyfill-corejs3";
import pluginRegenerator from "babel-plugin-polyfill-regenerator";
import getTargets, {
prettifyTargets,
@ -28,7 +28,6 @@ import getTargets, {
type InputTargets,
} from "@babel/helper-compilation-targets";
import availablePlugins from "./available-plugins";
import { filterStageFromList } from "./utils";
import { declare } from "@babel/helper-plugin-utils";
import typeof ModuleTransformationsType from "./module-transformations";
@ -41,6 +40,19 @@ export function isPluginRequired(targets: Targets, support: Targets) {
});
}
function filterStageFromList(
list: { [feature: string]: Targets },
stageList: Set<string>,
) {
return Object.keys(list).reduce((result, item) => {
if (!stageList.has(item)) {
result[item] = list[item];
}
return result;
}, {});
}
const pluginLists = {
withProposals: {
withoutBugfixes: pluginsList,
@ -171,31 +183,46 @@ export const getPolyfillPlugins = ({
const polyfillPlugins = [];
if (useBuiltIns === "usage" || useBuiltIns === "entry") {
const pluginOptions = {
corejs,
polyfillTargets,
method: `${useBuiltIns}-global`,
version: corejs ? corejs.toString() : undefined,
targets: polyfillTargets,
include,
exclude,
proposals,
shippedProposals,
regenerator,
debug,
};
if (corejs) {
if (useBuiltIns === "usage") {
if (corejs.major === 2) {
polyfillPlugins.push([addCoreJS2UsagePlugin, pluginOptions]);
polyfillPlugins.push(
[pluginCoreJS2, pluginOptions],
[legacyBabelPolyfillPlugin, { usage: true }],
);
} else {
polyfillPlugins.push([addCoreJS3UsagePlugin, pluginOptions]);
polyfillPlugins.push(
[pluginCoreJS3, pluginOptions],
[legacyBabelPolyfillPlugin, { usage: true, deprecated: true }],
);
}
if (regenerator) {
polyfillPlugins.push([addRegeneratorUsagePlugin, pluginOptions]);
polyfillPlugins.push([
pluginRegenerator,
{ method: "usage-global", debug },
]);
}
} else {
if (corejs.major === 2) {
polyfillPlugins.push([replaceCoreJS2EntryPlugin, pluginOptions]);
polyfillPlugins.push(
[legacyBabelPolyfillPlugin, { regenerator }],
[pluginCoreJS2, pluginOptions],
);
} else {
polyfillPlugins.push([replaceCoreJS3EntryPlugin, pluginOptions]);
polyfillPlugins.push(
[pluginCoreJS3, pluginOptions],
[legacyBabelPolyfillPlugin, { deprecated: true }],
);
if (!regenerator) {
polyfillPlugins.push([removeRegeneratorEntryPlugin, pluginOptions]);
}
@ -393,9 +420,6 @@ option \`forceAllTransforms: true\` instead.
console.log(
"\nUsing polyfills: No polyfills were added, since the `useBuiltIns` option was not set.",
);
} else {
// NOTE: Polyfill plugins are outputting debug info internally
console.log(`\nUsing polyfills with \`${useBuiltIns}\` option:`);
}
}

View File

@ -6,7 +6,12 @@ import { plugins as pluginsList } from "./plugins-compat-data";
import moduleTransformations from "./module-transformations";
import { TopLevelOptions, ModulesOption, UseBuiltInsOption } from "./options";
import { OptionValidator } from "@babel/helper-validator-option";
import { defaultWebIncludes } from "./polyfills/corejs2/get-platform-specific-default";
const corejs2DefaultWebIncludes = [
"web.timers",
"web.immediate",
"web.dom.iterable",
];
import type {
BuiltInsOption,
@ -38,7 +43,7 @@ const getValidIncludesAndExcludes = (
...(type === "exclude" ? modulePlugins : []),
...(corejs
? corejs == 2
? [...Object.keys(corejs2Polyfills), ...defaultWebIncludes]
? [...Object.keys(corejs2Polyfills), ...corejs2DefaultWebIncludes]
: Object.keys(corejs3Polyfills)
: []),
]);

View File

@ -0,0 +1,68 @@
// @flow
import { getImportSource, getRequireSource, isPolyfillSource } from "./utils";
import type { NodePath } from "@babel/traverse";
const BABEL_POLYFILL_DEPRECATION = `
\`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
and \`regenerator-runtime/runtime\` separately`;
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the direct import of \`SPECIFIER\` or use \`useBuiltIns: 'entry'\` instead.`;
export default function (
{ template }: any,
{ regenerator, deprecated, usage }: any,
) {
return {
name: "preset-env/replace-babel-polyfill",
visitor: {
ImportDeclaration(path: NodePath) {
const src = getImportSource(path);
if (usage && isPolyfillSource(src)) {
// $FlowIgnore
console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src));
if (!deprecated) path.remove();
} else if (src === "@babel/polyfill") {
if (deprecated) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else if (regenerator) {
path.replaceWithMultiple(template.ast`
import "core-js";
import "regenerator-runtime/runtime.js";
`);
} else {
path.replaceWith(template.ast`
import "core-js";
`);
}
}
},
Program(path: NodePath) {
path.get("body").forEach(bodyPath => {
const src = getRequireSource(bodyPath);
if (usage && isPolyfillSource(src)) {
// $FlowIgnore
console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src));
if (!deprecated) bodyPath.remove();
} else if (src === "@babel/polyfill") {
if (deprecated) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else if (regenerator) {
bodyPath.replaceWithMultiple(template.ast`
require("core-js");
require("regenerator-runtime/runtime.js");
`);
} else {
bodyPath.replaceWith(template.ast`
require("core-js");
`);
}
}
});
},
},
};
}

View File

@ -1,190 +0,0 @@
// @flow
type ObjectMap<V> = { [name: string]: V };
const ArrayNatureIterators = [
"es6.object.to-string",
"es6.array.iterator",
"web.dom.iterable",
];
const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];
const PromiseDependencies = ["es6.object.to-string", "es6.promise"];
export const BuiltIns: ObjectMap<string | string[]> = {
DataView: "es6.typed.data-view",
Float32Array: "es6.typed.float32-array",
Float64Array: "es6.typed.float64-array",
Int8Array: "es6.typed.int8-array",
Int16Array: "es6.typed.int16-array",
Int32Array: "es6.typed.int32-array",
Map: ["es6.map", ...CommonIterators],
Number: "es6.number.constructor",
Promise: PromiseDependencies,
RegExp: ["es6.regexp.constructor"],
Set: ["es6.set", ...CommonIterators],
Symbol: ["es6.symbol", "es7.symbol.async-iterator"],
Uint8Array: "es6.typed.uint8-array",
Uint8ClampedArray: "es6.typed.uint8-clamped-array",
Uint16Array: "es6.typed.uint16-array",
Uint32Array: "es6.typed.uint32-array",
WeakMap: ["es6.weak-map", ...CommonIterators],
WeakSet: ["es6.weak-set", ...CommonIterators],
};
export const InstanceProperties: ObjectMap<string[]> = {
__defineGetter__: ["es7.object.define-getter"],
__defineSetter__: ["es7.object.define-setter"],
__lookupGetter__: ["es7.object.lookup-getter"],
__lookupSetter__: ["es7.object.lookup-setter"],
anchor: ["es6.string.anchor"],
big: ["es6.string.big"],
bind: ["es6.function.bind"],
blink: ["es6.string.blink"],
bold: ["es6.string.bold"],
codePointAt: ["es6.string.code-point-at"],
copyWithin: ["es6.array.copy-within"],
endsWith: ["es6.string.ends-with"],
entries: ArrayNatureIterators,
every: ["es6.array.is-array"],
fill: ["es6.array.fill"],
filter: ["es6.array.filter"],
finally: ["es7.promise.finally", ...PromiseDependencies],
find: ["es6.array.find"],
findIndex: ["es6.array.find-index"],
fixed: ["es6.string.fixed"],
flags: ["es6.regexp.flags"],
flatMap: ["es7.array.flat-map"],
fontcolor: ["es6.string.fontcolor"],
fontsize: ["es6.string.fontsize"],
forEach: ["es6.array.for-each"],
includes: ["es6.string.includes", "es7.array.includes"],
indexOf: ["es6.array.index-of"],
italics: ["es6.string.italics"],
keys: ArrayNatureIterators,
lastIndexOf: ["es6.array.last-index-of"],
link: ["es6.string.link"],
map: ["es6.array.map"],
match: ["es6.regexp.match"],
name: ["es6.function.name"],
padStart: ["es7.string.pad-start"],
padEnd: ["es7.string.pad-end"],
reduce: ["es6.array.reduce"],
reduceRight: ["es6.array.reduce-right"],
repeat: ["es6.string.repeat"],
replace: ["es6.regexp.replace"],
search: ["es6.regexp.search"],
slice: ["es6.array.slice"],
small: ["es6.string.small"],
some: ["es6.array.some"],
sort: ["es6.array.sort"],
split: ["es6.regexp.split"],
startsWith: ["es6.string.starts-with"],
strike: ["es6.string.strike"],
sub: ["es6.string.sub"],
sup: ["es6.string.sup"],
toISOString: ["es6.date.to-iso-string"],
toJSON: ["es6.date.to-json"],
toString: [
"es6.object.to-string",
"es6.date.to-string",
"es6.regexp.to-string",
],
trim: ["es6.string.trim"],
trimEnd: ["es7.string.trim-right"],
trimLeft: ["es7.string.trim-left"],
trimRight: ["es7.string.trim-right"],
trimStart: ["es7.string.trim-left"],
values: ArrayNatureIterators,
};
export const StaticProperties: ObjectMap<ObjectMap<string | string[]>> = {
Array: {
from: ["es6.array.from", "es6.string.iterator"],
isArray: "es6.array.is-array",
of: "es6.array.of",
},
Date: {
now: "es6.date.now",
},
Object: {
assign: "es6.object.assign",
create: "es6.object.create",
defineProperty: "es6.object.define-property",
defineProperties: "es6.object.define-properties",
entries: "es7.object.entries",
freeze: "es6.object.freeze",
getOwnPropertyDescriptors: "es7.object.get-own-property-descriptors",
getOwnPropertySymbols: "es6.symbol",
is: "es6.object.is",
isExtensible: "es6.object.is-extensible",
isFrozen: "es6.object.is-frozen",
isSealed: "es6.object.is-sealed",
keys: "es6.object.keys",
preventExtensions: "es6.object.prevent-extensions",
seal: "es6.object.seal",
setPrototypeOf: "es6.object.set-prototype-of",
values: "es7.object.values",
},
Math: {
acosh: "es6.math.acosh",
asinh: "es6.math.asinh",
atanh: "es6.math.atanh",
cbrt: "es6.math.cbrt",
clz32: "es6.math.clz32",
cosh: "es6.math.cosh",
expm1: "es6.math.expm1",
fround: "es6.math.fround",
hypot: "es6.math.hypot",
imul: "es6.math.imul",
log1p: "es6.math.log1p",
log10: "es6.math.log10",
log2: "es6.math.log2",
sign: "es6.math.sign",
sinh: "es6.math.sinh",
tanh: "es6.math.tanh",
trunc: "es6.math.trunc",
},
String: {
fromCodePoint: "es6.string.from-code-point",
raw: "es6.string.raw",
},
Number: {
EPSILON: "es6.number.epsilon",
MIN_SAFE_INTEGER: "es6.number.min-safe-integer",
MAX_SAFE_INTEGER: "es6.number.max-safe-integer",
isFinite: "es6.number.is-finite",
isInteger: "es6.number.is-integer",
isSafeInteger: "es6.number.is-safe-integer",
isNaN: "es6.number.is-nan",
parseFloat: "es6.number.parse-float",
parseInt: "es6.number.parse-int",
},
Promise: {
all: CommonIterators,
race: CommonIterators,
},
Reflect: {
apply: "es6.reflect.apply",
construct: "es6.reflect.construct",
defineProperty: "es6.reflect.define-property",
deleteProperty: "es6.reflect.delete-property",
get: "es6.reflect.get",
getOwnPropertyDescriptor: "es6.reflect.get-own-property-descriptor",
getPrototypeOf: "es6.reflect.get-prototype-of",
has: "es6.reflect.has",
isExtensible: "es6.reflect.is-extensible",
ownKeys: "es6.reflect.own-keys",
preventExtensions: "es6.reflect.prevent-extensions",
set: "es6.reflect.set",
setPrototypeOf: "es6.reflect.set-prototype-of",
},
};

View File

@ -1,85 +0,0 @@
// @flow
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
import { filterItems } from "@babel/helper-compilation-targets";
import getPlatformSpecificDefaultFor from "./get-platform-specific-default";
import {
createImport,
isPolyfillSource,
getImportSource,
getRequireSource,
} from "../../utils";
import { logEntryPolyfills } from "../../debug";
import type { InternalPluginOptions } from "../../types";
import type { NodePath } from "@babel/traverse";
export default function (
_: any,
{
include,
exclude,
polyfillTargets,
regenerator,
debug,
}: InternalPluginOptions,
) {
const polyfills = filterItems(
corejs2Polyfills,
include,
exclude,
polyfillTargets,
getPlatformSpecificDefaultFor(polyfillTargets),
);
const isPolyfillImport = {
ImportDeclaration(path: NodePath) {
if (isPolyfillSource(getImportSource(path))) {
this.replaceBySeparateModulesImport(path);
}
},
Program(path: NodePath) {
path.get("body").forEach(bodyPath => {
if (isPolyfillSource(getRequireSource(bodyPath))) {
this.replaceBySeparateModulesImport(bodyPath);
}
});
},
};
return {
name: "corejs2-entry",
visitor: isPolyfillImport,
pre() {
this.importPolyfillIncluded = false;
this.replaceBySeparateModulesImport = function (path) {
this.importPolyfillIncluded = true;
if (regenerator) {
createImport(path, "regenerator-runtime");
}
const modules = Array.from(polyfills).reverse();
for (const module of modules) {
createImport(path, module);
}
path.remove();
};
},
post() {
if (debug) {
logEntryPolyfills(
"@babel/polyfill",
this.importPolyfillIncluded,
polyfills,
this.file.opts.filename,
polyfillTargets,
corejs2Polyfills,
);
}
},
};
}

View File

@ -1,17 +0,0 @@
// @flow
import type { Targets } from "@babel/helper-compilation-targets";
export const defaultWebIncludes = [
"web.timers",
"web.immediate",
"web.dom.iterable",
];
export default function (targets: Targets): null | string[] {
const targetNames = Object.keys(targets);
const isAnyTarget = !targetNames.length;
const isWebTarget = targetNames.some(name => name !== "node");
return isAnyTarget || isWebTarget ? defaultWebIncludes : null;
}

View File

@ -1,222 +0,0 @@
// @flow
import corejs2Polyfills from "@babel/compat-data/corejs2-built-ins";
import { filterItems } from "@babel/helper-compilation-targets";
import getPlatformSpecificDefaultFor from "./get-platform-specific-default";
import {
BuiltIns,
StaticProperties,
InstanceProperties,
} from "./built-in-definitions";
import {
createImport,
getType,
has,
isPolyfillSource,
getImportSource,
getRequireSource,
isNamespaced,
} from "../../utils";
import { logUsagePolyfills } from "../../debug";
import type { InternalPluginOptions } from "../../types";
import type { NodePath } from "@babel/traverse";
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the \`import '@babel/polyfill'\` call or use \`useBuiltIns: 'entry'\` instead.`;
export default function (
{ types: t }: { types: Object },
{ include, exclude, polyfillTargets, debug }: InternalPluginOptions,
) {
const polyfills = filterItems(
corejs2Polyfills,
include,
exclude,
polyfillTargets,
getPlatformSpecificDefaultFor(polyfillTargets),
);
const addAndRemovePolyfillImports = {
ImportDeclaration(path: NodePath) {
if (isPolyfillSource(getImportSource(path))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
path.remove();
}
},
Program(path: NodePath) {
path.get("body").forEach(bodyPath => {
if (isPolyfillSource(getRequireSource(bodyPath))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
bodyPath.remove();
}
});
},
// Symbol()
// new Promise
ReferencedIdentifier({ node: { name }, parent, scope }: NodePath) {
if (t.isMemberExpression(parent)) return;
if (!has(BuiltIns, name)) return;
if (scope.getBindingIdentifier(name)) return;
const BuiltInDependencies = BuiltIns[name];
this.addUnsupported(BuiltInDependencies);
},
// arr[Symbol.iterator]()
CallExpression(path: NodePath) {
// we can't compile this
if (path.node.arguments.length) return;
const callee = path.node.callee;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
if (!path.get("callee.property").matchesPattern("Symbol.iterator")) {
return;
}
this.addImport("web.dom.iterable");
},
// Symbol.iterator in arr
BinaryExpression(path: NodePath) {
if (path.node.operator !== "in") return;
if (!path.get("left").matchesPattern("Symbol.iterator")) return;
this.addImport("web.dom.iterable");
},
// yield*
YieldExpression(path: NodePath) {
if (path.node.delegate) {
this.addImport("web.dom.iterable");
}
},
// Array.from
MemberExpression: {
enter(path: NodePath) {
const { node } = path;
const { object, property } = node;
// ignore namespace
if (isNamespaced(path.get("object"))) return;
let evaluatedPropType = object.name;
let propertyName = "";
let instanceType = "";
if (node.computed) {
if (t.isStringLiteral(property)) {
propertyName = property.value;
} else {
const result = path.get("property").evaluate();
if (result.confident && result.value) {
propertyName = result.value;
}
}
} else {
propertyName = property.name;
}
if (path.scope.getBindingIdentifier(object.name)) {
const result = path.get("object").evaluate();
if (result.value) {
instanceType = getType(result.value);
} else if (result.deopt && result.deopt.isIdentifier()) {
evaluatedPropType = result.deopt.node.name;
}
}
if (has(StaticProperties, evaluatedPropType)) {
const BuiltInProperties = StaticProperties[evaluatedPropType];
if (has(BuiltInProperties, propertyName)) {
const StaticPropertyDependencies = BuiltInProperties[propertyName];
this.addUnsupported(StaticPropertyDependencies);
}
}
if (has(InstanceProperties, propertyName)) {
let InstancePropertyDependencies = InstanceProperties[propertyName];
if (instanceType) {
InstancePropertyDependencies = InstancePropertyDependencies.filter(
module => module.includes(instanceType),
);
}
this.addUnsupported(InstancePropertyDependencies);
}
},
// Symbol.match
exit(path: NodePath) {
const { name } = path.node.object;
if (!has(BuiltIns, name)) return;
if (path.scope.getBindingIdentifier(name)) return;
const BuiltInDependencies = BuiltIns[name];
this.addUnsupported(BuiltInDependencies);
},
},
// var { repeat, startsWith } = String
VariableDeclarator(path: NodePath) {
const { node } = path;
const { id, init } = node;
if (!t.isObjectPattern(id)) return;
// doesn't reference the global
if (init && path.scope.getBindingIdentifier(init.name)) return;
for (const { key } of id.properties) {
if (
!node.computed &&
t.isIdentifier(key) &&
has(InstanceProperties, key.name)
) {
const InstancePropertyDependencies = InstanceProperties[key.name];
this.addUnsupported(InstancePropertyDependencies);
}
}
},
};
return {
name: "corejs2-usage",
pre({ path }: { path: NodePath }) {
this.polyfillsSet = new Set();
this.addImport = function (builtIn) {
if (!this.polyfillsSet.has(builtIn)) {
this.polyfillsSet.add(builtIn);
createImport(path, builtIn);
}
};
this.addUnsupported = function (builtIn) {
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
for (const module of modules) {
if (polyfills.has(module)) {
this.addImport(module);
}
}
};
},
post() {
if (debug) {
logUsagePolyfills(
this.polyfillsSet,
this.file.opts.filename,
polyfillTargets,
corejs2Polyfills,
);
}
},
visitor: addAndRemovePolyfillImports,
};
}

View File

@ -1,448 +0,0 @@
// @flow
type ObjectMap<V> = { [name: string]: V };
const ArrayNatureIterators = [
"es.array.iterator",
"web.dom-collections.iterator",
];
export const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
const ArrayNatureIteratorsWithTag = [
"es.object.to-string",
...ArrayNatureIterators,
];
const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
const TypedArrayDependencies = [
"es.typed-array.copy-within",
"es.typed-array.every",
"es.typed-array.fill",
"es.typed-array.filter",
"es.typed-array.find",
"es.typed-array.find-index",
"es.typed-array.for-each",
"es.typed-array.includes",
"es.typed-array.index-of",
"es.typed-array.iterator",
"es.typed-array.join",
"es.typed-array.last-index-of",
"es.typed-array.map",
"es.typed-array.reduce",
"es.typed-array.reduce-right",
"es.typed-array.reverse",
"es.typed-array.set",
"es.typed-array.slice",
"es.typed-array.some",
"es.typed-array.sort",
"es.typed-array.subarray",
"es.typed-array.to-locale-string",
"es.typed-array.to-string",
"es.object.to-string",
"es.array.iterator",
"es.array-buffer.slice",
];
const TypedArrayStaticMethods = {
from: "es.typed-array.from",
of: "es.typed-array.of",
};
export const PromiseDependencies = ["es.promise", "es.object.to-string"];
const PromiseDependenciesWithIterators = [
...PromiseDependencies,
...CommonIterators,
];
const SymbolDependencies = [
"es.symbol",
"es.symbol.description",
"es.object.to-string",
];
const MapDependencies = [
"es.map",
"esnext.map.delete-all",
"esnext.map.every",
"esnext.map.filter",
"esnext.map.find",
"esnext.map.find-key",
"esnext.map.includes",
"esnext.map.key-of",
"esnext.map.map-keys",
"esnext.map.map-values",
"esnext.map.merge",
"esnext.map.reduce",
"esnext.map.some",
"esnext.map.update",
...CommonIteratorsWithTag,
];
const SetDependencies = [
"es.set",
"esnext.set.add-all",
"esnext.set.delete-all",
"esnext.set.difference",
"esnext.set.every",
"esnext.set.filter",
"esnext.set.find",
"esnext.set.intersection",
"esnext.set.is-disjoint-from",
"esnext.set.is-subset-of",
"esnext.set.is-superset-of",
"esnext.set.join",
"esnext.set.map",
"esnext.set.reduce",
"esnext.set.some",
"esnext.set.symmetric-difference",
"esnext.set.union",
...CommonIteratorsWithTag,
];
const WeakMapDependencies = [
"es.weak-map",
"esnext.weak-map.delete-all",
...CommonIteratorsWithTag,
];
const WeakSetDependencies = [
"es.weak-set",
"esnext.weak-set.add-all",
"esnext.weak-set.delete-all",
...CommonIteratorsWithTag,
];
const URLSearchParamsDependencies = ["web.url", ...CommonIteratorsWithTag];
export const BuiltIns: ObjectMap<string[]> = {
AggregateError: ["esnext.aggregate-error", ...CommonIterators],
ArrayBuffer: [
"es.array-buffer.constructor",
"es.array-buffer.slice",
"es.object.to-string",
],
DataView: ["es.data-view", "es.array-buffer.slice", "es.object.to-string"],
Date: ["es.date.to-string"],
Float32Array: ["es.typed-array.float32-array", ...TypedArrayDependencies],
Float64Array: ["es.typed-array.float64-array", ...TypedArrayDependencies],
Int8Array: ["es.typed-array.int8-array", ...TypedArrayDependencies],
Int16Array: ["es.typed-array.int16-array", ...TypedArrayDependencies],
Int32Array: ["es.typed-array.int32-array", ...TypedArrayDependencies],
Uint8Array: ["es.typed-array.uint8-array", ...TypedArrayDependencies],
Uint8ClampedArray: [
"es.typed-array.uint8-clamped-array",
...TypedArrayDependencies,
],
Uint16Array: ["es.typed-array.uint16-array", ...TypedArrayDependencies],
Uint32Array: ["es.typed-array.uint32-array", ...TypedArrayDependencies],
Map: MapDependencies,
Number: ["es.number.constructor"],
Observable: [
"esnext.observable",
"esnext.symbol.observable",
"es.object.to-string",
...CommonIteratorsWithTag,
],
Promise: PromiseDependencies,
RegExp: ["es.regexp.constructor", "es.regexp.exec", "es.regexp.to-string"],
Set: SetDependencies,
Symbol: SymbolDependencies,
URL: ["web.url", ...URLSearchParamsDependencies],
URLSearchParams: URLSearchParamsDependencies,
WeakMap: WeakMapDependencies,
WeakSet: WeakSetDependencies,
clearImmediate: ["web.immediate"],
compositeKey: ["esnext.composite-key"],
compositeSymbol: ["esnext.composite-symbol", ...SymbolDependencies],
fetch: PromiseDependencies,
globalThis: ["es.global-this", "esnext.global-this"],
parseFloat: ["es.parse-float"],
parseInt: ["es.parse-int"],
queueMicrotask: ["web.queue-microtask"],
setTimeout: ["web.timers"],
setInterval: ["web.timers"],
setImmediate: ["web.immediate"],
};
export const InstanceProperties: ObjectMap<string[]> = {
at: ["esnext.string.at"],
anchor: ["es.string.anchor"],
big: ["es.string.big"],
bind: ["es.function.bind"],
blink: ["es.string.blink"],
bold: ["es.string.bold"],
codePointAt: ["es.string.code-point-at"],
codePoints: ["esnext.string.code-points"],
concat: ["es.array.concat"],
copyWithin: ["es.array.copy-within"],
description: ["es.symbol", "es.symbol.description"],
endsWith: ["es.string.ends-with"],
entries: ArrayNatureIteratorsWithTag,
every: ["es.array.every"],
exec: ["es.regexp.exec"],
fill: ["es.array.fill"],
filter: ["es.array.filter"],
finally: ["es.promise.finally", ...PromiseDependencies],
find: ["es.array.find"],
findIndex: ["es.array.find-index"],
fixed: ["es.string.fixed"],
flags: ["es.regexp.flags"],
flat: ["es.array.flat", "es.array.unscopables.flat"],
flatMap: ["es.array.flat-map", "es.array.unscopables.flat-map"],
fontcolor: ["es.string.fontcolor"],
fontsize: ["es.string.fontsize"],
forEach: ["es.array.for-each", "web.dom-collections.for-each"],
includes: ["es.array.includes", "es.string.includes"],
indexOf: ["es.array.index-of"],
italics: ["es.string.italics"],
join: ["es.array.join"],
keys: ArrayNatureIteratorsWithTag,
lastIndex: ["esnext.array.last-index"],
lastIndexOf: ["es.array.last-index-of"],
lastItem: ["esnext.array.last-item"],
link: ["es.string.link"],
match: ["es.string.match", "es.regexp.exec"],
matchAll: ["es.string.match-all", "esnext.string.match-all"],
map: ["es.array.map"],
name: ["es.function.name"],
padEnd: ["es.string.pad-end"],
padStart: ["es.string.pad-start"],
reduce: ["es.array.reduce"],
reduceRight: ["es.array.reduce-right"],
repeat: ["es.string.repeat"],
replace: ["es.string.replace", "es.regexp.exec"],
replaceAll: ["esnext.string.replace-all"],
reverse: ["es.array.reverse"],
search: ["es.string.search", "es.regexp.exec"],
slice: ["es.array.slice"],
small: ["es.string.small"],
some: ["es.array.some"],
sort: ["es.array.sort"],
splice: ["es.array.splice"],
split: ["es.string.split", "es.regexp.exec"],
startsWith: ["es.string.starts-with"],
strike: ["es.string.strike"],
sub: ["es.string.sub"],
sup: ["es.string.sup"],
toFixed: ["es.number.to-fixed"],
toISOString: ["es.date.to-iso-string"],
toJSON: ["es.date.to-json", "web.url.to-json"],
toPrecision: ["es.number.to-precision"],
toString: ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"],
trim: ["es.string.trim"],
trimEnd: ["es.string.trim-end"],
trimLeft: ["es.string.trim-start"],
trimRight: ["es.string.trim-end"],
trimStart: ["es.string.trim-start"],
values: ArrayNatureIteratorsWithTag,
__defineGetter__: ["es.object.define-getter"],
__defineSetter__: ["es.object.define-setter"],
__lookupGetter__: ["es.object.lookup-getter"],
__lookupSetter__: ["es.object.lookup-setter"],
};
export const StaticProperties: ObjectMap<ObjectMap<string | string[]>> = {
Array: {
from: ["es.array.from", "es.string.iterator"],
isArray: ["es.array.is-array"],
of: ["es.array.of"],
},
Date: {
now: "es.date.now",
},
Object: {
assign: "es.object.assign",
create: "es.object.create",
defineProperty: "es.object.define-property",
defineProperties: "es.object.define-properties",
entries: "es.object.entries",
freeze: "es.object.freeze",
fromEntries: ["es.object.from-entries", "es.array.iterator"],
getOwnPropertyDescriptor: "es.object.get-own-property-descriptor",
getOwnPropertyDescriptors: "es.object.get-own-property-descriptors",
getOwnPropertyNames: "es.object.get-own-property-names",
getOwnPropertySymbols: "es.symbol",
getPrototypeOf: "es.object.get-prototype-of",
is: "es.object.is",
isExtensible: "es.object.is-extensible",
isFrozen: "es.object.is-frozen",
isSealed: "es.object.is-sealed",
keys: "es.object.keys",
preventExtensions: "es.object.prevent-extensions",
seal: "es.object.seal",
setPrototypeOf: "es.object.set-prototype-of",
values: "es.object.values",
},
Math: {
DEG_PER_RAD: "esnext.math.deg-per-rad",
RAD_PER_DEG: "esnext.math.rad-per-deg",
acosh: "es.math.acosh",
asinh: "es.math.asinh",
atanh: "es.math.atanh",
cbrt: "es.math.cbrt",
clamp: "esnext.math.clamp",
clz32: "es.math.clz32",
cosh: "es.math.cosh",
degrees: "esnext.math.degrees",
expm1: "es.math.expm1",
fround: "es.math.fround",
fscale: "esnext.math.fscale",
hypot: "es.math.hypot",
iaddh: "esnext.math.iaddh",
imul: "es.math.imul",
imulh: "esnext.math.imulh",
isubh: "esnext.math.isubh",
log1p: "es.math.log1p",
log10: "es.math.log10",
log2: "es.math.log2",
radians: "esnext.math.radians",
scale: "esnext.math.scale",
seededPRNG: "esnext.math.seeded-prng",
sign: "es.math.sign",
signbit: "esnext.math.signbit",
sinh: "es.math.sinh",
tanh: "es.math.tanh",
trunc: "es.math.trunc",
umulh: "esnext.math.umulh",
},
String: {
fromCodePoint: "es.string.from-code-point",
raw: "es.string.raw",
},
Number: {
EPSILON: "es.number.epsilon",
MIN_SAFE_INTEGER: "es.number.min-safe-integer",
MAX_SAFE_INTEGER: "es.number.max-safe-integer",
fromString: "esnext.number.from-string",
isFinite: "es.number.is-finite",
isInteger: "es.number.is-integer",
isSafeInteger: "es.number.is-safe-integer",
isNaN: "es.number.is-nan",
parseFloat: "es.number.parse-float",
parseInt: "es.number.parse-int",
},
Map: {
from: ["esnext.map.from", ...MapDependencies],
groupBy: ["esnext.map.group-by", ...MapDependencies],
keyBy: ["esnext.map.key-by", ...MapDependencies],
of: ["esnext.map.of", ...MapDependencies],
},
Set: {
from: ["esnext.set.from", ...SetDependencies],
of: ["esnext.set.of", ...SetDependencies],
},
WeakMap: {
from: ["esnext.weak-map.from", ...WeakMapDependencies],
of: ["esnext.weak-map.of", ...WeakMapDependencies],
},
WeakSet: {
from: ["esnext.weak-set.from", ...WeakSetDependencies],
of: ["esnext.weak-set.of", ...WeakSetDependencies],
},
Promise: {
all: PromiseDependenciesWithIterators,
allSettled: [
"es.promise.all-settled",
"esnext.promise.all-settled",
...PromiseDependenciesWithIterators,
],
any: [
"esnext.promise.any",
"esnext.aggregate-error",
...PromiseDependenciesWithIterators,
],
race: PromiseDependenciesWithIterators,
try: ["esnext.promise.try", ...PromiseDependenciesWithIterators],
},
Reflect: {
apply: "es.reflect.apply",
construct: "es.reflect.construct",
defineMetadata: "esnext.reflect.define-metadata",
defineProperty: "es.reflect.define-property",
deleteMetadata: "esnext.reflect.delete-metadata",
deleteProperty: "es.reflect.delete-property",
get: "es.reflect.get",
getMetadata: "esnext.reflect.get-metadata",
getMetadataKeys: "esnext.reflect.get-metadata-keys",
getOwnMetadata: "esnext.reflect.get-own-metadata",
getOwnMetadataKeys: "esnext.reflect.get-own-metadata-keys",
getOwnPropertyDescriptor: "es.reflect.get-own-property-descriptor",
getPrototypeOf: "es.reflect.get-prototype-of",
has: "es.reflect.has",
hasMetadata: "esnext.reflect.has-metadata",
hasOwnMetadata: "esnext.reflect.has-own-metadata",
isExtensible: "es.reflect.is-extensible",
metadata: "esnext.reflect.metadata",
ownKeys: "es.reflect.own-keys",
preventExtensions: "es.reflect.prevent-extensions",
set: "es.reflect.set",
setPrototypeOf: "es.reflect.set-prototype-of",
},
Symbol: {
asyncIterator: ["es.symbol.async-iterator"],
dispose: ["esnext.symbol.dispose"],
hasInstance: ["es.symbol.has-instance", "es.function.has-instance"],
isConcatSpreadable: ["es.symbol.is-concat-spreadable", "es.array.concat"],
iterator: ["es.symbol.iterator", ...CommonIteratorsWithTag],
match: ["es.symbol.match", "es.string.match"],
observable: ["esnext.symbol.observable"],
patternMatch: ["esnext.symbol.pattern-match"],
replace: ["es.symbol.replace", "es.string.replace"],
search: ["es.symbol.search", "es.string.search"],
species: ["es.symbol.species", "es.array.species"],
split: ["es.symbol.split", "es.string.split"],
toPrimitive: ["es.symbol.to-primitive", "es.date.to-primitive"],
toStringTag: [
"es.symbol.to-string-tag",
"es.object.to-string",
"es.math.to-string-tag",
"es.json.to-string-tag",
],
unscopables: ["es.symbol.unscopables"],
},
ArrayBuffer: {
isView: ["es.array-buffer.is-view"],
},
Int8Array: TypedArrayStaticMethods,
Uint8Array: TypedArrayStaticMethods,
Uint8ClampedArray: TypedArrayStaticMethods,
Int16Array: TypedArrayStaticMethods,
Uint16Array: TypedArrayStaticMethods,
Int32Array: TypedArrayStaticMethods,
Uint32Array: TypedArrayStaticMethods,
Float32Array: TypedArrayStaticMethods,
Float64Array: TypedArrayStaticMethods,
};
export const CommonInstanceDependencies = new Set<string>([
"es.object.to-string",
"es.object.define-getter",
"es.object.define-setter",
"es.object.lookup-getter",
"es.object.lookup-setter",
"es.regexp.exec",
]);
export const PossibleGlobalObjects = new Set<string>([
"global",
"globalThis",
"self",
"window",
]);

View File

@ -1,139 +0,0 @@
// @flow
import corejs3Polyfills from "core-js-compat/data.json";
import corejsEntries from "core-js-compat/entries.json";
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
import { filterItems } from "@babel/helper-compilation-targets";
import {
has,
intersection,
createImport,
getImportSource,
getRequireSource,
getModulePath,
} from "../../utils";
import { logEntryPolyfills } from "../../debug";
import type { InternalPluginOptions } from "../../types";
import type { NodePath } from "@babel/traverse";
function isBabelPolyfillSource(source) {
return source === "@babel/polyfill" || source === "babel-polyfill";
}
function isCoreJSSource(source) {
if (typeof source === "string") {
source = source
.replace(/\\/g, "/")
.replace(/(\/(index)?)?(\.js)?$/i, "")
.toLowerCase();
}
return has(corejsEntries, source) && corejsEntries[source];
}
const BABEL_POLYFILL_DEPRECATION = `
\`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
and \`regenerator-runtime/runtime\` separately`;
export default function (
_: any,
{ corejs, include, exclude, polyfillTargets, debug }: InternalPluginOptions,
) {
const polyfills = filterItems(
corejs3Polyfills,
include,
exclude,
polyfillTargets,
null,
);
const available = new Set(getModulesListForTargetVersion(corejs.version));
function shouldReplace(source, modules) {
if (!modules) return false;
if (
// Don't replace an import with itself to avoid an infinite loop
modules.length === 1 &&
polyfills.has(modules[0]) &&
available.has(modules[0]) &&
getModulePath(modules[0]) === source
) {
return false;
}
return true;
}
const isPolyfillImport = {
ImportDeclaration(path: NodePath) {
const source = getImportSource(path);
if (!source) return;
if (isBabelPolyfillSource(source)) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else {
const modules = isCoreJSSource(source);
if (shouldReplace(source, modules)) {
this.replaceBySeparateModulesImport(path, modules);
}
}
},
Program: {
enter(path: NodePath) {
path.get("body").forEach(bodyPath => {
const source = getRequireSource(bodyPath);
if (!source) return;
if (isBabelPolyfillSource(source)) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else {
const modules = isCoreJSSource(source);
if (shouldReplace(source, modules)) {
this.replaceBySeparateModulesImport(bodyPath, modules);
}
}
});
},
exit(path: NodePath) {
const filtered = intersection(polyfills, this.polyfillsSet, available);
const reversed = Array.from(filtered).reverse();
for (const module of reversed) {
// Program:exit could be called multiple times.
// Avoid injecting the polyfills twice.
if (!this.injectedPolyfills.has(module)) {
createImport(path, module);
}
}
filtered.forEach(module => this.injectedPolyfills.add(module));
},
},
};
return {
name: "corejs3-entry",
visitor: isPolyfillImport,
pre() {
this.injectedPolyfills = new Set();
this.polyfillsSet = new Set();
this.replaceBySeparateModulesImport = function (path, modules) {
for (const module of modules) {
this.polyfillsSet.add(module);
}
path.remove();
};
},
post() {
if (debug) {
logEntryPolyfills(
"core-js",
this.injectedPolyfills.size > 0,
this.injectedPolyfills,
this.file.opts.filename,
polyfillTargets,
corejs3Polyfills,
);
}
},
};
}

View File

@ -1,285 +0,0 @@
// @flow
import corejs3Polyfills from "core-js-compat/data.json";
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 {
BuiltIns,
StaticProperties,
InstanceProperties,
CommonIterators,
CommonInstanceDependencies,
PromiseDependencies,
PossibleGlobalObjects,
} from "./built-in-definitions";
import {
createImport,
getType,
has,
intersection,
isPolyfillSource,
getImportSource,
getRequireSource,
isNamespaced,
} from "../../utils";
import { logUsagePolyfills } from "../../debug";
import type { InternalPluginOptions } from "../../types";
import type { NodePath } from "@babel/traverse";
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the direct import of \`core-js\` or use \`useBuiltIns: 'entry'\` instead.`;
const corejs3PolyfillsWithoutProposals = Object.keys(corejs3Polyfills)
.filter(name => !name.startsWith("esnext."))
.reduce((memo, key) => {
memo[key] = corejs3Polyfills[key];
return memo;
}, {});
const corejs3PolyfillsWithShippedProposals = (corejs3ShippedProposalsList: string[]).reduce(
(memo, key) => {
memo[key] = corejs3Polyfills[key];
return memo;
},
{ ...corejs3PolyfillsWithoutProposals },
);
export default function (
_: any,
{
corejs,
include,
exclude,
polyfillTargets,
proposals,
shippedProposals,
debug,
}: InternalPluginOptions,
) {
const polyfills = filterItems(
proposals
? corejs3Polyfills
: shippedProposals
? corejs3PolyfillsWithShippedProposals
: corejs3PolyfillsWithoutProposals,
include,
exclude,
polyfillTargets,
null,
);
const available = new Set(getModulesListForTargetVersion(corejs.version));
function resolveKey(path, computed) {
const { node, parent, scope } = path;
if (path.isStringLiteral()) return node.value;
const { name } = node;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || parent.computed)) return name;
if (!isIdentifier || scope.getBindingIdentifier(name)) {
const { value } = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(path) {
const { node, scope } = path;
let builtIn, instanceType;
if (node) {
builtIn = node.name;
if (!path.isIdentifier() || scope.getBindingIdentifier(builtIn)) {
const { deopt, value } = path.evaluate();
if (value !== undefined) {
instanceType = getType(value);
} else if (deopt?.isIdentifier()) {
builtIn = deopt.node.name;
}
}
}
return { builtIn, instanceType, isNamespaced: isNamespaced(path) };
}
const addAndRemovePolyfillImports = {
// import 'core-js'
ImportDeclaration(path: NodePath) {
if (isPolyfillSource(getImportSource(path))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
path.remove();
}
},
// require('core-js')
Program: {
enter(path: NodePath) {
path.get("body").forEach(bodyPath => {
if (isPolyfillSource(getRequireSource(bodyPath))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
bodyPath.remove();
}
});
},
exit(path: NodePath) {
const filtered = intersection(polyfills, this.polyfillsSet, available);
const reversed = Array.from(filtered).reverse();
for (const module of reversed) {
// Program:exit could be called multiple times.
// Avoid injecting the polyfills twice.
if (!this.injectedPolyfills.has(module)) {
createImport(path, module);
}
}
filtered.forEach(module => this.injectedPolyfills.add(module));
},
},
// import('something').then(...)
Import() {
this.addUnsupported(PromiseDependencies);
},
Function({ node }: NodePath) {
// (async function () { }).finally(...)
if (node.async) {
this.addUnsupported(PromiseDependencies);
}
},
// for-of, [a, b] = c
"ForOfStatement|ArrayPattern"() {
this.addUnsupported(CommonIterators);
},
// [...spread]
SpreadElement({ parentPath }: NodePath) {
if (!parentPath.isObjectExpression()) {
this.addUnsupported(CommonIterators);
}
},
// yield*
YieldExpression({ node }: NodePath) {
if (node.delegate) {
this.addUnsupported(CommonIterators);
}
},
// Symbol(), new Promise
ReferencedIdentifier({ node: { name }, scope }: NodePath) {
if (scope.getBindingIdentifier(name)) return;
this.addBuiltInDependencies(name);
},
MemberExpression(path: NodePath) {
const source = resolveSource(path.get("object"));
const key = resolveKey(path.get("property"));
// Object.entries
// [1, 2, 3].entries
this.addPropertyDependencies(source, key);
},
ObjectPattern(path: NodePath) {
const { parentPath, parent, key } = path;
let source;
// const { keys, values } = Object
if (parentPath.isVariableDeclarator()) {
source = resolveSource(parentPath.get("init"));
// ({ keys, values } = Object)
} else if (parentPath.isAssignmentExpression()) {
source = resolveSource(parentPath.get("right"));
// !function ({ keys, values }) {...} (Object)
// resolution does not work after properties transform :-(
} else if (parentPath.isFunctionExpression()) {
const grand = parentPath.parentPath;
if (grand.isCallExpression() || grand.isNewExpression()) {
if (grand.node.callee === parent) {
source = resolveSource(grand.get("arguments")[key]);
}
}
}
for (const property of path.get("properties")) {
if (property.isObjectProperty()) {
const key = resolveKey(property.get("key"));
// const { keys, values } = Object
// const { keys, values } = [1, 2, 3]
this.addPropertyDependencies(source, key);
}
}
},
BinaryExpression(path: NodePath) {
if (path.node.operator !== "in") return;
const source = resolveSource(path.get("right"));
const key = resolveKey(path.get("left"), true);
// 'entries' in Object
// 'entries' in [1, 2, 3]
this.addPropertyDependencies(source, key);
},
};
return {
name: "corejs3-usage",
pre() {
this.injectedPolyfills = new Set();
this.polyfillsSet = new Set();
this.addUnsupported = function (builtIn) {
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
for (const module of modules) {
this.polyfillsSet.add(module);
}
};
this.addBuiltInDependencies = function (builtIn) {
if (has(BuiltIns, builtIn)) {
const BuiltInDependencies = BuiltIns[builtIn];
this.addUnsupported(BuiltInDependencies);
}
};
this.addPropertyDependencies = function (source = {}, key) {
const { builtIn, instanceType, isNamespaced } = source;
if (isNamespaced) return;
if (PossibleGlobalObjects.has(builtIn)) {
this.addBuiltInDependencies(key);
} else if (has(StaticProperties, builtIn)) {
const BuiltInProperties = StaticProperties[builtIn];
if (has(BuiltInProperties, key)) {
const StaticPropertyDependencies = BuiltInProperties[key];
return this.addUnsupported(StaticPropertyDependencies);
}
}
if (!has(InstanceProperties, key)) return;
let InstancePropertyDependencies = InstanceProperties[key];
if (instanceType) {
InstancePropertyDependencies = InstancePropertyDependencies.filter(
m => m.includes(instanceType) || CommonInstanceDependencies.has(m),
);
}
this.addUnsupported(InstancePropertyDependencies);
};
},
post() {
if (debug) {
logUsagePolyfills(
this.injectedPolyfills,
this.file.opts.filename,
polyfillTargets,
corejs3Polyfills,
);
}
},
visitor: addAndRemovePolyfillImports,
};
}

View File

@ -1,10 +1,13 @@
// @flow
import { getImportSource, getRequireSource } from "../../utils";
import { getImportSource, getRequireSource } from "./utils";
import type { NodePath } from "@babel/traverse";
function isRegeneratorSource(source) {
return source === "regenerator-runtime/runtime";
return (
source === "regenerator-runtime/runtime" ||
source === "regenerator-runtime/runtime.js"
);
}
export default function () {
@ -26,7 +29,7 @@ export default function () {
};
return {
name: "regenerator-entry",
name: "preset-env/remove-regenerator",
visitor,
pre() {
this.regeneratorImportExcluded = false;

View File

@ -1,35 +0,0 @@
// @flow
import { createImport } from "../../utils";
import type { NodePath } from "@babel/traverse";
export default function () {
return {
name: "regenerator-usage",
pre() {
this.usesRegenerator = false;
},
visitor: {
Function(path: NodePath) {
const { node } = path;
if (!this.usesRegenerator && (node.generator || node.async)) {
this.usesRegenerator = true;
createImport(path, "regenerator-runtime");
}
},
},
post() {
if (this.opts.debug && this.usesRegenerator) {
let filename = this.file.opts.filename;
// normalize filename to generate consistent preset-env test fixtures
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log(
`\n[${filename}] Based on your code and targets, added regenerator-runtime.`,
);
}
},
};
}

View File

@ -0,0 +1,24 @@
// @flow
import * as t from "@babel/types";
import type { NodePath } from "@babel/traverse";
export function getImportSource({ node }: NodePath) {
if (node.specifiers.length === 0) return node.source.value;
}
export function getRequireSource({ node }: NodePath) {
if (!t.isExpressionStatement(node)) return;
const { expression } = node;
const isRequire =
t.isCallExpression(expression) &&
t.isIdentifier(expression.callee) &&
expression.callee.name === "require" &&
expression.arguments.length === 1 &&
t.isStringLiteral(expression.arguments[0]);
if (isRequire) return expression.arguments[0].value;
}
export function isPolyfillSource(source: ?string): boolean {
return source === "@babel/polyfill" || source === "core-js";
}

View File

@ -1,76 +0,0 @@
// @flow
import * as t from "@babel/types";
import type { NodePath } from "@babel/traverse";
import { addSideEffect } from "@babel/helper-module-imports";
import type { Targets } from "@babel/helper-compilation-targets";
export const has = Object.hasOwnProperty.call.bind(Object.hasOwnProperty);
export function getType(target: any): string {
return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
}
export function intersection<T>(
first: Set<T>,
second: Set<T>,
third: Set<T>,
): Set<T> {
const result = new Set();
for (const el of first) {
if (second.has(el) && third.has(el)) result.add(el);
}
return result;
}
export function filterStageFromList(
list: { [feature: string]: Targets },
stageList: Set<string>,
) {
return Object.keys(list).reduce((result, item) => {
if (!stageList.has(item)) {
result[item] = list[item];
}
return result;
}, {});
}
export function getImportSource({ node }: NodePath) {
if (node.specifiers.length === 0) return node.source.value;
}
export function getRequireSource({ node }: NodePath) {
if (!t.isExpressionStatement(node)) return;
const { expression } = node;
const isRequire =
t.isCallExpression(expression) &&
t.isIdentifier(expression.callee) &&
expression.callee.name === "require" &&
expression.arguments.length === 1 &&
t.isStringLiteral(expression.arguments[0]);
if (isRequire) return expression.arguments[0].value;
}
export function isPolyfillSource(source: ?string): boolean {
return source === "@babel/polyfill" || source === "core-js";
}
const modulePathMap = {
"regenerator-runtime": "regenerator-runtime/runtime.js",
};
export function getModulePath(mod: string): string {
return modulePathMap[mod] || `core-js/modules/${mod}.js`;
}
export function createImport(path: NodePath, mod: string) {
return addSideEffect(path, getModulePath(mod));
}
export function isNamespaced(path: NodePath) {
if (!path.node) return false;
const binding = path.scope.getBinding(path.node.name);
if (!binding) return false;
return binding.path.isImportNamespaceSpecifier();
}

View File

@ -1,13 +1,12 @@
import "core-js/modules/es7.symbol.async-iterator.js";
import "core-js/modules/es6.symbol.js";
import "core-js/modules/es6.regexp.match.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.map.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.array.from.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.map.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.regexp.match.js";
Array.from; // static method
Map; // built-in

View File

@ -1,3 +1,3 @@
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
var a = new Map();

View File

@ -35,9 +35,23 @@ Using plugins:
transform-block-scoping { "ios":"10.3", "safari":"10.1" }
proposal-export-namespace-from { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
syntax-dynamic-import { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
corejs2: `DEBUG` option
Using polyfills with `usage` option:
Using targets: {
"android": "61",
"chrome": "61",
"edge": "16",
"firefox": "60",
"ios": "10.3",
"node": "13.2",
"opera": "48",
"safari": "10.1",
"samsung": "8.2"
}
[<CWD>/packages/babel-preset-env/test/fixtures/corejs2/usage-browserslist-config-ignore/input.mjs] Added following core-js polyfills:
es6.array.iterator { "android":"61", "chrome":"61", "opera":"48", "samsung":"8.2" }
Using polyfills with `usage-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/corejs2/usage-browserslist-config-ignore/input.mjs]
The corejs2 polyfill added the following polyfills:
es6.array.iterator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
web.dom.iterable { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }

View File

@ -1 +1,5 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
[a, b] = c;

View File

@ -1,3 +1,8 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
try {
a();
} catch ([b, c]) {}

View File

@ -1,3 +1,8 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
for (var [a, b] in c) {
;
}

View File

@ -1,3 +1,8 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
function a(_ref) {
var [b, c] = _ref;
}

View File

@ -1 +1,5 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
var [a, b] = c;

View File

@ -1,7 +1,7 @@
import "core-js/modules/es6.object.assign.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.object.assign.js";
var objectClass = Object;
var arrayInstance = [];
var assignStr = "assign";

View File

@ -1,5 +1,5 @@
import "core-js/modules/es6.array.find.js";
import "core-js/modules/es7.array.includes.js";
import "core-js/modules/es6.array.find.js";
var arrayInstance = [];
var inclidesStr = "includes";
var findStr = "find"; // Allow instance methods be assigned to variables.

View File

@ -1,8 +1,5 @@
import "core-js/modules/es6.array.map.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es7.object.values.js";
import "core-js/modules/es6.array.map.js";
Object['values'](); // include
[]['map'](); // include

View File

@ -1,5 +1,7 @@
import "core-js/modules/es7.string.pad-end.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es7.string.pad-start.js";
import "core-js/modules/es7.string.pad-end.js";
for (const {
padStart

View File

@ -1,3 +1,8 @@
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
for (var a of b) {
;
}

View File

@ -1,24 +1,24 @@
import "core-js/modules/es6.regexp.split.js";
import "core-js/modules/es6.regexp.replace.js";
import "core-js/modules/es6.regexp.search.js";
import "core-js/modules/es6.array.copy-within.js";
import "core-js/modules/es6.string.ends-with.js";
import "core-js/modules/es6.string.code-point-at.js";
import "core-js/modules/es6.string.starts-with.js";
import "core-js/modules/es7.string.pad-end.js";
import "core-js/modules/es7.string.pad-start.js";
import "core-js/modules/es6.array.fill.js";
import "core-js/modules/es6.function.bind.js";
import "core-js/modules/es6.array.find-index.js";
import "core-js/modules/es6.array.find.js";
import "core-js/modules/es7.array.includes.js";
import "core-js/modules/es6.string.includes.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.map.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.symbol.js";
import "core-js/modules/es6.array.from.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.map.js";
import "core-js/modules/es6.string.includes.js";
import "core-js/modules/es7.array.includes.js";
import "core-js/modules/es6.array.find.js";
import "core-js/modules/es6.function.bind.js";
import "core-js/modules/es6.array.fill.js";
import "core-js/modules/es7.string.pad-start.js";
import "core-js/modules/es7.string.pad-end.js";
import "core-js/modules/es6.string.starts-with.js";
import "core-js/modules/es6.string.code-point-at.js";
import "core-js/modules/es6.string.ends-with.js";
import "core-js/modules/es6.array.copy-within.js";
import "core-js/modules/es6.regexp.search.js";
import "core-js/modules/es6.regexp.replace.js";
import "core-js/modules/es6.regexp.split.js";
Array.from; // static function
Map; // top level built-in

View File

@ -1,7 +1,7 @@
"use strict";
require("core-js/modules/es6.promise.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es6.promise.js");
Promise;

View File

@ -1,5 +1,5 @@
import "core-js/modules/es6.number.parse-int.js";
import "core-js/modules/es6.number.constructor.js";
import "core-js/modules/es6.number.parse-float.js";
import "core-js/modules/es6.number.constructor.js";
import "core-js/modules/es6.number.parse-int.js";
Number.parseFloat("3.14");
Number.parseInt("10");

View File

@ -1,8 +1,8 @@
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
var p = Promise.resolve(0);
Promise.all([p]).then(function (outcome) {
alert("OK");

View File

@ -1,6 +1,6 @@
import "core-js/modules/es7.promise.finally.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es7.promise.finally.js";
var p = Promise.resolve(0);
p.finally(function () {
alert("OK");

View File

@ -1,8 +1,8 @@
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
var p = Promise.resolve(0);
Promise.race([p]).then(function (outcome) {
alert("OK");

View File

@ -1,6 +1,6 @@
import "regenerator-runtime/runtime.js";
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.promise.js";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

View File

@ -2,3 +2,4 @@ import "@babel/polyfill";
import "@babel/polyfill";
require("@babel/polyfill");
require("@babel/polyfill");
;

View File

@ -1,11 +1,11 @@
When setting `useBuiltIns: 'usage'`, polyfills are automatically imported when needed.
Please remove the `import '@babel/polyfill'` call or use `useBuiltIns: 'entry'` instead.
Please remove the direct import of `@babel/polyfill` or use `useBuiltIns: 'entry'` instead.
When setting `useBuiltIns: 'usage'`, polyfills are automatically imported when needed.
Please remove the `import '@babel/polyfill'` call or use `useBuiltIns: 'entry'` instead.
Please remove the direct import of `@babel/polyfill` or use `useBuiltIns: 'entry'` instead.
When setting `useBuiltIns: 'usage'`, polyfills are automatically imported when needed.
Please remove the `import '@babel/polyfill'` call or use `useBuiltIns: 'entry'` instead.
Please remove the direct import of `@babel/polyfill` or use `useBuiltIns: 'entry'` instead.
When setting `useBuiltIns: 'usage'`, polyfills are automatically imported when needed.
Please remove the `import '@babel/polyfill'` call or use `useBuiltIns: 'entry'` instead.
Please remove the direct import of `@babel/polyfill` or use `useBuiltIns: 'entry'` instead.

View File

@ -1,32 +1,30 @@
"use strict";
require("core-js/modules/es6.object.define-properties.js");
require("core-js/modules/es7.object.get-own-property-descriptors.js");
require("core-js/modules/es6.array.for-each.js");
require("core-js/modules/es6.array.filter.js");
require("core-js/modules/es6.object.define-property.js");
require("core-js/modules/es6.array.index-of.js");
require("core-js/modules/web.dom.iterable.js");
require("core-js/modules/es6.array.iterator.js");
require("core-js/modules/es6.object.keys.js");
require("core-js/modules/es6.array.index-of.js");
require("core-js/modules/es6.object.define-property.js");
require("core-js/modules/es6.array.filter.js");
require("core-js/modules/es6.object.get-own-property-descriptor.js");
require("core-js/modules/es6.array.for-each.js");
require("core-js/modules/es7.object.get-own-property-descriptors.js");
require("core-js/modules/es6.object.define-properties.js");
require("regenerator-runtime/runtime.js");
require("core-js/modules/es7.symbol.async-iterator.js");
require("core-js/modules/es6.symbol.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es6.promise.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es6.symbol.js");
require("core-js/modules/es7.symbol.async-iterator.js");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

View File

@ -1,8 +1,8 @@
require("core-js/modules/es7.array.includes.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es6.promise.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es7.array.includes.js");
require("foo");

View File

@ -1,8 +1,8 @@
require("core-js/modules/es7.array.includes.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es6.promise.js");
require("core-js/modules/es6.object.to-string.js");
require("core-js/modules/es7.array.includes.js");
require("foo");

View File

@ -1,4 +1,6 @@
import "core-js/modules/es7.symbol.async-iterator.js";
import "core-js/modules/es6.symbol.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.symbol.js";
Symbol.iterator in arr;

View File

@ -1,4 +1,6 @@
import "core-js/modules/es7.symbol.async-iterator.js";
import "core-js/modules/es6.symbol.js";
import "core-js/modules/es6.string.iterator.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.array.iterator.js";
import "core-js/modules/web.dom.iterable.js";
import "core-js/modules/es6.symbol.js";
arr[Symbol.iterator]();

View File

@ -1,5 +1,5 @@
import "core-js/modules/es6.promise.js";
import "core-js/modules/es6.object.to-string.js";
import "core-js/modules/es6.promise.js";
Promise.resolve().then(function (it) {
setTimeout(foo, 1, 2);
setInterval(foo, 1, 2);

View File

@ -1,4 +1,3 @@
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/esnext.set.add-all.js";
import "core-js/modules/esnext.set.delete-all.js";
import "core-js/modules/esnext.set.difference.js";
@ -17,4 +16,5 @@ import "core-js/modules/esnext.set.reduce.js";
import "core-js/modules/esnext.set.some.js";
import "core-js/modules/esnext.set.symmetric-difference.js";
import "core-js/modules/esnext.set.union.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/esnext.string.replace-all.js";

View File

@ -1,6 +1,3 @@
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.set.js";
import "core-js/modules/es.string.iterator.js";
@ -22,5 +19,8 @@ import "core-js/modules/esnext.set.reduce.js";
import "core-js/modules/esnext.set.some.js";
import "core-js/modules/esnext.set.symmetric-difference.js";
import "core-js/modules/esnext.set.union.js";
import "core-js/modules/esnext.string.replace-all.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/esnext.string.replace-all.js";

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.set.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.from-entries.js";

View File

@ -1,11 +1,11 @@
import "core-js/modules/es.symbol.async-iterator.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.promise.finally.js";
import "core-js/modules/es.set.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.set.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.promise.finally.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.symbol.async-iterator.js";
import 'foo/index.js';

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
async function a() {
await 1;

View File

@ -1,16 +1,6 @@
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.symbol.match.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.match.js";
import "core-js/modules/esnext.global-this.js";
import "core-js/modules/es.map.js";
import "core-js/modules/esnext.map.delete-all.js";
import "core-js/modules/esnext.map.every.js";
import "core-js/modules/esnext.map.filter.js";
@ -24,10 +14,20 @@ import "core-js/modules/esnext.map.merge.js";
import "core-js/modules/esnext.map.reduce.js";
import "core-js/modules/esnext.map.some.js";
import "core-js/modules/esnext.map.update.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.symbol.match.js";
import "core-js/modules/es.string.match.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/web.queue-microtask.js";
import "core-js/modules/esnext.global-this.js";
import "core-js/modules/esnext.observable.js";
import "core-js/modules/esnext.symbol.observable.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/web.queue-microtask.js";
Array.from; // static method
Map; // built-in

View File

@ -1,20 +1,20 @@
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.symbol.match.js";
import "core-js/modules/es.string.match.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.symbol.match.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.global-this.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.promise.all-settled.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.match.js";
import "core-js/modules/es.string.match-all.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/web.queue-microtask.js";
import "core-js/modules/es.global-this.js";
import "core-js/modules/es.promise.all-settled.js";
import "core-js/modules/es.string.match-all.js";
Array.from; // static method
Map; // built-in

View File

@ -35,9 +35,23 @@ Using plugins:
transform-block-scoping { "ios":"10.3", "safari":"10.1" }
proposal-export-namespace-from { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
syntax-dynamic-import { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
corejs3: `DEBUG` option
Using polyfills with `usage` option:
Using targets: {
"android": "61",
"chrome": "61",
"edge": "16",
"firefox": "60",
"ios": "10.3",
"node": "13.2",
"opera": "48",
"safari": "10.1",
"samsung": "8.2"
}
[<CWD>/packages/babel-preset-env/test/fixtures/corejs3/usage-browserslist-config-ignore/input.mjs] Added following core-js polyfills:
es.array.iterator { "android":"61", "chrome":"61", "opera":"48", "samsung":"8.2" }
web.dom-collections.iterator { "android":"61", "chrome":"61", "edge":"16", "ios":"10.3", "opera":"48", "safari":"10.1", "samsung":"8.2" }
Using polyfills with `usage-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/corejs3/usage-browserslist-config-ignore/input.mjs]
The corejs3 polyfill added the following polyfills:
es.array.iterator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }
web.dom-collections.iterator { "android":"61", "chrome":"61", "edge":"16", "firefox":"60", "ios":"10.3", "node":"13.2", "opera":"48", "safari":"10.1", "samsung":"8.2" }

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.set.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
var Set = window.Set;
var Map = something.Map;

View File

@ -1,4 +1,4 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
[a, b] = c;

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
try {

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
for (var [a, b] in c) {

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.object.entries.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.includes.js";
!function (foo, {
entries: entries
}) {}({}, Object);

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
function a(_ref) {

View File

@ -1,4 +1,4 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
var [a, b] = c;

View File

@ -1,11 +1,11 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.function.bind.js";
import "core-js/modules/es.object.define-getter.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.regexp.flags.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.replace.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.regexp.flags.js";
import "core-js/modules/es.object.define-getter.js";
import "core-js/modules/es.function.bind.js";
var a = [];
a.values();
''.replace();

View File

@ -1,3 +1,3 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
var foo = import('foo');

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.assign.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.object.assign.js";
var objectClass = Object;
var arrayInstance = [];
var assignStr = "assign";

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.array.find.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.array.find.js";
var arrayInstance = [];
var inclidesStr = "includes";
var findStr = "find"; // Allow instance methods be assigned to variables.

View File

@ -1,3 +1,3 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
var foo = fetch('foo');

View File

@ -1,6 +1,6 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.pad-end.js";
import "core-js/modules/es.string.pad-start.js";
import "core-js/modules/es.string.pad-end.js";
for (const {
padStart

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
for (var a of b) {

View File

@ -1,8 +1,8 @@
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.entries.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.object.values.js";
import "core-js/modules/es.object.from-entries.js";
import "core-js/modules/es.array.iterator.js";
'entries' in Object;
'includes' in [1, 2, 3];
'va' + 'lues' in Object;

View File

@ -1,25 +1,24 @@
import "core-js/modules/es.array.copy-within.js";
import "core-js/modules/es.array.fill.js";
import "core-js/modules/es.array.find.js";
import "core-js/modules/es.array.find-index.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.function.bind.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.array.find.js";
import "core-js/modules/es.function.bind.js";
import "core-js/modules/es.array.fill.js";
import "core-js/modules/es.string.pad-start.js";
import "core-js/modules/es.string.pad-end.js";
import "core-js/modules/es.string.starts-with.js";
import "core-js/modules/es.string.code-point-at.js";
import "core-js/modules/es.string.ends-with.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.pad-end.js";
import "core-js/modules/es.string.pad-start.js";
import "core-js/modules/es.string.replace.js";
import "core-js/modules/es.array.copy-within.js";
import "core-js/modules/es.string.search.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.replace.js";
import "core-js/modules/es.string.split.js";
import "core-js/modules/es.string.starts-with.js";
import "core-js/modules/web.dom-collections.iterator.js";
Array.from; // static function
Map; // top level built-in

View File

@ -1,7 +1,7 @@
"use strict";
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.object.to-string.js");
Promise;

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.number.constructor.js";
import "core-js/modules/es.number.parse-float.js";
import "core-js/modules/es.number.constructor.js";
import "core-js/modules/es.number.parse-int.js";
Number.parseFloat("3.14");
Number.parseInt("10");

View File

@ -1,19 +1,19 @@
import "core-js/modules/es.array.filter.js";
import "core-js/modules/es.array.for-each.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array.of.js";
import "core-js/modules/es.date.to-string.js";
import "core-js/modules/es.function.bind.js";
import "core-js/modules/es.object.entries.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.regexp.to-string.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.date.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.string.trim.js";
import "core-js/modules/web.dom-collections.for-each.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.trim.js";
import "core-js/modules/es.array.filter.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.array.from.js";
import "core-js/modules/es.array.of.js";
import "core-js/modules/es.array.for-each.js";
import "core-js/modules/web.dom-collections.for-each.js";
var bind, toString;
var {
bind: bind

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
var p = Promise.resolve(0);
Promise.all([p]).then(function (outcome) {

View File

@ -1,5 +1,5 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.finally.js";
var p = Promise.resolve(0);
p.finally(function () {

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
var p = Promise.resolve(0);
Promise.race([p]).then(function (outcome) {

View File

@ -1,6 +1,6 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "regenerator-runtime/runtime.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/es.object.to-string.js";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

View File

@ -1,31 +1,31 @@
"use strict";
require("core-js/modules/es.array.from.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.map.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.symbol.match.js");
require("core-js/modules/es.string.match.js");
require("core-js/modules/es.symbol.js");
require("core-js/modules/es.symbol.description.js");
require("core-js/modules/es.symbol.iterator.js");
require("core-js/modules/es.symbol.match.js");
require("core-js/modules/es.array.from.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.map.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.string.match.js");
require("core-js/modules/web.dom-collections.iterator.js");
require("core-js/modules/web.queue-microtask.js");
require("core-js/modules/esnext.global-this.js");

View File

@ -1,8 +1,8 @@
require("core-js/modules/es.array.includes.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.array.includes.js");
require("foo");

View File

@ -1,8 +1,8 @@
require("core-js/modules/es.array.includes.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.promise.js");
require("core-js/modules/es.array.includes.js");
require("foo");

View File

@ -1,4 +1,4 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
a = [b, ...c];

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.object.keys.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.object.assign.js";
import "core-js/modules/es.object.define-property.js";
import "core-js/modules/es.object.keys.js";
Object.keys(foo);
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var {

View File

@ -1,8 +1,8 @@
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
Symbol.iterator in arr;

View File

@ -1,8 +1,8 @@
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.symbol.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.string.iterator.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
arr[Symbol.iterator]();

View File

@ -1,7 +1,7 @@
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.promise.js";
import "core-js/modules/web.immediate.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/web.timers.js";
import "core-js/modules/web.immediate.js";
Promise.resolve().then(function (it) {
setTimeout(foo, 1, 2);
setInterval(foo, 1, 2);

View File

@ -1,6 +1,6 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.typed-array.int8-array.js";
import "core-js/modules/es.typed-array.includes.js";
import "core-js/modules/es.typed-array.to-locale-string.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
new Int8Array(1);

View File

@ -1,6 +1,4 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array-buffer.slice.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.typed-array.of.js";
import "core-js/modules/es.typed-array.int8-array.js";
import "core-js/modules/es.typed-array.copy-within.js";
import "core-js/modules/es.typed-array.every.js";
@ -15,7 +13,6 @@ import "core-js/modules/es.typed-array.iterator.js";
import "core-js/modules/es.typed-array.join.js";
import "core-js/modules/es.typed-array.last-index-of.js";
import "core-js/modules/es.typed-array.map.js";
import "core-js/modules/es.typed-array.of.js";
import "core-js/modules/es.typed-array.reduce.js";
import "core-js/modules/es.typed-array.reduce-right.js";
import "core-js/modules/es.typed-array.reverse.js";
@ -26,4 +23,7 @@ import "core-js/modules/es.typed-array.sort.js";
import "core-js/modules/es.typed-array.subarray.js";
import "core-js/modules/es.typed-array.to-locale-string.js";
import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array-buffer.slice.js";
Int8Array.of();

View File

@ -1,6 +1,3 @@
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array-buffer.slice.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.typed-array.int8-array.js";
import "core-js/modules/es.typed-array.copy-within.js";
import "core-js/modules/es.typed-array.every.js";
@ -25,4 +22,7 @@ import "core-js/modules/es.typed-array.sort.js";
import "core-js/modules/es.typed-array.subarray.js";
import "core-js/modules/es.typed-array.to-locale-string.js";
import "core-js/modules/es.typed-array.to-string.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/es.array-buffer.slice.js";
new Int8Array(1);

View File

@ -46,10 +46,16 @@ Using plugins:
proposal-export-namespace-from { "android":"4" }
transform-modules-commonjs { "android":"4" }
proposal-dynamic-import { "android":"4" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"android": "4"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-android/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
es6.array.copy-within { "android":"4" }
es6.array.fill { "android":"4" }
es6.array.find { "android":"4" }

View File

@ -32,10 +32,16 @@ Using plugins:
proposal-export-namespace-from { "electron":"0.36" }
transform-modules-commonjs { "electron":"0.36" }
proposal-dynamic-import { "electron":"0.36" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"electron": "0.36"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-electron/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
es7.array.flat-map { "electron":"0.36" }
es6.array.from { "electron":"0.36" }
es6.array.iterator { "electron":"0.36" }

View File

@ -47,10 +47,16 @@ Using plugins:
transform-reserved-words {}
proposal-export-namespace-from { "chrome":"55" }
syntax-dynamic-import { "chrome":"55" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"chrome": "55"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-force-all-transforms/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
es7.array.flat-map { "chrome":"55" }
es6.array.iterator { "chrome":"55" }
es6.array.sort { "chrome":"55" }

View File

@ -27,7 +27,13 @@ Using plugins:
proposal-export-namespace-from { "node":"6" }
transform-modules-commonjs { "node":"6" }
proposal-dynamic-import { "node":"6" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"node": "6"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-no-import/input.js] Import of @babel/polyfill was not found.
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-no-import/input.js]
The entry point for the corejs2 polyfill has not been found.

View File

@ -19,10 +19,16 @@ Using plugins:
proposal-export-namespace-from { "chrome":"71" }
transform-modules-commonjs { "chrome":"71" }
proposal-dynamic-import { "chrome":"71" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"chrome": "71"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals-chrome-71/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals-chrome-71/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
web.timers { "chrome":"71" }
web.immediate { "chrome":"71" }
web.dom.iterable { "chrome":"71" }

View File

@ -48,10 +48,16 @@ Using plugins:
proposal-export-namespace-from { "ie":"6" }
transform-modules-commonjs { "ie":"6" }
proposal-dynamic-import { "ie":"6" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"ie": "6"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-proposals/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
es6.array.copy-within { "ie":"6" }
es6.array.every { "ie":"6" }
es6.array.fill { "ie":"6" }

View File

@ -21,10 +21,16 @@ Using plugins:
proposal-export-namespace-from { "chrome":"71" }
transform-modules-commonjs { "chrome":"71" }
proposal-dynamic-import { "chrome":"71" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"chrome": "71"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals-chrome-71/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
web.timers { "chrome":"71" }
web.immediate { "chrome":"71" }
web.dom.iterable { "chrome":"71" }

View File

@ -50,10 +50,16 @@ Using plugins:
proposal-export-namespace-from { "ie":"6" }
transform-modules-commonjs { "ie":"6" }
proposal-dynamic-import { "ie":"6" }
corejs2: `DEBUG` option
Using polyfills with `entry` option:
Using targets: {
"ie": "6"
}
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/input.mjs] Replaced @babel/polyfill entries with the following polyfills:
Using polyfills with `entry-global` method:
[<CWD>/packages/babel-preset-env/test/fixtures/debug/entry-corejs2-shippedProposals/input.mjs]
The corejs2 polyfill entry has been replaced with the following polyfills:
es6.array.copy-within { "ie":"6" }
es6.array.every { "ie":"6" }
es6.array.fill { "ie":"6" }

Some files were not shown because too many files have changed in this diff Show More