27 Commits

Author SHA1 Message Date
Nicolò Ribaudo
911c2d0bf4
Use @babel/eslint-plugin-developement (#9206) 2018-12-18 22:59:43 +01:00
Nicolò Ribaudo
4e28459a2f
Make @babel/plugin-class-features a normal helper package (#9083)
* Make @babel/plugin-class-features a normal helper package

This effectively disallows using it directly.

* Rename helper

* Style

* Don't add prefix to plugin name

* Move private methods plugin
2018-11-29 16:42:45 +01:00
Nicolò Ribaudo
5979b0669b
Merge class features plugins
* Create @babel/plugin-class-features

* Move class properties transformation logic to enanced-classes (#8130)
2018-11-20 21:14:35 +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
Nicolò Ribaudo
c5279eeca4
[static private] Use explicit descriptors instead of an object (#8620)
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.
2018-09-05 15:08:40 +02:00
Nicolò Ribaudo
d4e23b5b2a
[static private] Unify loose handling of static and instance props (#8614) 2018-09-04 08:10:46 +02:00
Robin Ricard
fb66fa6f90 Private Static Fields Features: Stage 3 (#8205)
* Private Static Class Fields Implementation

* Redo testing without class transform for static private

* Add a call() test for private static

* Use Object.defineProperty in loose mode
2018-09-01 00:42:18 -04:00
Mauro Bringolf
427aff559f Fix decorators interop bug with class field tdz
Co-authored-by: Jan Buschtöns <jan@buschtoens.me>
2018-08-13 08:57:09 +02:00
Nicolò Ribaudo
ec69b4bb12 Save full descriptor instead of only value for private fields. (#8318)
* Save full descriptor instead of only value for private fields.

Decorators can make private fields non-writable, so we need to store this
information somewhere.
The descriptor can also be used to implement private accessors.
2018-07-27 16:24:57 -04:00
Nicolò Ribaudo
387cda8fbb isConstantExpression should return true for immuable bindings (#8122)
* isConstantExpression should return true for immuable bindings

* New test

* Don't return undefined
2018-06-12 13:40:52 -04:00
Nicolò Ribaudo
9f4e2f81d8
[class-properties] Remove unnecessary return and temp variable (#8123)
* Remove unnecessary temp variable

* Update tests
2018-06-08 07:02:36 +02:00
Brian Ng
5895277b32 Bump prettier to v1.13.2 2018-06-03 07:54:39 -05:00
Justin Ridgewell
27c39c512d
Class private properties (#7842)
* Update member-expression-to-functions

1. Babel using British spellings, so `memoise`
2. Provide a helper `AssignmentMemoiser` class, which will assign the memo'd value with the `n`th access.

* Private properties!

* Fixes

* Tests

* Update helper name

* Fix privates that reference other privates

* Don't extend a builtin

* Rebase
2018-05-18 14:03:23 -04:00
Justin Ridgewell
725e6a01c0 Don't fold class property calls (#7814)
This undoes the property call folding from #6656.

It complicates the private property transforms, since they boil down to `map.set(this, vlaue)` and we definitely don't want the next call define a property on the map.

/cc @Andarist
2018-04-26 15:06:18 -05:00
Justin Ridgewell
8c46fd159f
Class Props: Don't rename constructor collisions with static props (#7813)
Static props aren't evaluated inside the constructor, so there can't be a collision.
2018-04-25 23:45:52 -04:00
Mateusz Burzyński
5166eef103 Optimize class properties output (#6656) 2018-04-15 01:03:47 -04:00
Justin Ridgewell
668358c4d0
Fix class properties after nested class' bare super (#7671)
* Fix class properties after nested class' bare super

Fixes #7371.

* Fix node 4 test

* This damn node 4 test

* All of the ClassBody, but not the methods or field inits

* tmp

* tmp

* Use common class environment visitor

* Tests

* Use skipKey to avoid recursive traversal

* Remove old state

* Use jest expect
2018-04-14 13:48:38 -04:00
Nicolò Ribaudo
fa2c6c5164 Never extract class fields into an initializer function. (#7659)
It was needed to avoid collision of identifiers used in fields
initializers with variables declared in the constructor, but it
broke `this` handling.
This commit removes that behavior and instead renames the
colliding variables.
2018-04-05 16:20:47 +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
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
Mateusz Burzyński
820edd1e23
Fix computed properties being inserted after the class, thus making them unavailable for instance methods & properties (#7147) 2018-01-03 15:39:07 +01:00
Nicolò Ribaudo
68476b6ddd
Make .insert{Before,After} work by default when the parent is an eport declaration (#7040) 2017-12-19 00:05:29 +01:00
Mauro Bringolf
6330a152ce Implement TDZ for ClassFieldDefinitionEvaluation (#6855)
* First implementation sketch and testcase

* Use helper instead of inline IIFE's

* minNodeVersion 6.0.0

* Hoisted visitor for subtraversal and fixed edgest case

* Resolve merge conflicts in helpers

* Remove duplicated helper from messing up Git
2017-11-26 16:56:04 +01:00
Logan Smyth
b19b66d94b Use peerDep rather than plugin param for common APIs. 2017-11-06 11:32:47 -08:00
Mateusz Burzyński
a1c7449a92 Fixed incorrect static class field initialization order (#6530) 2017-10-30 16:32:45 -04:00
Henry Zhu
c41abd79a1
Rename all proposal plugins to -proposal- from -transform- (#6570) 2017-10-27 15:26:38 -04:00