38 Commits

Author SHA1 Message Date
Nicolò Ribaudo
6ef7b51a11 Implement assumptions defined in the babel/rfcs#5 RFC
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408)
- `setClassMethods` (#12407)
- `setComputedProperties` (#12490)
- `ignoreFunctionLength` (#12491)
- `noDocumentAll` (#12481)
- `iterableIsArray` and `arrayLikeIsIterable` (#12489)
- `pureGetters` (#12504)
- `skipForOfIteratorClosing` (#12496)
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505)
- `noNewArrows` (#12613, #12793)
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497)
- `constantReexports` and `enumerableModuleMeta` (#12618)
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726)

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Huáng Jùnliàng <JLHwung@users.noreply.github.com>
2021-02-21 17:09:45 +01:00
Huáng Jùnliàng
8f191ead92
chore: fix typo in codebase (#11846) 2020-07-16 16:01:20 -05:00
Bogdan Savluk
4108524856
Update prettier to v2 (#11579)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-07 22:21:33 +02:00
Nikita Kirsanov
9a52019019
Use computed memberExpression for literal keys with object rest (#11550) 2020-05-12 22:56:03 +02:00
Justin Ridgewell
a080a1d345
Use single object spread call in loose mode (#11520) 2020-05-08 13:07:59 +02:00
Justin Ridgewell
c1d65d8842
Fix evaluation order with object spread, 2 (#11471) 2020-04-26 20:30:48 +02:00
Zen
af669297ef
Fix evaluation order with object spread (#11412)
* Fix object spread runtime semantics

* limit this deoptimization

* optimize empty objects

* declare variables
2020-04-23 17:59:35 -04:00
Vedant Roy
aea0fcd599
Correctly transpile when cross-param refs with obj rest (#11326)
* Transform initializers with ids in rest elements

Fix issue 11281. Transform parameters with default initializers that
have ids that are also in a parameter with a rest element.
Before, these parameters were not transformed.

* Add plugin-transform-parameters as dependency

* Remove outdated comment

* Use set instead of array for paramsWithRestElement

* Skip when encounter "Scope"

Previously, f({...R}, f = R => R) would be incorrectly transformed.

* Pass in loose mode option instead of false

* Address review and re-organize tests

Checking the RHS of an assignment pattern/checking the parent of
an identifier node fails on cases like "({...R}, a = f(R))" or
"({...R}, {[R.key]: a = 42})".

Also refactor tests by removing unecessary tests and
separating "should transform" from "should not transform" tests.
2020-04-07 21:06:43 +02:00
Huáng Jùnliàng
d60802bf73
fix: object-rest-spread should not transform array rest (#11282) 2020-03-18 20:55:38 -04:00
Huáng Jùnliàng
9be27bcfea fix: add computed property support for object Ref (#10863)
* fix: add computed property support for object Ref

* Apply suggestions from code review

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

* Update output.js
2019-12-19 01:29:46 +01:00
Tan Li Hau
8027dca501 fix object rest in array pattern (#10275)
* fix object rest in array pattern

* update test fixtures

* early return

* use path.stop() at the right path
2019-09-10 15:18:45 +02:00
Nicolò Ribaudo
7dc5fdb390
Workaround #10179 in proposal-object-rest-spread (#10200) 2019-07-15 19:01:29 +02:00
Nicolò Ribaudo
24dde2e8e8
Fix objectSpread2 backward compatibility (#10170) 2019-07-06 09:48:36 +02:00
Kagami Sascha Rosylight
a596da2822 Retry to fix object spread helper compatibility (#9384)
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>
2019-05-25 12:57:13 +02:00
piotr
a64bf63639 [proposal-object-rest-spread] fix templateLiteral in extractNormalizedKeys (#9628)
Added additional check in extractNormalizedKeys function to handle templates differently than string.
2019-03-13 21:39:50 +01:00
Nicolò Ribaudo
5c8cc0d536
Mark FOO in "var { x: FOO }˝ as a binding, not as a reference (#9492) 2019-02-27 00:17:11 +01:00
Nicolò Ribaudo
0345c1bc1d
Use for..of Object.keys instead of for..in (#9518)
In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them.
I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties.
2019-02-26 20:09:02 +01:00
Daniel Tschinder
b78fdc0cb1
chore: Enable eqeqeq rule in eslint (#9541) 2019-02-18 21:16:42 -08:00
Moti Zilberman
1452e977a0 Destructuring: Create assignments from ForX non-declaration patterns (#9414) 2019-01-28 09:50:24 +01:00
Daniel Tschinder
43b83f8ed7 Revert "Differentiate object spread and non-spread properties (#9341)" (#9379)
This reverts commit 3ae5e79ec8ab1e6d1c6927f35d4a1eeac04faf9a.
2019-01-21 23:03:54 -08:00
Kagami Sascha Rosylight
3ae5e79ec8 Differentiate object spread and non-spread properties (#9341)
* 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
2019-01-21 22:04:47 +01:00
Nicolò Ribaudo
8c7d4b55c9
Add plugins name (#8769)
* Add plugins name

* Add missing names found by the plugin

* Add eslint plugin
2018-11-18 23:02:58 +01:00
Jason Quense
47e05d70f3 Fixed issue with non-simple property paths in object-rest-spread loose mode (#8514)
* fix: object rest with default values bug

fixes #8323

* rename variable
2018-08-23 15:53:31 +02:00
Mateusz Burzyński
b5e64cb66e
Remove unused bindings when excluding keys with rest in loose mode (#8264) 2018-07-07 19:54:51 +02:00
Mateusz Burzyński
c0c13ae30f Introduce objectWithoutPropertiesLoose helper (#8261) 2018-07-06 15:03:44 -04:00
Mateusz Burzyński
d682e32529
Favour extends helper over objectWithoutProperties when whole object gets copied anyway (#7390) 2018-03-14 22:59:02 +01:00
Logan Smyth
a4795408b4
Allow plugins to assert that a specific babel version has loaded the plugin. (#7450) 2018-03-04 14:36:54 -08:00
Nicolò Ribaudo
3d49766f6b Don't extract rest elements from nested expressions (#7364)
* Don't extract rest elements from nested expressions

* Node 4
2018-02-17 16:22:38 +01:00
James Reggio
6cbc585cf4 Fix over-zealous traversal by object-rest-spread (#7388)
Prior to this change, we'd conduct an open-ended traversal on the 'id'
of any VariableDeclarator to find a RestElement. The 'id' of
a VariableDeclarator can contain an AssignmentPattern (to supply
a default value), and if the right-hand side of the AssignmentPattern
contained a RestElement, we'd transform it.

The problem here is that the right-hand side of an AssignmentPattern can
be *any* Expression. If the right-hand side is a function body, we'd
traverse the entire function body, and if a RestElement occurred
anywhere in that function body, we'd transform it and emit the
transformations wherever we began the traversal (at least one scope
outside its usage).

The fix is to stop the inner traversal if we encounter an
AssignmentPattern. The outer traversal will still visit the
AssignmentPattern, so RestElements within the right-hand side of an
AssignmentPattern will be properly transformed at that time.
2018-02-16 21:19:09 -05:00
Andrea Puddu
ee6dfd1580 Fix object spread according to spec (#7034) 2018-02-16 20:06:17 -05:00
Nicolò Ribaudo
4887d81929 Remove bindings of removed paths from scope 2018-02-06 23:59:12 +01:00
Nicolò Ribaudo
252ea5a966 Fix reused nodes - part 2 (#7149) 2018-01-29 22:59:06 +01:00
Mateusz Burzyński
912bcc186d Fix reused nodes - part 1 (#7149) 2018-01-29 22:59:06 +01:00
Nicolò Ribaudo
63ae923987 Add t.cloneNode and deprecate t.clone and t.cloneDeep (#7149) 2018-01-29 22:59:06 +01:00
Logan Smyth
e7c57ae85a Move a few more references to plugin options to the top level. 2017-11-08 23:07:56 -08:00
Logan Smyth
b19b66d94b Use peerDep rather than plugin param for common APIs. 2017-11-06 11:32:47 -08:00
Henry Zhu
9ac326b075
remove es20xx prefixes from plugins and rename folders (#6575) 2017-10-28 20:43:15 -04:00
Henry Zhu
c41abd79a1
Rename all proposal plugins to -proposal- from -transform- (#6570) 2017-10-27 15:26:38 -04:00