18 Commits

Author SHA1 Message Date
Nicolò Ribaudo
7127330f02
Allow using preset-env with newer versions of compat-data (#11201)
* Use ~ for preset-env's @babel/compat-data dependency

* Revert "Use ~ for preset-env's @babel/compat-data dependency"

This reverts commit e7d57c7894095d381670cddfbbce06bd2a480a32.

* Allow using `preset-env` with newer versions of `compat-data`
2020-03-05 02:35:31 +01:00
Nicolò Ribaudo
04354d1556
Extract targets parser and compat data from preset-env (#10899)
* Extract targets parser and compat data from preset-env

* Review by Jùnliàng

* isItemRequired -> targetsSupported

* Export isRequired
2020-01-10 03:15:20 +01:00
Nicolò Ribaudo
30f3b07ebf Replace custom "findSuggestion" function with "levenary" (#10924)
* Replace custom "findSuggestion" function with "levenary"

* Update
2019-12-26 00:45:26 +01:00
Adam Ramberg
fcb77de901 [preset-env] Include / exclude module plugins properly (#10218)
* Include / exclude module plugins properly

* Use filter-items to excl / incl module plugins

* Move transform selection to getModulesPluginNames

* Remove unnecessary spread operator

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* Adjust tests to changes in #10218
2019-09-05 15:58:29 +02:00
Matthew Schupack
45ca6751fa use console.warn for warning (#9992)
* use console.warn for warning

* fix tests
2019-05-18 00:36:18 +02:00
Nicolò Ribaudo
de7dd7f015
Mark the core-js warning as such (#9732) 2019-03-21 10:38:21 +01:00
Brian Ng
7f8ded9851
Tweak preset-env corejs/useBuiltIns warning and error messages (#9716) 2019-03-20 19:47:30 -05:00
Denis Pushkarev
3303b079c5 Update to core-js@3 (#7646)
### `@babel/runtime`
- Added `@babel/runtime-corejs3` package and `corejs: 3` options to `@babel/plugin-transform-runtime`.
- Added support of instance methods, fixes #8928.
- Added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for support all proposals polyfills from `core-js`.
- Used separate directories in runtime for `core-js` entry points with proposals and without.
- Used `get-iterator-method` helper for getting iterators, fixes #2500.
- As a cheap bonus, added support of IE8- (except some cases of `regenerator`).

### `@babel/polyfill`
- Should be deprecated in favor of separate usage required features from `core-js` and `regenerator-runtime` with an informative message.

### `@babel/preset-env`
- Uses for built-ins data from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) instead of `compat-table` since information from `compat-table` [is not enough](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat).
- `useBuilIns` now requires direct setting of `corejs` version option, without it will be used `2` by default and shown deprecation warning.
- Added support of minor `core-js` versions for simplify updating in the future.
- For preventing some order-related problems, polyfills in the both `core-js@3` plugins added on `post` stage in the order of `core-js-compat` data.
- Divided plugins and polyfills parts of `preset-env`, instead of 2 internal plugins for adding polyfills, we have 6: usage and entry versions of plugins for `core-js@2`, ### Current state:
`core-js@3`, `regenerator-runtime`.
- Added support `samsung` target (for Samsung Internet) since `core-js-compat` and `compat-table` now contains mapping for this, fixes #6602.

#### `useBuilIns: entry` with `corejs: 3`
- No longer transforms `@babel/polyfill`.
- Transforms **all possible** `core-js` entry points to import of related modules (based on data from [`core-js-compat`](https://unpkg.com/core-js-compat@3.0.0-beta.15/entries.json)).
- Since of this, we no longer need `shippedProposals` / `proposals` flags with `useBuilIns: entry`.
- Removes `regenerator-runtime/runtime` import where it's not required.

#### `useBuilIns: usage` with `corejs: 3`
- In addition to `shippedProposals`, added flag `proposals`  (in `corejs: { version: 3, proposals: true }` format) for polyfill all proposals from `core-js`.
- Fixed list of dependencies in built-in definitions.
- Improved the way of determination method / built-in name and source of this method.
- Adds import of required polyfills on `MemberExpression`, `ObjectPattern`, `in` operator.
- Adds import of required polyfills on access to global object properties.
- Adds import of all required common iterators on all syntax features which use iterators protocol (`for-of`, destructuring, spread, `yield` delegation, etc.).
- Adds import of promises on syntax features which use promises (async functions/generators, dynamic import, etc.), fixes #9250, #7402, etc.

### `core-js@2` stuff
I didn't want to tough `core-js@2`-related stuff, however
- Fixed some serious errors in definitions which breaks `Object.getOwnPropertySymbols`, `Symbol.toStringTag` logic, `Promise#finally`, `Array#forEach`, etc.
- `Array#flatMap` and trim methods moved to stable features as a part of ES2019 and loaded by deprecated `@babel/polyfill` and `@babel/preset-env` with `corejs: 2` option.
2019-03-19 21:07:45 +01:00
Brian Ng
ea1c436ea1
Fix handling scoped packages in preset-env include/exclude options (#9219) 2018-12-27 09:54:28 -06:00
Artem Yavorsky
4249dbc8ea Add browserslist 4 support. (#8509) 2018-08-23 20:09:18 -05:00
Logan Smyth
d60c5e1736 Expose caller.supportsStaticESM as a flag to change preset-env behavior. 2018-08-20 10:27:55 -07:00
Serhii Nanovskyi
3de053cc6c Validate @babel/preset-env options (#8031) 2018-06-09 18:38:14 -05:00
Brian Ng
f699f1bbbf
flow@0.73.0 (#8032) 2018-05-25 16:53:23 -05:00
Justin Ridgewell
2afe9404fe
Use Object Spread Syntax (#7777)
* Use Object Spread Syntax

* Nits
2018-04-23 21:44:27 -04:00
Michał Pierzchała
81c1b49f6a Disable flow on transformClass, fix preset-env errors (#7605) 2018-03-20 18:42:11 -05:00
Amin Marashi
8eee435cd6 Add RegExp support to include/exclude preset-env options (#7242)
* Add support for RegExp includes/excludes

* Keep the plugin order

* Detect invalid modules in regexp

* Add more tests for regexp

* Cover builtins, and unnormalized in the RegExp tests

* Remove babel-plugin- in all positions

* Change babel-plugin- prefix to string

* Add a test for the same module in include/exclude

* Handle partial matches explicitly

* Remove extra valid regexp check

* Optimise validation of plugins

* Optimise selecting the plugins

* Fix undefined include/exclude option

* Update documentation to reflect the new include matching

* Fix typo

* Apply reviews

Use regexp.test instead of string.match (slower)

Define flatten helper

Do not normalize babel-plugin anywhere in the string
2018-03-18 15:54:43 +01:00
Guy Bedford
f004972625 Ensure babel-preset-env targets input object is not mutated (#7438) 2018-02-27 08:46:24 -06:00
Henry Zhu
70361f1200 Remove the experimental folder 2017-11-21 20:03:16 -05:00