* Allow rest/spread on polyfilled or builtin iterables when `Symbol` unsupported
Currently, when `Symbol` is not supported, we allow using rest/spread with:
- arrays
- strings
- arguments
With this PR, it will be also possible to use it with
- maps
- sets
- binary arrays
While in old browsers es6 builtins would still need to be polyfilled, it's way
easier to polyfill them because `Symbol` cannot be reliably polyfilled.
I didn't use `instanceof` becase:
- it doesn't work with polyfills not attatched to the global scope
- when using Babel to load polyfills, it would force the inclusion of `Map` and `Set` polyfills even if they are not used
Downside: the current approach of relying on `toString || construcor.name` doesn't work with subclasses.
* Don't use Array.from for array-like objects
* Extract for-of iterator handling to a helper
Dis greatly recudes the code size when for-of is used multiple times across the
codebase. Also, makes it easier to read what's happening in a compiled loop.
* Unify spec and loose code
* Legacy implementation fallback
* Update tmp var name
* Updates from review and after rebase
This PR allows legacy decorators to work with strict class fields, which
are now stage 3 and have shipped in a number of browsers. Allowing this will
allow users of the legacy transform (which is currently recommended by the
champions of the decorator proposal) to use the proper class field semantics
for non-decorated fields, which should help prevent breakage later on.
This change is not a breaking change, since users had to explicitly opt into
loose mode in class fields before. This just gives them the option to remove
that opt-in.
* fix: [#10561] _interopRequireWildcard should cache object only
* fix: narrow down cache restriction to object/function type
* test: add interop require null module case
* Improves the logic to import objects in helpers
* Modified to work with more cases.
* Modified by considering exception cases
* Fixed not using bundler's polyfill
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
* Updated test output files
* Changes to cache logic
* Modified to use if statement
* Better tdz tests
- Use jest's expect.toThrow/expect.not.toThrow
- Add input/output tests
* Fix basic tdz (a = 2; let a)
Fixes#6848
* Make _guessExecutionStatusRelativeTo more robust
* Add tests
* Return less "unkown" execution status
* "function" execution status does not exist
* Fix recursive functions
* Update helper version
* "finally" blocks are always executed
* Typo
* destructuring private fields with array pattern / object pattern
* wip: new test cases
* destrucuring and rest for private properties
* test case for loose private-loose
* add transform-desturcturing for exec
* update test case
* remove getPrototypeOf imports from get and set
* wip: destructure super assignment
* throw "Destructuring to a super field is not supported yet."
* fix tests and fix assignment pattern
* remove CallExpression from AssignmentPattern
This reverts commit 43b83f8ed7545b9c049eeed85541fa162842fb8f.
Fix objectSpread helper breaking old codes
remove tests to regenerate later
renamed output
new name
try using word
add comment as requested
revert inline name changes
add 2 for consistency
Update packages/babel-helpers/src/helpers.js
Co-Authored-By: Daniel Tschinder <daniel@tschinder.de>
### `@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.
* add isSpread field
* use argument
* t.booleanLiteral
* fix typo
* push empty-argument object
* .object
* .value
* object field should be an expression
* lint
* update outputs
* isSpread for the second argument is redundant
* add test
* alternating spread
When the `runtime` flag is on (by default), this plugin adds a new helper which wraps the native `RegExp` class to provide groups support. People nees to use a polyfill (I implemented it in core-js) for browsers that don't support ES6 regexps.
This is similar to ec69b4bb1256c061ac76f53dfed09c4283ec6a31, which
was about private instance fields.
Private properties can be non-writable (thanks to decorators), or have
get/set accessors. If we stored this information on the `privateClass`
object, we would need to always use `Object.getOwnPropertyDescriptor`
before reading or writing a property because accessors need to be called
with the correct `this` context (it should be the actual class, not the
object hat stores the private properties). This commit simplifies that
operation a bit by removing the container object.
It also have another advantage, which instance fields already have
thanks to the use of separate weakmaps: unused private static fields
can be tree-shaken away or garbage-collected, while properties of an
object can't. Also, they can be easilier minified.