Skip to content

Commit

Permalink
Merge pull request #325 from zloirock/v3
Browse files Browse the repository at this point in the history
core-js@3
  • Loading branch information
zloirock authored Jun 7, 2018
2 parents de5ed6f + 65c966d commit 2fe6644
Show file tree
Hide file tree
Showing 3,569 changed files with 32,847 additions and 102,544 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
23 changes: 23 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// use transforms which does not use ES5+ builtins
plugins: [
['transform-es3-member-expression-literals'],
['transform-es3-property-literals'],
// use it instead of webpack es modules for support engines without descriptors
['transform-es2015-modules-commonjs', { loose: true }],
['transform-es2015-arrow-functions'],
['transform-es2015-block-scoped-functions'],
['transform-es2015-block-scoping'],
['transform-es2015-classes', { loose: true }],
['transform-es2015-computed-properties', { loose: true }],
['transform-es2015-destructuring', { loose: true }],
['transform-es2015-literals'],
['transform-es2015-parameters'],
['transform-es2015-shorthand-properties'],
['transform-es2015-spread', { loose: true }],
['transform-es2015-template-literals', { loose: true, spec: true }],
['transform-exponentiation-operator'],
['transform-for-of-as-array'],
['check-es2015-constants']
]
}
8 changes: 4 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules/**
build/index.js
client/**
tests/**
node_modules/
/packages/core-js-bundle/
/packages/core-js-pure/override/
/tests/bundles/
!**/.eslintrc.js
751 changes: 470 additions & 281 deletions .eslintrc.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ node_modules/
*.bak
*.swp

Thumbs.db

Desktop.ini
/packages/core-js/LICENSE
/packages/core-js-builder/LICENSE
/packages/core-js-bundle/LICENSE
/packages/core-js-bundle/index.js
/packages/core-js-bundle/minified.js
/packages/core-js-bundle/minified.js.map
/packages/core-js-pure/es/
/packages/core-js-pure/features/
/packages/core-js-pure/internals/
/packages/core-js-pure/modules/
/packages/core-js-pure/proposals/
/packages/core-js-pure/stage/
/packages/core-js-pure/web/
/packages/core-js-pure/index.js
/packages/core-js-pure/LICENSE
/tests/bundles/
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- '10'
- '8'
- '6'

Expand Down
48 changes: 48 additions & 0 deletions .webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
const resolve = require('path').resolve;

