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

core-js@3 #325

Merged
merged 281 commits into from
Jun 7, 2018
Merged

core-js@3 #325

merged 281 commits into from
Jun 7, 2018

Conversation

zloirock
Copy link
Owner

@zloirock zloirock commented Aug 9, 2017

Features:

  • Add new features:
  • Improve existing features:
    • Add triggering unhandled Promise rejection events (instead of only global handlers), #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.
    • Correct Typed Arrays prototypes chain, related #378.
    • Make the internal state of polyfilled features completely unobservable, #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.
  • Update standard features and proposals:
  • 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.
  • Fix import of property before constructor which should contain this property, #262.
  • Fix some cases of IE11 WeakMap frozen keys fallback, #384.
  • Fix non-enumerable integer keys issue because of Nashorn ~ JDK8 bug, #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.
  • 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.

Documentation:

  • Document API changes
  • For each feature
    • Rewrite signatures of features to something like Web IDL / TypeScript / Flow
    • Add description
    • Add link to MDN
    • Add link to compat table
    • Add info about fixed bugs of engines
  • Add CONTRIBUTING.md
  • Add some babel-related info to Usage section (can be postponed):
    • About @babel/polyfill
    • About @babel/runtime
    • About @babel/preset-env
  • Add a note about compatibility with some popular tools

Also:

  • Add PRs to babel@7 (after publishing a pre-release of core-js@3):
    • Update @babel/polyfill
    • Update @babel/runtime
    • Update @babel/preset-env

The list is not completely finished.

// https://github.com/tc39/proposal-global
var $export = require('./_export');

$export($export.S, 'System', { global: require('./_global') });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to hold off on removing System.global until tc39/proposal-global#20 is cleared up.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aciccarello maybe. I'm watching this issue, but global is already on stage 3.

@zloirock
Copy link
Owner Author

core-js@3.0.0-beta.2 is available.

if (result.e) reject(result.v);
return capability.promise;
}
});
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jasonwilliams @mathiasbynens internal logic is similar to Promise.all. Any comments?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zloirock looks good to me, i don't see any issues there.

@zloirock
Copy link
Owner Author

zloirock commented Jun 7, 2018

core-js@3.0.0-beta.3 is available.

@AlexWayfer
Copy link
Contributor

AlexWayfer commented Jun 7, 2018

Undeniably, great work! Any plans about release date?… I'm not pushing, just for personal planning.

@zloirock
Copy link
Owner Author

zloirock commented Jun 7, 2018

@AlexWayfer all that I wanna see in core-js@3 already here. Left some minor internal changes, RC, work on documentation and a release article. I can't say the concrete date.

@AlexWayfer
Copy link
Contributor

Yep, okay. Thank you. I'll wait!

@zloirock
Copy link
Owner Author

zloirock commented Jun 7, 2018

I think that it's time to merge it with master.

@Gokulanarayanan
Copy link

Does Angular 6 supports core-js 3.x versions

@zloirock
Copy link
Owner Author

zloirock commented Aug 1, 2023

@Gokulanarayanan you could ask the Angular team - I'm not an expert in Angular versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants