Skip to content

Commit

Permalink
move globalThis to stable ES
Browse files Browse the repository at this point in the history
per agenda of the next TC39 meeting
  • Loading branch information
zloirock committed Oct 2, 2019
1 parent f810631 commit 076f2b8
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
## Changelog
##### Unreleased
- **`String#{ matchAll, replaceAll }` throws an error on non-global regex argument per [this PR](https://github.com/tc39/proposal-string-replaceall/pull/24) and [the decision from TC39 meetings](https://docs.google.com/presentation/d/1OGmV6uVTOEeSYO1nMeLjzflkbRJZ4p9QXlGV8IvDMmU/edit#slide=id.g61f26d86f6_0_2). It's a breaking change, but because it's a breaking change in the ES spec, it's added at the minor release**
- `globalThis` moved to stable ES
- Added [iterator helpers stage 2 proposal](https://github.com/tc39/proposal-iterator-helpers):
- `Iterator`
- `Iterator.from`
Expand Down
26 changes: 13 additions & 13 deletions README.md
Expand Up @@ -1601,6 +1601,19 @@ Stage 4 proposals already marked in `core-js` as stable ECMAScript, they will be
```js
core-js(-pure)/stage/4
```
* `globalThis` [proposal](https://github.com/tc39/proposal-global) - module [`esnext.global-this`](https://github.com/zloirock/core-js/blob/v3.2.1/packages/core-js/modules/esnext.global-this.js).
```js
let globalThis: Object;
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/global-this
core-js(-pure)/features/global-this
```
[*Examples*](https://goo.gl/LAifsc):
```js
globalThis.Array === Array; // => true
```
* `String#matchAll` [proposal](https://github.com/tc39/proposal-string-matchall) - module [`esnext.string.match-all`](https://github.com/zloirock/core-js/blob/v3.2.1/packages/core-js/modules/esnext.string.match-all.js).

```js
Expand Down Expand Up @@ -1628,19 +1641,6 @@ core-js/proposals/promise-all-settled
```js
core-js(-pure)/stage/3
```
* `globalThis` [proposal](https://github.com/tc39/proposal-global) - module [`esnext.global-this`](https://github.com/zloirock/core-js/blob/v3.2.1/packages/core-js/modules/esnext.global-this.js).
```js
let globalThis: Object;
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/global-this
core-js(-pure)/features/global-this
```
[*Examples*](https://goo.gl/LAifsc):
```js
globalThis.Array === Array; // => true
```

#### Stage 2 proposals
[*CommonJS entry points:*](#commonjs-api)
Expand Down
13 changes: 8 additions & 5 deletions packages/core-js-compat/src/data.js
Expand Up @@ -332,6 +332,11 @@ const data = {
firefox: '4',
safari: '8.0',
},
'es.global-this': {
chrome: '71',
firefox: '65',
safari: '12.1',
},
'es.json.to-string-tag': {
edge: '15',
chrome: '50',
Expand Down Expand Up @@ -1233,11 +1238,8 @@ const data = {
},
'esnext.composite-symbol': {
},
'esnext.global-this': {
chrome: '71',
firefox: '65',
safari: '12.1',
},
// TODO: Remove from `core-js@4`
'esnext.global-this': null,
'esnext.iterator.constructor': {
},
'esnext.iterator.as-indexed-pairs': {
Expand Down Expand Up @@ -1481,6 +1483,7 @@ const data = {
};

// TODO: Remove from `core-js@4`
data['esnext.global-this'] = data['es.global-this'];
data['esnext.promise.all-settled'] = data['es.promise.all-settled'];
data['esnext.string.match-all'] = data['es.string.match-all'];

Expand Down
1 change: 1 addition & 0 deletions packages/core-js-compat/src/modules-by-versions.js
Expand Up @@ -12,6 +12,7 @@ module.exports = {
'esnext.symbol.async-dispose',
],
3.3: [
'es.global-this',
'esnext.async-iterator.constructor',
'esnext.async-iterator.as-indexed-pairs',
'esnext.async-iterator.drop',
Expand Down
3 changes: 3 additions & 0 deletions packages/core-js/es/global-this.js
@@ -0,0 +1,3 @@
require('../modules/esnext.global-this');

module.exports = require('../internals/global');
1 change: 1 addition & 0 deletions packages/core-js/es/index.js
Expand Up @@ -41,6 +41,7 @@ require('../modules/es.object.lookup-setter');
require('../modules/es.function.bind');
require('../modules/es.function.name');
require('../modules/es.function.has-instance');
require('../modules/es.global-this');
require('../modules/es.array.from');
require('../modules/es.array.is-array');
require('../modules/es.array.of');
Expand Down
4 changes: 1 addition & 3 deletions packages/core-js/features/global-this.js
@@ -1,3 +1 @@
require('../modules/esnext.global-this');

module.exports = require('../internals/global');
module.exports = require('../es/global-this');
8 changes: 8 additions & 0 deletions packages/core-js/modules/es.global-this.js
@@ -0,0 +1,8 @@
var $ = require('../internals/export');
var global = require('../internals/global');

// `globalThis` object
// https://github.com/tc39/proposal-global
$({ global: true }, {
globalThis: global
});
10 changes: 2 additions & 8 deletions packages/core-js/modules/esnext.global-this.js
@@ -1,8 +1,2 @@
var $ = require('../internals/export');
var global = require('../internals/global');

// `globalThis` object
// https://github.com/tc39/proposal-global
$({ global: true }, {
globalThis: global
});
// TODO: Remove from `core-js@4`
require('./es.global-this');
4 changes: 1 addition & 3 deletions packages/core-js/stable/global-this.js
@@ -1,3 +1 @@
require('../modules/esnext.global-this');

module.exports = require('../internals/path').globalThis;
module.exports = require('../es/global-this');
2 changes: 0 additions & 2 deletions packages/core-js/stage/3.js
@@ -1,3 +1 @@
require('../proposals/global-this');

module.exports = require('./4');
1 change: 1 addition & 0 deletions packages/core-js/stage/4.js
@@ -1,3 +1,4 @@
require('../proposals/global-this');
require('../proposals/promise-all-settled');
require('../proposals/string-match-all');

Expand Down
2 changes: 2 additions & 0 deletions tests/commonjs.js
Expand Up @@ -354,6 +354,8 @@ for (const _PATH of ['../packages/core-js-pure', '../packages/core-js']) {
ok(load('features/promise/try')(() => 42) instanceof load('features/promise'));
ok(new (load('features/aggregate-error'))([42]).errors[0] === 42);
ok('from' in load('features/observable'));
ok(load('es/global-this').Math === Math);
ok(load('stable/global-this').Math === Math);
ok(load('features/global-this').Math === Math);
ok(typeof load('features/dom-collections').iterator === 'function');
ok(typeof load('features/dom-collections/iterator') === 'function');
Expand Down
6 changes: 3 additions & 3 deletions tests/compat/tests.js
Expand Up @@ -429,6 +429,9 @@ GLOBAL.tests = {
'es.function.name': function () {
return 'name' in Function.prototype;
},
'es.global-this': function () {
return globalThis;
},
'es.json.to-string-tag': [SYMBOLS_SUPPORT, function () {
return JSON[Symbol.toStringTag];
}],
Expand Down Expand Up @@ -1072,9 +1075,6 @@ GLOBAL.tests = {
'esnext.composite-symbol': function () {
return compositeSymbol;
},
'esnext.global-this': function () {
return globalThis;
},
'esnext.iterator.constructor': function () {
return typeof Iterator == 'function'
&& Iterator.prototype === Object.getPrototypeOf(Object.getPrototypeOf([].values()));
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/pure/index.js
Expand Up @@ -34,6 +34,7 @@ import './es.date.to-iso-string';
import './es.date.to-json';
import './es.function.bind';
import './es.function.has-instance';
import './es.global-this';
import './es.map';
import './es.math.acosh';
import './es.math.asinh';
Expand Down Expand Up @@ -157,7 +158,6 @@ import './esnext.async-iterator.take';
import './esnext.async-iterator.to-array';
import './esnext.composite-key';
import './esnext.composite-symbol';
import './esnext.global-this';
import './esnext.iterator.constructor';
import './esnext.iterator.as-indexed-pairs';
import './esnext.iterator.drop';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/tests/index.js
Expand Up @@ -34,6 +34,7 @@ import './es.date.to-string';
import './es.function.bind';
import './es.function.has-instance';
import './es.function.name';
import './es.global-this';
import './es.map';
import './es.math.acosh';
import './es.math.asinh';
Expand Down Expand Up @@ -208,7 +209,6 @@ import './esnext.async-iterator.take';
import './esnext.async-iterator.to-array';
import './esnext.composite-key';
import './esnext.composite-symbol';
import './esnext.global-this';
import './esnext.iterator.constructor';
import './esnext.iterator.as-indexed-pairs';
import './esnext.iterator.drop';
Expand Down

0 comments on commit 076f2b8

Please sign in to comment.