53 Commits

Author SHA1 Message Date
Logan Smyth
eaa31b6ec3 Explicitly throw if the rest/spread items are not iterable. 2018-03-05 09:32:40 -08:00
Logan Smyth
4d76d5dddc Refactor Babel's helpers into smaller functions. 2018-03-05 09:32:39 -08:00
Logan Smyth
dffcef785a Lazy-initialize helper templates. 2018-02-26 18:18:57 -08:00
Deepak Pai
dad05ed503 Solves Tagged template literal size optimization (#7379)
* Tagged template literal size optimization
solves #7352

* Incorporates review changes
2018-02-20 15:39:22 -05:00
Andrea Puddu
ee6dfd1580 Fix object spread according to spec (#7034) 2018-02-16 20:06:17 -05:00
Jorrit Schippers
3c8d831fe4 Prevent object shape change in jsx helper (#7170)
Keeping the shape of an object constant is a performance improvement for modern javascript engines. At the point of the code change it is certain that the `children` property will be set later, so the property can already be set to `undefined`.
2018-01-15 16:37:57 +01:00
Nicolò Ribaudo
ae3f5b9149
Return the obj in setPrototypeOf fallback (#7080) 2017-12-20 22:48:10 +01:00
Nicolò Ribaudo
0c885b3200 Add support for extending builtins (#7020) 2017-12-20 14:46:00 -05:00
Peri Nikhil
9cc0a26694 Move helpers from 'babel-plugin-proposal-decorators' to 'babel-helpers' (#7017) 2017-12-13 16:08:19 +01:00
Nicolò Ribaudo
509dbb7302
this before super() is a runtime error, not a static one. (#6467)
* Check that super.* is after super() at runtime

* "missing super() call in constructor" runtime

* "'this' is not allowed before super()" runtime
2017-12-06 06:46:54 +01:00
Daniel Tschinder
9d9710c765 Copy getters and setters correctly in interopWildcard (#6850) 2017-11-30 15:50:10 -06: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
Mauro Bringolf
ba441c5ce4 Define readOnlyError helper and use in check-constants plugin 2017-11-20 16:41:15 +01:00
Mateusz Burzyński
4684edaec7 Adhering to async generator yield behavior change (#6452) 2017-10-21 21:48:27 +02:00
Mateusz Burzyński
54aa4cb3f9 Fixed async generator named declarations with inline helpers 2017-10-20 14:23:27 +02:00
Nicolò Ribaudo
e0a6e1e864 Import temporalUndefined inside temporalRef helper 2017-10-19 00:32:43 +02:00
Logan Smyth
107c37715e Use .program template for helpers. 2017-10-18 13:58:47 -07:00
Logan Smyth
cc802c1e00 Reimplement 'babel-template' with better caching and tagged literal utilities. 2017-10-18 13:58:47 -07:00
Logan Smyth
fc3433c5cf Default templates to sourceType:module. 2017-10-18 13:55:14 -07:00
Henry Zhu
cde0054227 Scoped: change src imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Mateusz Burzyński
88b7983e4f Fixed asyncToGenerator helper using arrow function (#6289) 2017-09-21 17:09:43 -07:00
Pranav Prakash
e98bb3dc60 Use new Array instead of Array for V8 optimization (#6250)
* Use new Array instead of Array for V8 optimization

* fix spacing [skip ci]

* Remove extraneous use strict clauses
2017-09-18 14:14:46 -04:00
Logan Smyth
158e9fbfd7 Represent helpers as simple modules. 2017-09-12 22:15:16 -07:00
Artem Yavorsky
b2b3d7944a Spec compatibility for iteratorClose condition. (#6094)
* for-of: IteratorClose spec compatibility.

See #3:
https://tc39.github.io/ecma262/#sec-iteratorclose

* Update spec fixtures for for-of.

* Fix IteratorClose case for remap-async-to-generator.

* Fix IteratorClose case for async-generator-function test output.

* Modify few tests according to iteratorClose fix.

* Fix iteratorClose for helpers.slicedToArray also.

* Update iteratorClose fixture for commonjs.
2017-08-28 13:39:02 -06:00
Justin Ridgewell
7795750862 Tests 2017-08-25 22:52:17 -04:00
Adam Miller
2d8fdf3045 Allow native Symbols as computed property names (#6705)
The for-in loop in helpers.defineEnumerableProperties doesn't iterate over Symbols.
If Object.getOwnPropertySymbols exists, include the discovered values when defining properties.
2017-08-25 22:33:51 -04:00
Nicolò Ribaudo
fb9a752262 Function sent (#5920)
* Create "babel-helper-wrap-function"

It contains the logic to wrap a function inside a call expression.
It was part of the "babel-helper-remap-async-to-generator" package, but
it is needed to transpile "function.sent"

* Create "babel-transform-function-sent"

It transforms the "function.sent" meta property by replacing it with
"yield" and making the generator ignore the first ".next()" call.

* "function.sent" is the last value passed to .next(), not the first one

* Disable exec tests on old node

* Fix flow error

* Add "transform-function-sent" to "stage-2" preset

* Do every trasformation in one traversal

* Test for "yield function.sent"

* [skip ci]

* Fix some typos [skip ci]
2017-07-25 11:07:01 -04:00
Peeyush Kushwaha
4a35243118 Non string computed keys in object-rest-spread (#5757) 2017-07-25 09:46:52 -05: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
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
Henry Zhu
4fdff567c6 remove superClass truthy check 2017-06-24 14:27:41 -04:00
Henry Zhu
8a4ab088e4 create and use a inheritsLoose helper 2017-06-19 11:58:49 -04:00
Steven Hargrove
d5aa6d3ff8 Fix for #4943 "Calling an async function with default parameter as function for arguments checking handled synchonous" (#5688)
* moved applying arguments inside new Promise handler block

* updated test fixture to reflect change

* corrected the apply to use correct scope and arguments

* added regression test for issue #4943, added async-to-generator/async-default-arguments test

* added regression test for issue #4943

* switched back to using arrow function, since now pointing to v7 release base branch

* simplified async-to-generator regression test for issue #4943, imrproved change to self/arguments refs by using arrow function on returned promise

* updated text fixtures

* removed es2015 preset usage from issue #4943 regression exec test

* added use strict to test fixture

* added use strict to test fixture

* added destructing transform to test options

* removed use strict from exec test

* added parameters & destructing transforms to test
2017-05-03 21:44:41 -07:00
Andres Suarez
f0dc710a46 Remove unnecessary returns in asyncToGenerator helper (#5548)
* Remove unnecessary returns in asyncToGenerator helper

* Reuse "then" callbacks in asyncToGenerator helpher
2017-04-06 11:40:55 -04:00
Logan Smyth
b845f2b69d Re-enable the max-len ESLint rule. (#5265) 2017-02-04 11:07:15 -05:00
Henry Zhu
672adba9a1 enable prefer const (#5113) 2017-01-14 09:48:52 -05:00
zenparsing
26e79c5433 Implement support for async generator functions and for-await statements 2016-09-27 17:37:21 -04:00
Kay J
4dcc981d6a Removed unnecessary 'return' statements. (#3653)
* Removed unnecessary 'return' statements.

Returning a 'Promise' value in 'promise.then()' makes promise chains.
Used memory and promises are not garbage collected
until finishing 'helpers.asyncToGenerator'.

* Update test
2016-09-25 13:57:59 -07:00
Alberto Piai
8f6d4ae5cf Fix typeof Symbol.prototype (#3686)
* formatting

* fix `typeof Symbol.prototype`

Babel uses a helper function to return the correct value for `typeof
obj` when obj is a Symbol and support for Symbol has been polyfilled.

This function assumes that `obj.constructor === Symbol` implies `typeof
obj === 'symbol'`.

This isn't true when obj is `Symbol.prototype`. In that case (REPL from
node 6, the same holds in Firefox):

```
> Symbol.prototype.constructor === Symbol
true
> typeof Symbol.prototype
'object'
>
```

AFAICS, that's the only case where the assumption doesn't hold.

The test added by this patch fails only on node 0.10, as 0.12 already
has a native implementation of Symbol and the polyfill code doesn't run.

This caused a problem in core-js when it's compiled with babel (the
issue was isolated by @skozin here:
https://github.com/zloirock/core-js/issues/189#issuecomment-209864582).
2016-09-20 12:19:09 -04:00
Sebastian McKenzie
5b89849f43 Switch to klint, fix some lint rules 2016-02-14 23:25:14 +00:00
Sebastian McKenzie
99a224efd9 add missing returns to async to generator helper 2016-01-18 02:02:08 +00:00
John-David Dalton
d9bf5da460 Defer to built-in typeof if built-in support for symbols exists. 2015-12-27 22:50:48 -06:00
Nook Scheel
a81e11c4ae Use arguments with #apply 2015-11-29 21:47:04 +03:00
Nook Scheel
b2ff128e94 Unnecessary #call 2015-11-29 21:28:14 +03:00
Nook Scheel
8c7a81d317 Optimizations for asyncToGenerator
Never use a bind!
Never use arguments as an array!
2015-11-29 21:25:09 +03:00
Ben Alpert
d1b8db1532 React inlining: Refactor to reduce parsing cost
- Have the `jsx` helper do the `defaultProps` work instead of calling `defaultProps` inline.
- Put `key` after `props` and make it optional.
- Inline `children` as rest args instead of in the object.
- Rename `createRawReactElement` to `jsx`. I wish I was kidding.

Most of these are silly microoptimizations. In my test file (based off an internal RN app), this reduces the parsing overhead of inlining from around 1% to 0.1% in JSC and from 0.6% to 0.0% in V8 (compared to element inlining before this commit).

Once parsed, the initial render with inlining is the same speed as not inlining in JSC and ~1% slower in V8. A second initial render in the same context (reusing the function objects, JIT, etc) is 2.0% faster in JSC and 5.5% faster in V8.
2015-11-12 18:05:57 -08:00
Sebastian McKenzie
fe5aff09a4 fix remaining babel helper issues 2015-11-11 22:45:50 -08:00
Ben Alpert
3cad287233 Use a helper function for React "inlining"
Either due to lower parsing costs or better type inference, this seems
to perform better than direct object inlining. (All along, the main win
was skipping a loop through props, not avoiding a function call.)
2015-11-10 21:10:06 -08:00
Sebastian McKenzie
bcd639672d add defineEnumerableProperties helper 2015-11-08 05:33:42 -08:00