Update to core-js@3 (#7646)
### `@babel/runtime` - Added `@babel/runtime-corejs3` package and `corejs: 3` options to `@babel/plugin-transform-runtime`. - Added support of instance methods, fixes #8928. - Added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for support all proposals polyfills from `core-js`. - Used separate directories in runtime for `core-js` entry points with proposals and without. - Used `get-iterator-method` helper for getting iterators, fixes #2500. - As a cheap bonus, added support of IE8- (except some cases of `regenerator`). ### `@babel/polyfill` - Should be deprecated in favor of separate usage required features from `core-js` and `regenerator-runtime` with an informative message. ### `@babel/preset-env` - Uses for built-ins data from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) instead of `compat-table` since information from `compat-table` [is not enough](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat). - `useBuilIns` now requires direct setting of `corejs` version option, without it will be used `2` by default and shown deprecation warning. - Added support of minor `core-js` versions for simplify updating in the future. - For preventing some order-related problems, polyfills in the both `core-js@3` plugins added on `post` stage in the order of `core-js-compat` data. - Divided plugins and polyfills parts of `preset-env`, instead of 2 internal plugins for adding polyfills, we have 6: usage and entry versions of plugins for `core-js@2`, ### Current state: `core-js@3`, `regenerator-runtime`. - Added support `samsung` target (for Samsung Internet) since `core-js-compat` and `compat-table` now contains mapping for this, fixes #6602. #### `useBuilIns: entry` with `corejs: 3` - No longer transforms `@babel/polyfill`. - Transforms **all possible** `core-js` entry points to import of related modules (based on data from [`core-js-compat`](https://unpkg.com/core-js-compat@3.0.0-beta.15/entries.json)). - Since of this, we no longer need `shippedProposals` / `proposals` flags with `useBuilIns: entry`. - Removes `regenerator-runtime/runtime` import where it's not required. #### `useBuilIns: usage` with `corejs: 3` - In addition to `shippedProposals`, added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for polyfill all proposals from `core-js`. - Fixed list of dependencies in built-in definitions. - Improved the way of determination method / built-in name and source of this method. - Adds import of required polyfills on `MemberExpression`, `ObjectPattern`, `in` operator. - Adds import of required polyfills on access to global object properties. - Adds import of all required common iterators on all syntax features which use iterators protocol (`for-of`, destructuring, spread, `yield` delegation, etc.). - Adds import of promises on syntax features which use promises (async functions/generators, dynamic import, etc.), fixes #9250, #7402, etc. ### `core-js@2` stuff I didn't want to tough `core-js@2`-related stuff, however - Fixed some serious errors in definitions which breaks `Object.getOwnPropertySymbols`, `Symbol.toStringTag` logic, `Promise#finally`, `Array#forEach`, etc. - `Array#flatMap` and trim methods moved to stable features as a part of ES2019 and loaded by deprecated `@babel/polyfill` and `@babel/preset-env` with `corejs: 2` option.
This commit is contained in:
committed by
Nicolò Ribaudo
parent
7df0d16131
commit
3303b079c5
@@ -0,0 +1,155 @@
|
||||
import { hasMinVersion } from "./helpers";
|
||||
|
||||
export default runtimeVersion => {
|
||||
// Conditionally include 'Math' because it was not included in the 7.0.0
|
||||
// release of '@babel/runtime'. See issue https://github.com/babel/babel/pull/8616.
|
||||
const includeMathModule = hasMinVersion("7.0.1", runtimeVersion);
|
||||
|
||||
return {
|
||||
BuiltIns: {
|
||||
Symbol: { stable: true, path: "symbol" },
|
||||
Promise: { stable: true, path: "promise" },
|
||||
Map: { stable: true, path: "map" },
|
||||
WeakMap: { stable: true, path: "weak-map" },
|
||||
Set: { stable: true, path: "set" },
|
||||
WeakSet: { stable: true, path: "weak-set" },
|
||||
setImmediate: { stable: true, path: "set-immediate" },
|
||||
clearImmediate: { stable: true, path: "clear-immediate" },
|
||||
parseFloat: { stable: true, path: "parse-float" },
|
||||
parseInt: { stable: true, path: "parse-int" },
|
||||
},
|
||||
|
||||
StaticProperties: {
|
||||
Array: {
|
||||
from: { stable: true, path: "array/from" },
|
||||
isArray: { stable: true, path: "array/is-array" },
|
||||
of: { stable: true, path: "array/of" },
|
||||
},
|
||||
|
||||
JSON: {
|
||||
stringify: { stable: true, path: "json/stringify" },
|
||||
},
|
||||
|
||||
Object: {
|
||||
assign: { stable: true, path: "object/assign" },
|
||||
create: { stable: true, path: "object/create" },
|
||||
defineProperties: { stable: true, path: "object/define-properties" },
|
||||
defineProperty: { stable: true, path: "object/define-property" },
|
||||
entries: { stable: true, path: "object/entries" },
|
||||
freeze: { stable: true, path: "object/freeze" },
|
||||
getOwnPropertyDescriptor: {
|
||||
stable: true,
|
||||
path: "object/get-own-property-descriptor",
|
||||
},
|
||||
getOwnPropertyDescriptors: {
|
||||
stable: true,
|
||||
path: "object/get-own-property-descriptors",
|
||||
},
|
||||
getOwnPropertyNames: {
|
||||
stable: true,
|
||||
path: "object/get-own-property-names",
|
||||
},
|
||||
getOwnPropertySymbols: {
|
||||
stable: true,
|
||||
path: "object/get-own-property-symbols",
|
||||
},
|
||||
getPrototypeOf: { stable: true, path: "object/get-prototype-of" },
|
||||
isExtensible: { stable: true, path: "object/is-extensible" },
|
||||
isFrozen: { stable: true, path: "object/is-frozen" },
|
||||
isSealed: { stable: true, path: "object/is-sealed" },
|
||||
is: { stable: true, path: "object/is" },
|
||||
keys: { stable: true, path: "object/keys" },
|
||||
preventExtensions: { stable: true, path: "object/prevent-extensions" },
|
||||
seal: { stable: true, path: "object/seal" },
|
||||
setPrototypeOf: { stable: true, path: "object/set-prototype-of" },
|
||||
values: { stable: true, path: "object/values" },
|
||||
},
|
||||
|
||||
...(includeMathModule
|
||||
? {
|
||||
Math: {
|
||||
acosh: { stable: true, path: "math/acosh" },
|
||||
asinh: { stable: true, path: "math/asinh" },
|
||||
atanh: { stable: true, path: "math/atanh" },
|
||||
cbrt: { stable: true, path: "math/cbrt" },
|
||||
clz32: { stable: true, path: "math/clz32" },
|
||||
cosh: { stable: true, path: "math/cosh" },
|
||||
expm1: { stable: true, path: "math/expm1" },
|
||||
fround: { stable: true, path: "math/fround" },
|
||||
hypot: { stable: true, path: "math/hypot" },
|
||||
imul: { stable: true, path: "math/imul" },
|
||||
log10: { stable: true, path: "math/log10" },
|
||||
log1p: { stable: true, path: "math/log1p" },
|
||||
log2: { stable: true, path: "math/log2" },
|
||||
sign: { stable: true, path: "math/sign" },
|
||||
sinh: { stable: true, path: "math/sinh" },
|
||||
tanh: { stable: true, path: "math/tanh" },
|
||||
trunc: { stable: true, path: "math/trunc" },
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
||||
Symbol: {
|
||||
// FIXME: Disabled to work around zloirock/core-js#262.
|
||||
// asyncIterator: { stable: true, path: "symbol/async-iterator" },
|
||||
for: { stable: true, path: "symbol/for" },
|
||||
hasInstance: { stable: true, path: "symbol/has-instance" },
|
||||
isConcatSpreadable: {
|
||||
stable: true,
|
||||
path: "symbol/is-concat-spreadable",
|
||||
},
|
||||
iterator: { stable: true, path: "symbol/iterator" },
|
||||
keyFor: { stable: true, path: "symbol/key-for" },
|
||||
match: { stable: true, path: "symbol/match" },
|
||||
replace: { stable: true, path: "symbol/replace" },
|
||||
search: { stable: true, path: "symbol/search" },
|
||||
species: { stable: true, path: "symbol/species" },
|
||||
split: { stable: true, path: "symbol/split" },
|
||||
toPrimitive: { stable: true, path: "symbol/to-primitive" },
|
||||
toStringTag: { stable: true, path: "symbol/to-string-tag" },
|
||||
unscopables: { stable: true, path: "symbol/unscopables" },
|
||||
},
|
||||
|
||||
String: {
|
||||
at: { stable: true, path: "string/at" },
|
||||
fromCodePoint: { stable: true, path: "string/from-code-point" },
|
||||
raw: { stable: true, path: "string/raw" },
|
||||
},
|
||||
|
||||
Number: {
|
||||
EPSILON: { stable: true, path: "number/epsilon" },
|
||||
isFinite: { stable: true, path: "number/is-finite" },
|
||||
isInteger: { stable: true, path: "number/is-integer" },
|
||||
isNaN: { stable: true, path: "number/is-nan" },
|
||||
isSafeInteger: { stable: true, path: "number/is-safe-integer" },
|
||||
MAX_SAFE_INTEGER: { stable: true, path: "number/max-safe-integer" },
|
||||
MIN_SAFE_INTEGER: { stable: true, path: "number/min-safe-integer" },
|
||||
parseFloat: { stable: true, path: "number/parse-float" },
|
||||
parseInt: { stable: true, path: "number/parse-int" },
|
||||
},
|
||||
|
||||
Reflect: {
|
||||
apply: { stable: true, path: "reflect/apply" },
|
||||
construct: { stable: true, path: "reflect/construct" },
|
||||
defineProperty: { stable: true, path: "reflect/define-property" },
|
||||
deleteProperty: { stable: true, path: "reflect/delete-property" },
|
||||
getOwnPropertyDescriptor: {
|
||||
stable: true,
|
||||
path: "reflect/get-own-property-descriptor",
|
||||
},
|
||||
getPrototypeOf: { stable: true, path: "reflect/get-prototype-of" },
|
||||
get: { stable: true, path: "reflect/get" },
|
||||
has: { stable: true, path: "reflect/has" },
|
||||
isExtensible: { stable: true, path: "reflect/is-extensible" },
|
||||
ownKeys: { stable: true, path: "reflect/own-keys" },
|
||||
preventExtensions: { stable: true, path: "reflect/prevent-extensions" },
|
||||
setPrototypeOf: { stable: true, path: "reflect/set-prototype-of" },
|
||||
set: { stable: true, path: "reflect/set" },
|
||||
},
|
||||
|
||||
Date: {
|
||||
now: { stable: true, path: "date/now" },
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user