source: imaps-frontend/node_modules/@babel/preset-env/CONTRIBUTING.md

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.6 KB
Line 
1# Contributing
2
3## Adding a new plugin or polyfill to support (when approved in the next ECMAScript version)
4
5### Update [`plugin-features.js`](https://github.com/babel/babel/blob/main/packages/babel-compat-data/scripts/data/plugin-features.js)
6
7*Example:*
8
9If you were going to add `**` which is in ES2016:
10
11Find the relevant entries on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-exponentiation_(**)_operator):
12
13`exponentiation (**) operator`
14
15Find the corresponding babel plugin:
16
17`@babel/plugin-transform-exponentiation-operator`
18
19And add them in this structure:
20
21```js
22// es2016
23"@babel/plugin-transform-exponentiation-operator": {
24 features: [
25 "exponentiation (**) operator",
26 ],
27},
28```
29
30### Update data for `core-js@2` polyfilling
31
32*Example:*
33
34In case you want to add `Object.values` which is in ES2017:
35
36Find the relevant feature and subfeature on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-Object_static_methods_Object.values)
37and split it with `/`:
38
39`Object static methods / Object.values`
40
41Find the corresponding module on [`core-js@2`](https://github.com/zloirock/core-js/tree/v2/modules):
42
43`es7.object.values.js`
44
45Find required ES version in [`corejs2-built-in-features.js`](https://github.com/babel/babel/blob/main/packages/babel-preset-env/data/corejs2-built-in-features.js) and add the new feature:
46
47```js
48const es = {
49 //...
50 "es7.object.values": "Object static methods / Object.values"
51}
52```
53
54If you want to transform a new built-in by `useBuiltIns: 'usage'`, add mapping to related `core-js` modules to [this file](https://github.com/babel/babel/blob/main/packages/babel-preset-env/polyfills/corejs2/built-in-definitions.js).
55
56### Update data for `core-js@3` polyfilling
57
58Just update the version of [`core-js-compat`](https://github.com/zloirock/core-js/tree/main/packages/core-js-compat) in dependencies.
59
60If you want to transform a new built-in by `useBuiltIns: 'usage'`, add mapping to related [`core-js`](https://github.com/zloirock/core-js/tree/main/packages/core-js/modules) modules to [this file](https://github.com/babel/babel/blob/main/packages/babel-preset-env/polyfills/corejs3/built-in-definitions.js).
61
62If you want to mark a new proposal as shipped, add it to [this list](https://github.com/babel/babel/blob/main/packages/babel-preset-env/polyfills/corejs3/shipped-proposals.js).
63
64### Update [`plugins.json`](https://github.com/babel/babel/blob/main/packages/babel-preset-env/data/plugins.json)
65
66Until `compat-table` is a standalone npm module for data we are using the git commit in `packages/babel-compat-data/scripts/download-compat-table.sh`
67
68`COMPAT_TABLE_COMMIT=[latest-commit-hash]`,
69
70So we update and then run `npm run build-data`. If there are no changes, then `plugins.json` will be the same.
71
72## Tests
73
74### Running tests
75See general [CONTRIBUTING.md](https://github.com/babel/babel/blob/main/CONTRIBUTING.md#running-lintingtests).
76
77### Writing tests
78
79#### General
80
81All the tests for `@babel/preset-env` exist in the `test/fixtures` folder. The
82test setup and conventions are exactly the same as testing a Babel plugin, so
83please read our [documentation on writing tests](https://github.com/babel/babel/blob/main/CONTRIBUTING.md#babel-plugin-x).
84
85#### Testing the `debug` option
86
87Testing debug output to `stdout` is similar. Under the `test/debug-fixtures`,
88create a folder with a descriptive name of your test, and add the following:
89
90* Add a `options.json` file (just as the other tests, this is essentially a
91`.babelrc`) with the desired test configuration (required)
92* Add a `stdout.txt` file with the expected debug output. For added
93convenience, if there is no `stdout.txt` present, the test runner will
94generate one for you.
Note: See TracBrowser for help on using the repository browser.