Skip to content

Commit

Permalink
Merge branch 'zloirock:master' into readme-redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudxain authored Sep 3, 2022
2 parents d7b604e + e2e9036 commit 4b4e00d
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ const forbidES2022BuiltIns = {
'es-x/no-regexp-d-flag': ERROR,
};

const forbidES2023BuiltIns = {
'es-x/no-array-prototype-findlast-findlastindex': ERROR,
};

const forbidModernESBuiltIns = {
...forbidESAnnexBBuiltIns,
...forbidES5BuiltIns,
Expand All @@ -870,6 +874,7 @@ const forbidModernESBuiltIns = {
...forbidES2020BuiltIns,
...forbidES2021BuiltIns,
...forbidES2022BuiltIns,
...forbidES2023BuiltIns,
};

const asyncAwait = {
Expand Down Expand Up @@ -926,13 +931,16 @@ const nodePackages = {
...forbidES2020BuiltIns,
...forbidES2021BuiltIns,
...forbidES2022BuiltIns,
...forbidES2023BuiltIns,
};

const nodeDev = {
...asyncAwait,
// disallow unsupported ECMAScript built-ins on the specified version
'n/no-unsupported-features/node-builtins': [ERROR, { version: DEV_NODE_VERSIONS }],
...disable(forbidModernESBuiltIns),
'es-x/no-array-string-prototype-at': ERROR,
...forbidES2023BuiltIns,
};

const tests = {
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## Changelog
##### Unreleased
- Added `sideEffects` field to `core-js-pure` `package.json` for better tree shaking, [#1117](https://github.com/zloirock/core-js/issues/1117)
- Dropped `semver` dependency from `core-js-compat`
- `semver` package (ironically) added [a breaking change and dropped NodeJS 8 support in the minor `7.1` version](https://github.com/npm/node-semver/commit/d61f828e64260a0a097f26210f5500), after that `semver` in `core-js-compat` was pinned to `7.0` since for avoiding breaking changes it should support NodeJS 8. However, since `core-js-compat` is usually used with other packages that use `semver` dependency, it causes multiple duplication of `semver` in dependencies. So I decided to remove `semver` dependency and replace it with a couple of simple helpers.
- Added Bun 0.1.6-0.1.10 compat data
- Added Deno 1.25 compat data mapping
- Updated Electron 21 compat data mapping
- Some stylistic changes, minor fixes, and improvements

##### [3.25.0 - 2022.08.25](https://github.com/zloirock/core-js/releases/tag/v3.25.0)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"es-observable": "git+https://github.com/tc39/proposal-observable.git#d3404f06bc70c7c578a5047dfb3dc813730e3319",
"eslint": "^8.23.0",
"eslint-plugin-array-func": "^3.1.7",
"eslint-plugin-es-x": "^5.2.1",
"eslint-plugin-es-x": "^5.3.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsonc": "^2.4.0",
Expand All @@ -60,7 +60,7 @@
"karma-qunit": "^4.1.2",
"konan": "^2.1.1",
"moon-unit": "0.2.2",
"npm": "8.18.0",
"npm": "8.19.1",
"npm-run-all": "^4.1.5",
"p-timeout": "^6.0.0",
"phantomjs-prebuilt": "~2.1.16",
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"directory": "packages/core-js-builder"
},
"main": "index.js",
"sideEffects": false,
"dependencies": {
"core-js": "3.25.0",
"core-js-compat": "3.25.0",
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"directory": "packages/core-js-compat"
},
"main": "index.js",
"sideEffects": false,
"dependencies": {
"browserslist": "^4.21.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-compat/src/mapping.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default {
[100, '18.0'],
[102, '19.0'],
[104, '20.0'],
[105, '21.0'],
[106, '21.0'],
],
// https://medium.com/samsung-internet-dev
// https://github.com/mdn/browser-compat-data/blob/main/browsers/samsunginternet_android.json
Expand Down
1 change: 1 addition & 0 deletions packages/core-js-pure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"url": "https://github.com/zloirock/core-js.git"
},
"main": "index.js",
"sideEffects": ["./modules/*.js"],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
Expand Down
9 changes: 9 additions & 0 deletions tests/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ export const CORRECT_PROTOTYPE_GETTER = !function () {
}
}();

// FF < 23 bug
export const REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR = DESCRIPTORS && !function () {
try {
Object.defineProperty([], 'length', { writable: false });
} catch {
return true;
}
}();

export const WHITESPACES = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4 changes: 2 additions & 2 deletions tests/pure/es.array.push.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

import push from 'core-js-pure/es/array/virtual/push';
import defineProperty from 'core-js-pure/es/object/define-property';
Expand All @@ -11,7 +11,7 @@ QUnit.test('Array#push', assert => {
assert.same(object[0x100000000], 1, 'proper ToLength #2');

if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => push.call(defineProperty([], 'length', { writable: false }), 1), TypeError, 'non-writable length, with arg');
assert.throws(() => push.call(defineProperty([], 'length', { writable: false })), TypeError, 'non-writable length, without arg');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/pure/es.array.splice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

import Symbol from 'core-js-pure/es/symbol';
import splice from 'core-js-pure/es/array/splice';
Expand Down Expand Up @@ -29,7 +29,7 @@ QUnit.test('Array#splice', assert => {
array = [0, 1, 2];
assert.deepEqual(splice(array, 2), [2]);
if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => splice(defineProperty([1, 2, 3], 'length', { writable: false }), 1, 1), TypeError, 'non-writable length');
}
assert.throws(() => splice(null), TypeError);
Expand Down
4 changes: 2 additions & 2 deletions tests/pure/es.array.unshift.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

import unshift from 'core-js-pure/es/array/virtual/unshift';
import defineProperty from 'core-js-pure/es/object/define-property';
Expand All @@ -9,7 +9,7 @@ QUnit.test('Array#unshift', assert => {
assert.same(unshift.call([1], 0), 2, 'proper result');

if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => unshift.call(defineProperty([], 'length', { writable: false }), 1), TypeError, 'non-writable length, with arg');
assert.throws(() => unshift.call(defineProperty([], 'length', { writable: false })), TypeError, 'non-writable length, without arg');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/es.array.push.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

const { defineProperty } = Object;

Expand All @@ -15,7 +15,7 @@ QUnit.test('Array#push', assert => {
assert.same(object[0x100000000], 1, 'proper ToLength #2');

if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => push.call(defineProperty([], 'length', { writable: false }), 1), TypeError, 'non-writable length, with arg');
assert.throws(() => push.call(defineProperty([], 'length', { writable: false })), TypeError, 'non-writable length, without arg');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/es.array.splice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

const { defineProperty } = Object;

Expand Down Expand Up @@ -32,7 +32,7 @@ QUnit.test('Array#splice', assert => {
array = [0, 1, 2];
assert.deepEqual(array.splice(2), [2]);
if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => splice.call(defineProperty([1, 2, 3], 'length', { writable: false }), 1, 1), TypeError, 'non-writable length');
}
assert.throws(() => splice.call(null), TypeError);
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/es.array.unshift.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';

const { defineProperty } = Object;

Expand All @@ -13,7 +13,7 @@ QUnit.test('Array#unshift', assert => {
assert.same(unshift.call([1], 0), 2, 'proper result');

if (STRICT) {
if (DESCRIPTORS) {
if (REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR) {
assert.throws(() => unshift.call(defineProperty([], 'length', { writable: false }), 1), TypeError, 'non-writable length, with arg');
assert.throws(() => unshift.call(defineProperty([], 'length', { writable: false })), TypeError, 'non-writable length, without arg');
}
Expand Down

0 comments on commit 4b4e00d

Please sign in to comment.