Skip to content

Latest commit

 

History

History
112 lines (97 loc) · 8.07 KB

CONTRIBUTING.md

File metadata and controls

112 lines (97 loc) · 8.07 KB

Contributing

Contributions are always welcome. If you don't know how you can help, you can check issues or ask @zloirock.

How to add a new polyfill

How to update core-js-compat data

For updating core-js-compat data:

  • If you want to add a new data for a browser, run in this browser tests/compat/index.html (tests and results for the actual release are available at http://zloirock.github.io/core-js/compat/) and you will see what core-js modules are required for this browser.

compat-table

  • If you want to add new data for NodeJS, run npm run compat-node with the installed required NodeJS version and you will see the results in the console. Use npm run compat-node -- json if you want to get the result as JSON.
  • If you want to add new data for Deno, run npm run compat-deno with the installed required Deno version and you will see the results in the console. Use npm run compat-deno -- json if you want to get the result as JSON.
  • If you want to add new data for Bun, run npm run compat-bun with the installed required Bun version and you will see the results in the console.
  • If you want to add new data for Rhino, set the required Rhino version in compat-rhino-prepare NPM script in package.json, run npm run compat-rhino and you will see the results in the console.
  • If you want to add new data for Hermes, run npm run compat-hermes -- YOR_PATH_TO_HERMES and you will see the results in the console.
  • After getting this data, add it to packages/core-js-compat/src/data.mjs.
  • If you want to add new mapping (for example, to add a new iOS Safari version based on Safari or NodeJS based on Chrome), add it to packages/core-js-compat/src/mapping.mjs.
engine how to run tests base data inherits from mandatory check mapping for a new version
android browser runner chrome
bun bun runner required
chrome browser runner required
deno deno runner chrome (only ES) non-ES features required
edge browser runner ie, chrome required
electron browser runner chrome required
firefox browser runner required
hermes hermes runner required
ie browser runner required
ios browser runner safari if inconsistent (!= safari)
node node runner chrome (only ES) non-ES features required
oculus browser runner android (-> chrome) required
opera browser runner chrome if inconsistent (!= chrome - 14)
opera_mobile browser runner opera, chrome required
phantom browser runner safari
rhino rhino runner required
safari browser runner required
samsung browser runner chrome required

If you have no access to all required browsers / versions of browsers, use Sauce Labs, BrowserStack or Cloud Browser.

Style and standards

The coding style should follow our .eslintrc. You can test it by calling npm run lint. Different places have different syntax and standard library limitations:

  • Polyfill implementations should use only ES3 syntax and standard library, they should not use other polyfills from the global scope.
  • Unit tests should use the modern syntax with our minimalistic Babel config. Unit tests for the pure version should not use any modern standard library features.
  • Tools, scripts and tests, performed in NodeJS, should use only the syntax and the standard library available in NodeJS 8.

File names should be in the kebab-case. Name of polyfill modules should follow the naming convention namespace.subnamespace-where-required.feature-name, for example, esnext.set.intersection. The top-level namespace should be es for stable ECMAScript features, esnext for ECMAScript proposals and web for other web standards.

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
  • The global version unit tests:
    $ npm run test-unit-global-standalone
  • The pure version unit tests:
    $ npm run test-unit-pure-standalone
  • Promises/A+ and ES6 Promise test cases:
    $ npm run test-promises-standalone
  • ECMAScript Observable test case:
    $ npm run test-observables-standalone
  • CommonJS entry points tests:
    $ npm run test-entries-standalone
  • If you want to run tests in a certain browser, at first, you should build packages and test bundles:
    $ npm run bundle-standalone
  • For running the global version of the unit test case, use this file:
    tests/tests.html
    
  • For running the pure version of the unit test case, use this file:
    tests/pure.html