38 Commits

Author SHA1 Message Date
Ajay Narain Mathur
3cdb7d7f0f added instanceOf plugin to preset es2015 (#6257)
* added instanceOf plugin to preset es2015

* fixed test cases
2017-09-17 17:33:42 -04:00
Logan Smyth
158e9fbfd7 Represent helpers as simple modules. 2017-09-12 22:15:16 -07:00
Logan Smyth
1e750a945c Convert CommonJS to use new shared implementation. 2017-09-12 17:17:41 -07:00
Mateusz Burzyński
c47258d68c Annotating transformed classes with #__PURE__ comment (#6209) 2017-09-11 11:18:37 -04:00
Oliver Don
960151c876 Fix #4840: Alias class prototype for methods in loose mode (#5560)
* Fix #4840: Alias class prototype for methods in loose mode

* Cleanup
2017-08-26 21:15:45 -04:00
Noah Lemen
2db0c3ad1d linting: disallow t.identifier("undefined") in plugins (#6096)
* add new custom eslint rule, replace remaining t.identifier("undefined") with buildUndefinedNode(), update tests

* change no-undefined-identifier reporting descriptor
2017-08-24 15:43:01 -04:00
Mateusz Burzyński
fffa604023 Fixed regenerator related fixtures 2017-08-16 10:02:33 +02:00
Nicolò Ribaudo
b84f8e9234 Don't use _possibleConstructorReturn inside arrow functions (#6103)
Arrow functions can't be entrly skipped while traversing because this
references inside of them needs to be transformed, so I added a check
which prevents return statements inside arrow functions from being
saved for the transformation.

Fixes #5817 (regression)
2017-08-14 11:11:05 -04:00
Henry Zhu
0f823beeb1 Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Justin Ridgewell
28ae47a174 Stop mutating nodes (#5963)
* Stop mutating nodes

* Update tests

* linting
2017-07-18 13:24:07 -04:00
Justin Ridgewell
797fb3c2e4 Optimize and remove state from typeof-symbol transform (#5955)
Also fixes a bug with returning a Symbol from a Class constructor
(because the transform wasn’t run on helpers before).
2017-07-17 10:51:36 -04:00
Justin Ridgewell
e170e6d760 Fix returning an object in a derived class constructor without super (#5885) 2017-07-11 17:43:19 -04:00
Daniel Tschinder
b3372a572d Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
Henry Zhu
cdca54aed3 remove possibleConstructorReturn in loose mode as well 2017-06-09 18:42:52 -04:00
Henry Zhu
123dce5fcd Hardcode to double quotes, indent to 2 spaces (#5824) 2017-06-05 22:14:37 -05:00
Buu Nguyen
c474fd48e1 Fix issue semi-colon gets inserted unnecessarily (#5749)
* Fix issue semi-colon gets inserted unnecessarily

* Simplify if condition a bit
2017-05-19 16:54:51 -04:00
Brian Ng
cd9bb7ba10 Ensure default exported classes keep entry in export table (#5488) 2017-04-09 16:39:15 -07:00
Henry Zhu
174e44f656 fix broken test from old PR 2016-08-31 14:55:38 -04:00
Stanislav Sysoev
33da726638 Not null check in babel-helper-builder-binary-assignment-operator-visitor (#3647)
Fix: T7537 — https://phabricator.babeljs.io/T7537

When transforming super call in class constructor, part of ast is replaced using method "replaceWithMultiple" here:
https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-es2015-classes/src/vanilla.js#L379

It leads to removing the node (replacing it with null) here:
https://github.com/babel/babel/blob/master/packages/babel-traverse/src/path/replacement.js#L51

But parent ExpressionsStatement is still untouched and when it reaches visitor generated in here
https://github.com/babel/babel/blob/master/packages/babel-helper-builder-binary-assignment-operator-visitor/src/index.js#L18

It blows up because expression is null from previous visitors.
2016-08-31 14:41:49 -04:00
Daniel Tschinder
10cd6519d8 Fix class inheritance in IE <=10 (T3041) (#3527)
* Fix class inheritance in IE9 & IE10 (T3041)

Internet Explorer 9&10 do not support __proto__ at all, don't have
Object.setPrototypeOf(), but have Object.getPrototypeOf().

Because of this setting the prototype is not possible, which makes the
babelHelpers.inherits() function to set __proto__ although not supported.

Afterwards Object.getPrototypeOf() is used, but this one is not
respecting the "custom" property __proto__ that we set.

The solution is to check for __proto__ first and afterwards fallback to
Object.getPrototypeOf().

* Do the same logic in babel-helper-replace-supers

* Fix tests

* Extract creation of prototype nodes to small helper
2016-08-23 15:08:44 -04:00
Henry Zhu
ad81f5b149 check if valid.id is defined 2016-01-22 14:20:54 -05:00
Amjad Masad
95c93dd22b Method names should not be bound to body
As an artificat of compiling methods to named function expressions the
function name is being considered a "local" binding in the function
body. This means that we will throw errors anytime someone would want to
create a new local binding with the same name.

This is solved by assigning a symbol to function Identifiers that
indicates that they should not be considered local bindings.
2016-01-17 13:19:37 -08:00
Amjad Masad
0d8e5a9e86 Fix over-parenthesizing of function expressions 2015-12-24 14:55:51 -08:00
Sebastian McKenzie
1fa24b1efd rename babel-plugin-external-helpers-2 to babel-plugin-external-helpers 2015-12-24 03:54:40 +00:00
James Kyle
abb85b498a Merge pull request #3138 from loganfsmyth/class-rename-failure-T2494
Skip name inference on hard-to-replace classes - fixes T2494
2015-12-05 20:58:37 -08:00
Logan Smyth
925804798d Skip name inference on hard-to-replace classes - fixes T2494 2015-12-05 17:07:10 -08:00
Logan Smyth
9f32061769 Merge pull request #3134 from loganfsmyth/default-renamer-T6750
Ensure that default exports have a name before splitting them - fixes T6750
2015-12-05 16:23:39 -08:00
Logan Smyth
a12a116b9f Ensure that default exports have a name before splitting them - fixes T6750 2015-12-05 15:28:48 -08:00
Logan Smyth
03f189fc46 Ensure that the async/generator flags carry over when converting class methods - fixes T6755 2015-12-05 12:24:00 -08:00
phantom10111
9a270a3d0a Fix return super(); in class constructor - fixes T2997 2015-11-25 23:53:53 +01:00
Logan Smyth
b3f2ea0aa1 Avoid duplicating traversal of class declarations - fixes T2694 2015-11-19 00:30:56 -08:00
Sebastian McKenzie
01356191d4 avoid revisiting classes - #2694 2015-11-13 16:55:54 -08:00
Sebastian McKenzie
688dcec6a3 fix queueing of nested paths being pushed onto the priority queue 2015-11-13 03:37:15 -08:00
Sebastian McKenzie
f91cfa68b9 ignore callee supers when doing spread compilation - fixes #2775 2015-11-12 01:59:07 -08:00
Sebastian McKenzie
e09d442be6 remove redundant test 2015-11-11 02:02:39 -08:00
Sebastian McKenzie
f601e62678 add regression test - fixes #2941 2015-11-10 16:02:45 -08:00
Sebastian McKenzie
54c13eef5c fix exported classes with static class properties - fixes #2868 2015-11-10 15:56:22 -08:00
Sebastian McKenzie
29f756fd6f add regression tests - closes #2663 2015-11-10 14:40:30 -08:00