Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update to core-js@3 #7646

Merged
merged 112 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
31d062a
update `core-js` in `babel-polyfill`
zloirock Dec 12, 2018
55ad89b
update `core-js` in `babel-register`
zloirock Dec 12, 2018
ad28f33
add `@babel/runtime-corejs3`
zloirock Dec 12, 2018
da31d39
remove an old runtime-related hack from `applyDecoratedDescriptor` fo…
zloirock Dec 12, 2018
d48087a
build runtime package with usage of ES3 related transforms for make s…
zloirock Dec 12, 2018
e4b31fb
remove a special case for `Object.defineProperty` from runtime for ma…
zloirock Dec 12, 2018
79e8924
use `get-iterator-method` helper for getting iterators in runtime, fi…
zloirock Dec 12, 2018
d711daf
add fixtures for `runtime-corejs3`
zloirock Dec 12, 2018
4674236
split `runtime-corejs2` and `runtime-corejs3` built-ins definitions
zloirock Dec 13, 2018
bec4c51
update definitions for `runtime-corejs3`
zloirock Dec 13, 2018
b9168c9
add some runtime tests
zloirock Dec 13, 2018
fa6f9a4
add support of instance methods to runtime
zloirock Dec 14, 2018
aaa1316
update `core-js` in `preset-env`, initial
zloirock Dec 17, 2018
0348804
update built-ins data in preset-env
zloirock Dec 17, 2018
95656be
update to `core-js-pure@3.0.0-beta.6`
zloirock Dec 18, 2018
c0b895e
add some tests
zloirock Dec 19, 2018
0a0dfa7
update to `core-js@3.0.0-beta.9`
zloirock Jan 18, 2019
a51ef45
revert back `@babel/polyfill` to `core-js@2` for leaving a major vers…
zloirock Jan 18, 2019
580a003
move preset-env built-ins plugins to separate folder, split usage plu…
zloirock Jan 20, 2019
18e07fb
some stylistic changes
zloirock Jan 20, 2019
72fbcfb
update core-js@2 version in babel-polyfill for prevent problems relat…
zloirock Jan 22, 2019
a5c223e
extract `isPluginRequired` and `filterItems`
zloirock Jan 23, 2019
f2560dc
get rid of `logMessage`
zloirock Jan 23, 2019
f991a66
fix linting
zloirock Jan 23, 2019
241bb3c
get rid of `onDebug` callback, remove incorrect debug targets output …
zloirock Jan 23, 2019
e784f8d
don't add regenerator-usage plugin where it's not required
zloirock Jan 23, 2019
40691ee
update to `core-js@3.0.0-beta.10`
zloirock Jan 23, 2019
d2eafb2
simplify `getBuiltInTargets`
zloirock Jan 23, 2019
7ab1386
add `core-js@2` usage and entry plugins
zloirock Jan 24, 2019
4e2d213
fix `addCommonIterators` helper, add `Promise` polyfill on async func…
zloirock Jan 24, 2019
b42ad16
add a carcass of regenerator entry plugin
zloirock Jan 24, 2019
74f5687
template of polyfills plugins injection
zloirock Jan 24, 2019
0e2b229
integrate core-js-compat
zloirock Jan 25, 2019
b8aef21
revert back core-js@2 data
zloirock Jan 25, 2019
2bc2eff
revert back `defaultWebIncludes` to core-js@2
zloirock Jan 25, 2019
bbf0f99
update definitions for core-js@3
zloirock Jan 25, 2019
7106699
add `corejs` option to `preset-env` as a temporal solution for suppor…
zloirock Jan 25, 2019
5362421
fix `defaultWebIncludes` in options normalization with core-js@2
zloirock Jan 25, 2019
fe1318b
add warning about missed core-js version option
zloirock Jan 26, 2019
08f1e0c
update debug-fixtures
zloirock Jan 27, 2019
11d012a
add debug fixtures for different core-js versions
zloirock Jan 27, 2019
f84ea73
add fixtures for different core-js versions
zloirock Jan 31, 2019
28268d9
implicit core-js version is 2
zloirock Jan 31, 2019
ae4e787
move `objectToBrowserslist` to `targets-parser`
zloirock Feb 1, 2019
3e97772
update to core-js@3.0.0-beta.12
zloirock Feb 2, 2019
60cfd2e
update to core-js@3.0.0-beta.13, use core-js /instance/ entries
zloirock Feb 4, 2019
c6c8923
add to runtime core-js definitions information about stability of fea…
zloirock Feb 4, 2019
fd427ab
add `proposal` option to `babel-transform-runtime`
zloirock Feb 4, 2019
33462ab
some fixes of instance methods injection logic
zloirock Feb 5, 2019
ce6e083
allow minor core-js versions in preset-env config
zloirock Feb 5, 2019
472b16c
allow polyfilling proposals in preset-env
zloirock Feb 6, 2019
8e7323f
remove generated core-js runtime files from git
zloirock Feb 6, 2019
ed2063e
update to core-js@3.0.0-beta.14
zloirock Feb 7, 2019
81c071e
replace top level entry points of core-js and regenerator-runtime ins…
zloirock Feb 8, 2019
768bddc
add some more tests
zloirock Feb 9, 2019
cd5e780
transform all possible core-js entry points
zloirock Feb 9, 2019
9a99f90
add some more tests
zloirock Feb 10, 2019
e9b2b32
update core-js@2 stuff
zloirock Feb 10, 2019
6c927f0
some stylistic changes, move built-ins related code to related plugin…
zloirock Feb 11, 2019
3dd80cf
make usage plugins little more object oriented
zloirock Feb 11, 2019
dee18ff
improve preset-env CONTRIBUTING.md
zloirock Feb 11, 2019
2a36a1e
deprecation warning on `@babel/polyfill` in `preset-env` with `core-j…
zloirock Feb 11, 2019
ebe8252
Update packages/babel-plugin-transform-runtime/src/index.js
nicolo-ribaudo Feb 11, 2019
7a8d958
some fixes
zloirock Feb 11, 2019
52383a2
use `t.cloneNode` on invocation of instance methods in runtime
zloirock Feb 12, 2019
362e2b3
refactoring
zloirock Feb 12, 2019
895f285
some stylistic changes
zloirock Feb 12, 2019
cab6e6b
some improvements of built-in-definitions
zloirock Feb 12, 2019
122af9c
some stylistic changes
zloirock Feb 13, 2019
7af124d
unify writeCoreJS
zloirock Feb 13, 2019
5295aae
fix instance methods optimisation
zloirock Feb 13, 2019
2103a57
inject polyfills in the order from core-js-compat on post stage for p…
zloirock Feb 13, 2019
18ca001
use isSomething helpers instead of direct `.type` check
zloirock Feb 14, 2019
b6ab5b6
add `Promise` dependencies on dynamic import, fixes #7402
zloirock Feb 14, 2019
0d4564d
add `Promise` dependencies on `fetch` usage
zloirock Feb 14, 2019
569af66
Update packages/babel-preset-env/CONTRIBUTING.md
nicolo-ribaudo Feb 15, 2019
7b99bde
fix some typos in CONTRIBUTING.md
zloirock Feb 15, 2019
564c408
use Program(path) { } instead of Program: { enter(path) { } }
zloirock Feb 15, 2019
5cb279e
simplify MemberExpression visitor, get rid of some extra isReferenced
zloirock Feb 15, 2019
3930d36
rework corejs3/usage plugin, fix many destructuring-ralated cases
zloirock Feb 17, 2019
5fa3233
rework the way of determination of keys and sources in corejs3/usage-…
zloirock Feb 18, 2019
2e04224
inject dependencies on getting built-ins as properties of global object
zloirock Feb 18, 2019
2a86728
update to `core-js@3.0.0-beta.16`
zloirock Feb 18, 2019
f421b95
inject polyfills on `in` operator
zloirock Feb 18, 2019
0833f85
determinate source of object destructuring in IIFE arguments
zloirock Feb 19, 2019
d0ecc3f
some stylistic changes
zloirock Feb 19, 2019
5537762
don't exit from `addPropertyDependencies` after `PossibleGlobalObject…
zloirock Feb 19, 2019
70f70d7
simplify identification sources of `import` and `require`
zloirock Feb 20, 2019
bd6d0de
some stylistic changes
zloirock Feb 20, 2019
8e86ef9
remove obsolete note from `preset-env` CONTRIBUTING.md
zloirock Feb 20, 2019
c4e75b2
add support `samsung` target (for Samsung Internet) since `core-js-co…
zloirock Feb 20, 2019
ed59f4d
add some more tests of specific `core-js` entry points by `preset-env…
zloirock Feb 20, 2019
bebd5cf
sync with master
zloirock Feb 22, 2019
71fde5a
simplify adding `Promise` dependencies on `import` pseudo-expression
zloirock Feb 22, 2019
2f189b9
sync with master
zloirock Feb 27, 2019
6ff31a9
use `corejs: { version, proposals }` options format
zloirock Mar 2, 2019
d09d699
don't add common iterators dependencies on `SpreadElement` in `Object…
zloirock Mar 5, 2019
ad41bbf
bump `regenerator-runtime` version
zloirock Mar 7, 2019
f46e4fe
update to `core-js@3.0.0-beta.18`
zloirock Mar 9, 2019
d02ffb8
fix an error in `core-js@2` definitions: `es6.object.get-own-property…
zloirock Mar 11, 2019
0f5b26a
fix `core-js@2` `es6.object.to-string` definition
zloirock Mar 11, 2019
689f6b5
add a few more simple tests
zloirock Mar 12, 2019
bb40189
add a warning on `corejs` option without `useBuiltIns`
zloirock Mar 14, 2019
6998ed9
inject `es.promise.finally` only on `.finally` usage
zloirock Mar 14, 2019
c33d52e
get rid of some warnings in tests
zloirock Mar 14, 2019
2572d72
remove `web.dom.iterable` from `.forEach` dependencies in `core-js@2`…
zloirock Mar 15, 2019
2268d73
update to `core-js@3.0.0-beta.20`
zloirock Mar 17, 2019
f40e7f5
sync with master
zloirock Mar 17, 2019
331e634
add required `Promise` dependencies on `.finally` method in `core-js@…
zloirock Mar 19, 2019
48bbb4b
Add back types to preset-env (#9687)
nicolo-ribaudo Mar 19, 2019
7af14c5
Merge master
nicolo-ribaudo Mar 19, 2019
3856bc3
update to `core-js@3.0.0`
zloirock Mar 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package.json
lerna.json
packages/babel-runtime
!packages/babel-plugin-transform-runtime/scripts
!packages/babel-runtime-corejs2/core-js.js
packages/babel-runtime-corejs2
packages/babel-runtime-corejs3
packages/*/node_modules
packages/*/lib
packages/*/dist
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ package-lock.json
/packages/babel-runtime-corejs2/core-js/**/*.js
!/packages/babel-runtime-corejs2/core-js/map.js

/packages/babel-runtime-corejs3/helpers/*.js
/packages/babel-runtime-corejs3/helpers/esm/*.js
/packages/babel-runtime-corejs3/core-js/**/*.js
/packages/babel-runtime-corejs3/core-js-stable/**/*.js

/packages/babel-register/test/.babel
/packages/babel-cli/test/tmp
/packages/babel-node/test/tmp
Expand Down
31 changes: 28 additions & 3 deletions lib/third-party-libs.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,31 @@ declare module "lodash/merge" {
}

declare module "semver" {
declare class SemVer {
build: Array<string>;
loose: ?boolean;
major: number;
minor: number;
patch: number;
prerelease: Array<string | number>;
raw: string;
version: string;

constructor(version: string | SemVer): SemVer;
}

declare module.exports: {
valid(v: string): boolean;
SemVer: SemVer;

coerce(version: string | SemVer): SemVer | null;
gt(v1: string, v2: string): boolean;
intersects(r1: string, r2: string): boolean;
lt(v1: string, v2: string): boolean;
major(v: string): number;
minor(v: string): number;
patch(v: string): number;
satisfies(v1: string, r1: string): boolean;

intersects(r1: string, r2: string): boolean;
valid(v: string): boolean;
}
}

Expand Down Expand Up @@ -180,3 +195,13 @@ declare module "js-levenshtein" {
(string, string): number,
};
}