module.exports = {
options: {
mode: 'none',
module: {
rules: [{
test: /\.js$/,
exclude: /modules/,
use: {
loader: 'babel-loader',
},
}],
},
resolve: {
alias: {
'core-js': resolve(__dirname, './packages/core-js'),
'core-js-pure': resolve(__dirname, './packages/core-js-pure'),
},
},
node: {
global: false,
process: false,
setImmediate: false,
},
stats: false,
output: {
path: resolve(__dirname, './tests/bundles'),
},
},
helpers: {
entry: './tests/helpers/qunit-helpers.js',
output: { filename: 'qunit-helpers.js' },
},
pure: {
entry: './tests/pure/index.js',
output: { filename: 'pure.js' },
},
tests: {
entry: './tests/tests/index.js',
output: { filename: 'tests.js' },
},
'promises-aplus-tests': {
entry: 'promises-aplus-tests/lib/testFiles.js',
output: { filename: 'promises-aplus.js' },
},
};
126 changes: 125 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,128 @@
## Changelog
##### 3.0.0
- Features
- Add new features:
- `Symbol#description` ([stage 3 proposal](https://tc39.github.io/proposal-Symbol-description/))
- `Object.fromEntries` ([stage 2 proposal](https://github.com/tc39/proposal-object-from-entries))
- New `Set` methods ([stage 2 proposal](https://github.com/tc39/proposal-set-methods))
- `Set#difference`
- `Set#intersection`
- `Set#symmetricDifference`
- `Set#union`
- Getting last item from `Array` ([stage 1 proposal](https://github.com/keithamus/proposal-array-last))
- `Array#lastItem`
- `Array#lastIndex`
- `String#replaceAll` ([stage 1 proposal](https://github.com/psmarshall/string-replace-all-proposal))
- `String#codePoints ` ([stage 1 proposal](https://github.com/RReverser/string-prototype-codepoints))
- New collections methods ([stage 1 proposal](https://github.com/Ginden/collection-methods))
- `Map.groupBy`
- `Map.keyBy`
- `Map#filter`
- `Map#mapKeys`
- `Map#mapValues`
- `Map#merge`
- `Set#addAll`
- `Set#deleteAll`
- `Set#every`
- `Set#filter`
- `Set#find`
- `Set#join`
- `Set#map`
- `Set#reduce`
- `Set#some`
- `compositeKey` and `compositeSymbol` methods from ([richer keys stage 1 proposal](https://github.com/bmeck/proposal-richer-keys/tree/master/compositeKey))
- `Number.fromString` ([stage 1 proposal](https://github.com/mathiasbynens/proposal-number-fromstring))
- `Symbol.patternMatch` ([for stage 1 pattern matching proposal](https://github.com/tc39/proposal-pattern-matching))
- `Promise.allSettled` ([stage 0 proposal](https://github.com/jasonwilliams/proposal-promise-allSettled))
- `.forEach` method to iterable DOM collections ([#329](https://github.com/zloirock/core-js/issues/329))
- Improve existing features:
- Add triggering unhandled `Promise` rejection events (instead of only global handlers), [#205](https://github.com/zloirock/core-js/issues/205).
- Add support of `@@isConcatSpreadable` to `Array#concat`.
- Add support of `@@species` to `Array#{concat, filter, map, slice, splice}`.
- Correct iterators prototypes chain, related [#261](https://github.com/zloirock/core-js/issues/261).
- Correct Typed Arrays prototypes chain, related [#378](https://github.com/zloirock/core-js/issues/378).
- Make the internal state of polyfilled features completely unobservable, [#146](https://github.com/zloirock/core-js/issues/146).
- Add validation of receiver's internal class to missed non-generic methods.
- Fix descriptors of global properties.
- In the version without global pollution, if `Object#toString` does not support `@@toStringTag`, add to wrapped prototypes own `toString` method with `@@toStringTag` logic, see [#199](https://github.com/zloirock/core-js/issues/199).
- Update standard features and proposals:
- Remove mongolian vowel separator (U+180E) from the list of whitespaces for methods like `String#trim` (ES6 -> ES7)
- Update [`Observable`](https://github.com/tc39/proposal-observable) (#257, #276, etc.)
- Update `Array#flatten` -> `Array#flat` and `Array#flatMap` and move to the stage 3
- Update `String#matchAll` (mainly [this PR](https://github.com/tc39/proposal-string-matchall/pull/17)) and move to the stage 3
- Update `.name` properties of `String#{trimStart, trimEnd , trimLeft, trimRight}`, move to the stage 3
- Mark ES2016, ES2017 and ES2018 features as stable:
- `Array#includes` and `%TypedArray%#includes`
- `Object.values` and `Object.entries`
- `Object.getOwnPropertyDescriptors`
- `String#padStart` and `String#padEnd`
- `Promise#finally`
- `Symbol.asyncIterator`
- `Object#__(define|lookup)[GS]etter__`
- Remove obsolete features:
- `Error.isError` (withdrawn)
- `System.global` (replaced by `global`)
- `Map#toJSON` and `Set#toJSON` (rejected)
- `RegExp.escape` (rejected)
- `Reflect.enumerate` (removed from the spec)
- Unnecessary iteration methods from `CSSRuleList`, `MediaList`, `StyleSheetList`
- **No more non-standard features**, finally removed:
- `Dict`
- `Object.{classof, isObject, define, make}`
- `Function#part`
- `Number#@@iterator`
- `String#{escapeHTML, unescapeHTML}`
- `delay`
- Add `.sham` flag to features which can't be properly polyfilled and / or not recommended for usage:
- `Symbol` constructor - we can't add new primitives. `Object.prototype` accessors too expensive.
- `Object.{create, defineProperty, defineProperties, getOwnPropertyDescriptor, getOwnPropertyDescriptos}`, `Reflect.{defineProperty, getOwnPropertyDescriptor}` can't be properly polyfilled without descriptors support.
- `Object.{freeze, seal, preventExtensions}`, `Reflect.preventExtensions` can't be properly polyfilled in ES3 environment.
- `Object.getPrototypeOf` can be deceived in ES3 environment.
- `Reflect.construct` can't be polyfilled for a correct work with `newTarget` argument on built-ins.
- Typed Array constructors polyfill is quite correct but too expensive.
- Bug and compatibility fixes:
- Fix deoptimisation of iterators in V8, [#377](https://github.com/zloirock/core-js/issues/377).
- Fix import of property before constructor which should contain this property, [#262](https://github.com/zloirock/core-js/issues/262).
- Fix some cases of IE11 `WeakMap` frozen keys fallback, [#384](https://github.com/zloirock/core-js/issues/384).
- Fix non-enumerable integer keys issue because of Nashorn ~ JDK8 bug, [#389](https://github.com/zloirock/core-js/issues/389).
- Repository:
- Change `core-js` repository structure to monorepo with packages in `/packages/` directory.
- Clean-up it, remove all possible duplicates, generated files, etc.
- Packages:
- **Extract a version without global namespace pollution to a separate `core-js-pure` package (replacement for `core-js/library`).**
- **Leave only one pair of bundles (global, with all polyfills) and move it to `core-js-bundle` package.**
- Remove bundling logic from `core-js` package, leave it only in `core-js-builder` package.
- Clean-up packages.
- Because of all approaches, **reduce size of packages from ~2mb for `core-js@2` to**:
- **~400kb for `core-js` package**
- **~340kb for `core-js-pure` package**
- Finally remove `bower.json`
- CommonJS API, namespaces:
- Move `core-js/library` to separate `core-js-pure` package.
- Because of removing all non-standard features, we no longer need `core-js/shim` entry point, replace it just with `core-js`.
- Move all features from ES5, ES2015, ES2016, ES2017 and ES2018 to one namespace for stable ES - it's available as `core-js/es`, all those features in `modules` folder has `es.` prefix.
- Change prefix for ES proposals from `es7.` to `esnext.`, they no longer available in `core-js/es7`, use `core-js/stage/*` instead of that.
- Rename `core-js(/library)/fn` to `core-js(-pure)/features` for improve readability.
- Add `/proposals/` entry points for allow include all features from one proposal (for example, `core-js/proposals/reflect-metadata`).
- Allow more granular inclusion of features from `/es/` path (for example, `core-js/es/array/from`).
- Split typed arrays polyfills. Now you can, for example, load only required method (for example, `core-js/es/typed-array/from`).
- Extract well-known symbols definition from `es.symbol` module for loading only required features, for example, in MS Edge.
- Rename `web.dom` namespace to `web.dom-collections`.
- Rename `es6.regexp.{match, replace, search, split}` -> `es.string.{match, replace, search, split}` - mainly it's fixes / adding support of well-known symbols to string methods, only in second place adding related methods to regexp prototype.
- Relax `/modules/` directory by moving internal modules to `/internals/` directory.
- Remove deprecated array entry points: `core-js(/library)/fn/array/{pop, push, reverse, shift, unshift}`.
- `core` object no longer available in the global version, entry points which previously returned it now returns `global` object. Also, don't set `global.core` object.
- Add some missing entry points.
- Tools, tests, code quality:
- Refactor source code for improving readability.
- **Get rid of LiveScript**, usage another language in JS standard library looks strange and impedes usage of tools like ESLint:
- Rewrite tests to JS.
- Rewrite scripts to JS.
- Use for tests Babel with minimalistic config which should work anywhere.
- Use ESLint on the code of tests and tools.
- Remove an option for generation bundle of a version without global namespace pollution from `core-js-builder` - now it's an odd use case.
- Remove UMD wrapper from the code, generated by `core-js-builder` bundles - we don't need it for a global polyfill.

##### 2.5.7 - 2018.05.26
- Get rid of reserved variable name `final`, related [#400](https://github.com/zloirock/core-js/issues/400)

Expand All @@ -15,7 +139,7 @@
- Fixed some cases of iterators feature detection, [#368](https://github.com/zloirock/core-js/issues/368)
- Fixed manually entered NodeJS domains issue in `Promise`, [#367](https://github.com/zloirock/core-js/issues/367)
- Fixed `Number.{parseInt, parseFloat}` entry points
- Fixed `__(define|lookup)[GS]etter__` import in the `library` version
- Fixed `__(define|lookup)[GS]etter__` export in the `library` version

##### 2.5.3 - 2017.12.12
- Fixed calling `onunhandledrejectionhandler` multiple times for one `Promise` chain, [#318](https://github.com/zloirock/core-js/issues/318)
Expand Down
78 changes: 78 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Contributing

Contributions are always welcome. If you don't know what how you can help, you can check [issues](https://github.com/zloirock/core-js/issues) or ask @zloirock.

## How to add a new polyfill

- The polyfill implementation should be added to the [`packages/core-js/modules`](./packages/core-js/modules) directory.
- If the implementation for the `pure` version should differ from the global version, it should be added to [`packages/core-js-pure/modules-pure`](./packages/core-js-pure/modules-pure) directory. The rest of `core-js-pure` will be copied from `core-js` package.
- For export the polyfill, in almost all cases should be used `_export` helper.
- The polyfill should be added to the [list of polyfills](./packages/core-js-builder/config.js) and to entry points, where it's required: [`packages/core-js/index.js`](./packages/core-js/index.js), directories [`packages/core-js/features`](./packages/core-js/features), [`packages/core-js/es`](./packages/core-js/es), [`packages/core-js/esnext`](./packages/core-js/esnext) and [`packages/core-js/web`](./packages/core-js/web).
- Unit tests for the polyfill should be added to [`tests/tests`](./tests/tests) and [`tests/pure`](./tests/pure).
- All new entry points should be added to [the test of entry points](./tests/commonjs).
- Add it to [README.md](./README.md).

## Style and standards

Coding style should follow our [`.eslintrc`](./.eslintrc.js). You can test it by calling [`npm run eslint`](#testing). Different places have different syntax and standard library limitations:
- Polyfill implementations should use only ES3 syntax and standard library. Polyfills should not use another polyfill from the global namespace.
- In unit tests should be used modern syntax with our [minimalistic Babel config](./.babelrc). Unit tests for the `pure` version should not use any modern standard library features.
- In building tools and tests, performed in Node.js, should be used only available in Node.js 4 syntax and standard library.

File names should be in kebab-case. Name of files with polyfills should follow naming convention `namespace.subnamespase-where-required.feature-name`, for example, `esnext.promise.try`. Top level namespace could be `es` for stable ECMAScript features, `esnext` for ECMAScript proposals, `web` for another web standards and `core` for helpers. Internal `core-js` modules should use `_` prefix.

## Testing

Before testing, you should install dependencies:
```
$ npm i
```
You can run all tests by
```
$ npm run test
```
You can run parts of the test case separately:
- Linting:
```
$ npm run lint
```
- Global version unit tests:
```
$ npm run unit-tests
```
- `pure` version unit tests:
```
$ npm run unit-tests-pure
```
- [Promises/A+ test case](https://github.com/promises-aplus/promises-tests):
```
$ npm run promises-tests
```
- [ECMAScript `Observable` test case](https://github.com/tc39/proposal-observable):
```
$ npm run observables-tests
```
- CommonJS entry points tests:
```
$ npm run commonjs-tests
```
If you want to run tests in a certain browser at first you should build packages and test bundles:
```
$ npm run build
```
- For running global version unit test case use this file:
```
tests/tests.html
```
- For running the `pure` version unit test case use this file:
```
tests/pure.html
```
- Before running [Promises/A+ test case](https://github.com/promises-aplus/promises-tests) in the browser you should bundle it:
```
$ npm run bundle-promises-tests
```
and after that use this file:
```
tests/promises-aplus.html
```
Loading

0 comments on commit 2fe6644

Please sign in to comment.