Skip to content

Commit

Permalink
move to scoped package: core-js-pure -> @core-js/pure
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 12, 2023
1 parent 8b1fd00 commit 3886ffe
Show file tree
Hide file tree
Showing 327 changed files with 645 additions and 643 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ There is always some ["help wanted" issues](https://github.com/zloirock/core-js/
- Shared helpers should be added to the [`packages/core-js/internals`](./packages/core-js/internals) directory. Reuse already existing helpers.
- Avoid direct import from `/modules/` path in `/internals|modules/` since it will break optimizations via Babel / `swc`. Specify such dependencies in `/es|stable|actual/full/` entries and use something like [`internals/get-built-in`](./packages/core-js/modules/get-built-in.js) helpers.
- For export the polyfill, in all common cases use [`internals/export`](./packages/core-js/modules/export.js) helper. Use something else only if this helper is not applicable - for example, if you want to polyfill accessors.
- If the code of the pure version implementation should significantly differ from the global version (*that's not a frequent situation, in most cases [`internals/is-pure`](./packages/core-js/modules/is-pure.js) constant is enough*), you can add it to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest parts of `core-js-pure` will be copied from `core-js` package.
- If the code of the pure version implementation should significantly differ from the global version (*that's not a frequent situation, in most cases [`internals/is-pure`](./packages/core-js/modules/is-pure.js) constant is enough*), you can add it to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest parts of `@core-js/pure` will be copied from `core-js` package.
- Add the feature detection of the polyfill to [`tests/compat/tests.js`](./tests/compat/tests.js), add the compatibility data to [`packages/core-js-compat/src/data.mjs`](./packages/core-js-compat/src/data.mjs), how to do it [see below](#how-to-update-core-js-compat-data), and the name of the polyfill module to [`packages/core-js-compat/src/modules-by-versions.mjs`](./packages/core-js-compat/src/modules-by-versions.mjs) (this data is also used for getting the default list of polyfills at bundling and generation indexes).
- Add it to entry points where it's required: directories [`packages/core-js/es`](./packages/core-js/es), [`packages/core-js/stable`](./packages/core-js/stable), [`packages/core-js/actual`](./packages/core-js/actual), [`packages/core-js/full`](./packages/core-js/full), [`packages/core-js/proposals`](./packages/core-js/proposals), [`packages/core-js/stage`](./packages/core-js/stage) and [`packages/core-js/web`](./packages/core-js/web).
- Add unit tests to [`tests/unit-global`](./tests/unit-global) and [`tests/unit-pure`](./tests/unit-pure).
Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=@core-js/compat&from=2014-11-18) [![core-js-pure downloads](https://img.shields.io/npm/dm/core-js-pure.svg?label=npm%20i%20core-js-pure)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=@core-js/compat&from=2014-11-18) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@core-js/bundle/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@core-js/bundle)
[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=@core-js/compat&from=2014-11-18) [![@core-js/pure downloads](https://img.shields.io/npm/dm/@core-js/pure.svg?label=npm%20i%20@core-js/pure)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=@core-js/compat&from=2014-11-18) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@core-js/bundle/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@core-js/bundle)

</div>

Expand Down Expand Up @@ -74,12 +74,12 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])

*Or use it without global namespace pollution*:
```js
import Promise from 'core-js-pure/actual/promise';
import Set from 'core-js-pure/actual/set';
import Iterator from 'core-js-pure/actual/iterator';
import from from 'core-js-pure/actual/array/from';
import flatMap from 'core-js-pure/actual/array/flat-map';
import structuredClone from 'core-js-pure/actual/structured-clone';
import Promise from '@core-js/pure/actual/promise';
import Set from '@core-js/pure/actual/set';
import Iterator from '@core-js/pure/actual/iterator';
import from from '@core-js/pure/actual/array/from';
import flatMap from '@core-js/pure/actual/array/flat-map';
import structuredClone from '@core-js/pure/actual/structured-clone';

Promise.resolve(42).then(it => console.log(it)); // => 42

Expand Down Expand Up @@ -211,7 +211,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
// global version
npm install --save [email protected]
// version without global namespace pollution
npm install --save core-js-[email protected]
npm install --save @core-js/[email protected]
// bundled global version
npm install --save @core-js/[email protected]
```
Expand Down Expand Up @@ -254,10 +254,10 @@ import "core-js/stable/set";
// only stable ES features required for `Set`:
import "core-js/es/set";
// the same without global namespace pollution:
import Set from "core-js-pure/full/set";
import Set from "core-js-pure/actual/set";
import Set from "core-js-pure/stable/set";
import Set from "core-js-pure/es/set";
import Set from "@core-js/pure/full/set";
import Set from "@core-js/pure/actual/set";
import Set from "@core-js/pure/stable/set";
import Set from "@core-js/pure/es/set";

// if you want to polyfill just required methods:
import "core-js/full/set/intersection";
Expand All @@ -284,8 +284,8 @@ import "core-js/stage/2";
#### CommonJS and prototype methods without global namespace pollution[](#index)
In the `pure` version, we can't pollute prototypes of native constructors. Because of that, prototype methods transformed into static methods like in examples above. But with transpilers, we can use one more trick - [bind operator and virtual methods](https://github.com/tc39/proposal-bind-operator). Special for that, available `/virtual/` entry points. Example:
```js
import fill from 'core-js-pure/actual/array/virtual/fill';
import findIndex from 'core-js-pure/actual/array/virtual/find-index';
import fill from '@core-js/pure/actual/array/virtual/fill';
import findIndex from '@core-js/pure/actual/array/virtual/find-index';

Array(10)::fill(0).map((a, b) => b * b)::findIndex(it => it && !(it % 8)); // => 4
```
Expand Down Expand Up @@ -373,12 +373,12 @@ By default, `@babel/preset-env` with `useBuiltIns: 'usage'` option only polyfill
#### `@babel/runtime`[](#index)

[`@babel/runtime`](https://babeljs.io/docs/plugins/transform-runtime/) with `corejs: 3` option simplifies work with `core-js-pure`. It automatically replaces usage of modern features from JS standard library to imports from the version of `core-js` without global namespace pollution, so instead of:
[`@babel/runtime`](https://babeljs.io/docs/plugins/transform-runtime/) with `corejs: 3` option simplifies work with `@core-js/pure`. It automatically replaces usage of modern features from JS standard library to imports from the version of `core-js` without global namespace pollution, so instead of:
```js
import from from 'core-js-pure/stable/array/from';
import flat from 'core-js-pure/stable/array/flat';
import Set from 'core-js-pure/stable/set';
import Promise from 'core-js-pure/stable/promise';
import from from '@core-js/pure/stable/array/from';
import flat from '@core-js/pure/stable/array/flat';
import Set from '@core-js/pure/stable/set';
import Promise from '@core-js/pure/stable/promise';

from(new Set([1, 2, 3, 2, 1]));
flat([1, [2, 3], [4, [5]]], 2);
Expand Down Expand Up @@ -3467,15 +3467,15 @@ function getIteratorMethod(value: any): Function | void;
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js-pure/es|stable|actual|full/is-iterable
core-js-pure/es|stable|actual|full/get-iterator
core-js-pure/es|stable|actual|full/get-iterator-method
@core-js/pure/es|stable|actual|full/is-iterable
@core-js/pure/es|stable|actual|full/get-iterator
@core-js/pure/es|stable|actual|full/get-iterator-method
```
[*Examples*](https://goo.gl/SXsM6D):
```js
import isIterable from 'core-js-pure/actual/is-iterable';
import getIterator from 'core-js-pure/actual/get-iterator';
import getIteratorMethod from 'core-js-pure/actual/get-iterator-method';
import isIterable from '@core-js/pure/actual/is-iterable';
import getIterator from '@core-js/pure/actual/get-iterator';
import getIteratorMethod from '@core-js/pure/actual/get-iterator-method';
let list = (function () {
return arguments;
Expand Down
2 changes: 1 addition & 1 deletion deno/corejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [![core-js-pure downloads](https://img.shields.io/npm/dm/core-js-pure.svg?label=npm%20i%20core-js-pure)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@core-js/bundle/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@core-js/bundle)
[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=core-js-compat&from=2014-11-18) [![@core-js/pure downloads](https://img.shields.io/npm/dm/@core-js/pure.svg?label=npm%20i%20@core-js/pure)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=core-js-compat&from=2014-11-18) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@core-js/bundle/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@core-js/bundle)

</div>

Expand Down
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/core-js-bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])

*Or use it without global namespace pollution*:
```js
import Promise from 'core-js-pure/actual/promise';
import Set from 'core-js-pure/actual/set';
import Iterator from 'core-js-pure/actual/iterator';
import from from 'core-js-pure/actual/array/from';
import flatMap from 'core-js-pure/actual/array/flat-map';
import structuredClone from 'core-js-pure/actual/structured-clone';
import Promise from '@core-js/pure/actual/promise';
import Set from '@core-js/pure/actual/set';
import Iterator from '@core-js/pure/actual/iterator';
import from from '@core-js/pure/actual/array/from';
import flatMap from '@core-js/pure/actual/array/flat-map';
import structuredClone from '@core-js/pure/actual/structured-clone';

Promise.resolve(42).then(it => console.log(it)); // => 42

Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/@core-js/compat.svg)](https://www.npmjs.com/package/@core-js/compat) [![@core-js/compat downloads](https://img.shields.io/npm/dm/@core-js/compat.svg?label=npm%20i%20@core-js/compat)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=@core-js/compat&from=2014-11-18)
[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/@core-js/compat.svg)](https://www.npmjs.com/package/@core-js/compat) [![@core-js/compat downloads](https://img.shields.io/npm/dm/@core-js/compat.svg?label=npm%20i%20@core-js/compat)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=@core-js/compat&from=2014-11-18)

</div>

Expand Down
14 changes: 7 additions & 7 deletions packages/core-js-pure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js-pure.svg)](https://www.npmjs.com/package/core-js-pure) [![core-js-pure downloads](https://img.shields.io/npm/dm/core-js-pure.svg?label=npm%20i%20core-js-pure)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=@core-js/compat&from=2014-11-18)
[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/@core-js/pure.svg)](https://www.npmjs.com/package/@core-js/pure) [![@core-js/pure downloads](https://img.shields.io/npm/dm/@core-js/pure.svg?label=npm%20i%20@core-js/pure)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=@core-js/compat&from=2014-11-18)

</div>

Expand Down Expand Up @@ -70,12 +70,12 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])

*Or use it without global namespace pollution*:
```js
import Promise from 'core-js-pure/actual/promise';
import Set from 'core-js-pure/actual/set';
import Iterator from 'core-js-pure/actual/iterator';
import from from 'core-js-pure/actual/array/from';
import flatMap from 'core-js-pure/actual/array/flat-map';
import structuredClone from 'core-js-pure/actual/structured-clone';
import Promise from '@core-js/pure/actual/promise';
import Set from '@core-js/pure/actual/set';
import Iterator from '@core-js/pure/actual/iterator';
import from from '@core-js/pure/actual/array/from';
import flatMap from '@core-js/pure/actual/array/flat-map';
import structuredClone from '@core-js/pure/actual/structured-clone';

Promise.resolve(42).then(it => console.log(it)); // => 42

Expand Down
2 changes: 1 addition & 1 deletion packages/core-js-pure/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "core-js-pure",
"name": "@core-js/pure",
"version": "3.33.0",
"description": "Standard library",
"keywords": [
Expand Down
14 changes: 7 additions & 7 deletions packages/core-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=@core-js/compat&from=2014-11-18)
[![fundraising](https://opencollective.com/core-js/all/badge.svg?label=fundraising)](https://opencollective.com/core-js) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=@core-js/pure&package=@core-js/compat&from=2014-11-18)

</div>

Expand Down Expand Up @@ -70,12 +70,12 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])

*Or use it without global namespace pollution*:
```js
import Promise from 'core-js-pure/actual/promise';
import Set from 'core-js-pure/actual/set';
import Iterator from 'core-js-pure/actual/iterator';
import from from 'core-js-pure/actual/array/from';
import flatMap from 'core-js-pure/actual/array/flat-map';
import structuredClone from 'core-js-pure/actual/structured-clone';
import Promise from '@core-js/pure/actual/promise';
import Set from '@core-js/pure/actual/set';
import Iterator from '@core-js/pure/actual/iterator';
import from from '@core-js/pure/actual/array/from';
import flatMap from '@core-js/pure/actual/array/flat-map';
import structuredClone from '@core-js/pure/actual/structured-clone';

Promise.resolve(42).then(it => console.log(it)); // => 42

Expand Down
2 changes: 1 addition & 1 deletion scripts/build-indexes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ await generateNamespaceIndex('stable', /^(?:es|web)\./);
await generateNamespaceIndex('full', /^(?:es|esnext|web)\./);

await generateTestsIndex('unit-global', 'core-js');
await generateTestsIndex('unit-pure', 'core-js-pure');
await generateTestsIndex('unit-pure', '@core-js/pure');

echo(chalk.green('indexes generated'));
1 change: 1 addition & 0 deletions scripts/downloads-by-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const [core, pure, bundle] = await Promise.all([
getStat('core-js'),
ALL && getStat('core-js-pure'),
ALL && getStat('core-js-bundle'),
ALL && getStat('@core-js/pure'),
ALL && getStat('@core-js/bundle'),
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/entries/unit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function load(...components) {
return require(path);
}

for (PATH of ['core-js-pure', 'core-js']) {
for (PATH of ['@core-js/pure', 'core-js']) {
for (const NS of ['es', 'stable', 'actual', 'full']) {
let O;
ok(load(NS, 'global-this').Math === Math);
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import defineProperty from 'core-js-pure/es/object/define-property';
import defineProperty from '@core-js/pure/es/object/define-property';

export const GLOBAL = Function('return this')();

Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Promise from 'core-js-pure/es/promise';
import ITERATOR from 'core-js-pure/es/symbol/iterator';
import ASYNC_ITERATOR from 'core-js-pure/es/symbol/async-iterator';
import Promise from '@core-js/pure/es/promise';
import ITERATOR from '@core-js/pure/es/symbol/iterator';
import ASYNC_ITERATOR from '@core-js/pure/es/symbol/async-iterator';

export function is(a, b) {
// eslint-disable-next-line no-self-compare -- NaN check
Expand Down
Loading

0 comments on commit 3886ffe

Please sign in to comment.