declare module "core-js-compat/data" {
declare type Target = "node" | "chrome" | "opera" | "edge" | "firefox" | "safari" | "ie" | "ios" | "android" | "electron" | "samsung";

declare module.exports: {
[key: string]: {
[target: Target]: string;
}
}
}
4 changes: 2 additions & 2 deletions packages/babel-helpers/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context){
var desc = {};
Object['ke' + 'ys'](descriptor).forEach(function(key){
Object.keys(descriptor).forEach(function(key){
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
Expand All @@ -1019,7 +1019,7 @@ helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
if (desc.initializer === void 0){
// This is a hack to avoid this being processed by 'transform-runtime'.
// See issue #9.
Object['define' + 'Property'](target, property, desc);
Object.defineProperty(target, property, desc);
zloirock marked this conversation as resolved.
Show resolved Hide resolved
desc = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; }
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _class, _class2;

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; }
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

let A = (_class2 = class A {
foo() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var _class2;

function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; }
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

let _class = (_class2 = class {
bar() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"targets": {
"node": 8
},
"useBuiltIns": "usage"
"useBuiltIns": "usage",
"corejs": 3
}
]
],
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-plugin-transform-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"@babel/helper-plugin-test-runner": "^7.0.0",
"@babel/helpers": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.3.4",
"@babel/plugin-transform-member-expression-literals": "^7.2.0",
"@babel/plugin-transform-property-literals": "^7.2.0",
"@babel/preset-env": "^7.3.4",
"@babel/runtime": "^7.3.4",
"@babel/template": "^7.0.0",
Expand Down
84 changes: 62 additions & 22 deletions packages/babel-plugin-transform-runtime/scripts/build-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,81 @@ const template = require("@babel/template");
const t = require("@babel/types");

const transformRuntime = require("../");
const getCorejs2Definitions = require("../lib/definitions").default;
const corejs2Definitions = getCorejs2Definitions();
const transformMemberExpressionLiterals = require("@babel/plugin-transform-member-expression-literals");
const transformPropertyLiterals = require("@babel/plugin-transform-property-literals");

writeHelpers("@babel/runtime");
const corejs2Definitions = require("../lib/runtime-corejs2-definitions").default();
const corejs3Definitions = require("../lib/runtime-corejs3-definitions").default();

writeCoreJS2("@babel/runtime-corejs2");
writeHelpers("@babel/runtime");
writeHelpers("@babel/runtime-corejs2", { corejs: 2 });

function writeCoreJS2(runtimeName) {
const pkgDirname = getRuntimeRoot(runtimeName);

const paths = [
writeHelpers("@babel/runtime-corejs3", {
corejs: { version: 3, proposals: true },
});

writeCoreJS({
corejs: 2,
proposals: true,
definitions: corejs2Definitions,
paths: [
"is-iterable",
"get-iterator",

// This was previously in definitions, but was removed to work around
// zloirock/core-js#262. We need to keep it in @babel/runtime-corejs2 to
// avoid a breaking change there.
"symbol/async-iterator",
];

Object.keys(corejs2Definitions.builtins).forEach(key => {
const path = corejs2Definitions.builtins[key];
paths.push(path);
],
corejsRoot: "core-js/library/fn",
});
writeCoreJS({
corejs: 3,
proposals: false,
definitions: corejs3Definitions,
paths: [],
corejsRoot: "core-js-pure/stable",
});
writeCoreJS({
corejs: 3,
proposals: true,
definitions: corejs3Definitions,
paths: ["is-iterable", "get-iterator", "get-iterator-method"],
corejsRoot: "core-js-pure/features",
});

function writeCoreJS({
corejs,
proposals,
definitions: { BuiltIns, StaticProperties, InstanceProperties },
paths,
corejsRoot,
}) {
const pkgDirname = getRuntimeRoot(`@babel/runtime-corejs${corejs}`);

Object.keys(BuiltIns).forEach(name => {
const { stable, path } = BuiltIns[name];
if (stable || proposals) paths.push(path);
});

Object.keys(corejs2Definitions.methods).forEach(key => {
const props = corejs2Definitions.methods[key];
Object.keys(props).forEach(key2 => {
paths.push(props[key2]);
Object.keys(StaticProperties).forEach(builtin => {
const props = StaticProperties[builtin];
Object.keys(props).forEach(name => {
const { stable, path } = props[name];
if (stable || proposals) paths.push(path);
});
});

paths.forEach(function(corePath) {
if (InstanceProperties) {
Object.keys(InstanceProperties).forEach(name => {
const { stable, path } = InstanceProperties[name];
if (stable || proposals) paths.push(`instance/${path}`);
});
}

const runtimeRoot = proposals ? "core-js" : "core-js-stable";
paths.forEach(function(corejsPath) {
outputFile(
path.join(pkgDirname, "core-js", `${corePath}.js`),
`module.exports = require("core-js/library/fn/${corePath}");`
path.join(pkgDirname, runtimeRoot, `${corejsPath}.js`),
`module.exports = require("${corejsRoot}/${corejsPath}");`
);
});
}
Expand Down Expand Up @@ -118,6 +156,8 @@ function buildHelper(
presets: [[require("@babel/preset-env"), { modules: false }]],
plugins: [
[transformRuntime, { corejs, useESModules: esm }],
[transformMemberExpressionLiterals],
[transformPropertyLiterals],
buildRuntimeRewritePlugin(
runtimeName,
path.relative(path.dirname(helperFilename), pkgDirname),
Expand Down