112 Commits

Author SHA1 Message Date
dlwalsh
cdb465a834 remove repeating dependency from babel-traverse (#3501) 2016-05-16 09:54:37 -04:00
Amjad Masad
109d99bb5e don't double count binding references (#3465)
When, for example, a function is moved between from one place to another we recrawl and end up double counting any references it holds to the upper scope. This protects against that. (The same thing is done for constant violations in the `reassign` method)
2016-05-13 17:20:32 -04:00
Jordan Klassen
dc1f40540d Upgrade to lodash 4 (#3315)
* Upgrade to lodash 4

* Fix incorrect require in babel-runtime/scripts

* Replace cloneDeep with cloneDeepWith where applicable
2016-05-13 17:15:14 -04:00
Logan Smyth
9843c87573 Fix block statement code style. (#3493) 2016-05-02 21:15:37 -04:00
Logan Smyth
c3ccddaaaf Revert "Merge pull request #3433 from loganfsmyth/bail-out-rename"
This reverts commit 2d0a007d14e519fe60a849dd17068a0f3df79a28, reversing
changes made to e4d6d420415a0c290a321fb6c18ba5f19675b5c1.
2016-04-08 09:09:48 -07:00
Logan Smyth
2d0a007d14 Merge pull request #3433 from loganfsmyth/bail-out-rename
Only attempt to rename export declarations, not expressions - fixes T7215
2016-04-06 19:04:21 -07:00
nkzawa
85ecb6c97b stop traversing when target type is found 2016-03-28 03:01:06 +09:00
Logan Smyth
bad2c768f2 Remove this check which will never pass with the new cache. 2016-03-23 20:57:18 -07:00
Logan Smyth
078f6c0ed3 Only attempt to rename export declarations, not expressions - fixes T7215 2016-03-16 23:26:52 -07:00
Simeon Willbanks
93d438cf01 Fix misspelling 2016-03-16 22:17:09 -07:00
Henry Zhu
459b1ffa1c Merge pull request #3420 from loganfsmyth/scope-cache-invalidation
Invalidate the scope cache if a node is moved to a different path - fixes T7194
2016-03-16 23:18:48 -04:00
Logan Smyth
80aa424b75 Invalidate the scope cache if a node is moved to a different path - fixes T7194 2016-03-12 14:21:21 -08:00
Logan Smyth
b1c50b01f2 Ensure that we push and pop evenly so things don't fail to queue - fixes T7199 2016-03-12 12:30:33 -08:00
Amjad Masad
4abc03eef1 Rework logic that controls flowBinding warning
The flag to control whether we should warn didn't take into account
nested calls or scope chains. An easier approach is to have a
counter. That way we know for sure if we're somewhere deep inside a
crawl call or not.
2016-03-10 16:39:12 -08:00
Amjad Masad
5a081a8572 Update comment, reformat message 2016-03-10 13:00:45 -08:00
Amjad Masad
9f0dbf0234 Better warnings 2016-03-10 12:54:02 -08:00
Amjad Masad
7f4b57a7a4 Add warning instead of removing support 2016-03-10 12:35:15 -08:00
Amjad Masad
342f9d5eb5 Don't consider flow types as bindings 2016-03-10 11:48:14 -08:00
Amjad Masad
b35013abe5 Merge pull request #3406 from babel/fix-scope-info
Update scope info after block-scoping transform
2016-03-08 00:57:18 -08:00
Amjad Masad
0200542e82 don't use Array.includes 2016-03-08 00:33:37 -08:00
Logan Smyth
de21f2ef77 Resolve 'arguments' for rest args relative to direct parent. 2016-03-07 20:45:21 -08:00
Logan Smyth
836f398619 Re-use central inShadow logic. 2016-03-07 20:45:19 -08:00
Logan Smyth
8b8e3ddbec Flatten inShadow logic for readability. 2016-03-07 20:45:18 -08:00
Amjad Masad
77c7cc5363 Rework scope info updating in block-scoping transform
I previously tried an approach to scope bindings from var to scope but
it didn't catch all cases. This is evident in this bug:

https://phabricator.babeljs.io/T2892

Where even after transforming a const to a var we still get an error
that it's read-only.

This approach will go through and delete every existing let and const
binding and creates a new one with the kind "var"
2016-03-07 18:19:10 -08:00
Amjad Masad
d5e78384ef Only export methods and not the entire cache 2016-03-07 12:50:29 -08:00
Amjad Masad
fc19ac2af5 Remove merge artificats 2016-03-07 12:05:46 -08:00
Amjad Masad
403d6153fd correct cache path 2016-03-07 12:04:44 -08:00
Amjad Masad
b53755422c Move things around 2016-03-07 12:04:44 -08:00
Amjad Masad
bf91a68375 Move scope cache to the cache module 2016-03-07 12:04:44 -08:00
Amjad Masad
3c148148bc Semicolon 2016-03-07 12:04:44 -08:00
Amjad Masad
5367d5d151 Make sure we update the cache in all the right places 2016-03-07 12:04:44 -08:00
Amjad Masad
29ef158204 Semis 2016-03-07 12:03:48 -08:00
Amjad Masad
b9a893aab6 Move NodePath cache out of the AST
As mentioned on the task https://phabricator.babeljs.io/T7179 having
this cache on the AST leads to all sorts of portability and reuse
bugs.

This moves the cache into a clearable WeakMap which will fix the
following:

1. Moving the AST between different babel versions or tools will not
lead into sharing potentially outdated cached information

2. `.clear()` can be called on the cache by a plugin to clear
potentially outdated information. This is helpful when implementing two
seperate pipelines that should not share information.

I think the next step (which is harder, I tried) is to isolate cache and
make it live on a transform or pipeline level state (like the `hub`).

The reason it is hard is because the `babel-traverse` main API -- although
requires the state object to be passed -- not many callers do. To fix
this we should release a patch version that warns about this and fix all
the internal callers. Next couple of releases we can start throwing when
no state is passed (or we can create our own state).
2016-03-07 12:03:48 -08:00
Amjad Masad
3667527d04 Revert "Remove flow"
This reverts commit 2827ff6b01dcce69e9d3c0402e96b52b3a2a47ee.
2016-03-03 14:49:20 -08:00
Sam Goldman
2827ff6b01 Remove flow 2016-03-01 22:33:30 -08:00
Logan Smyth
f2fea017c6 Ensure that the found context is active before pushing it. 2016-03-01 08:14:14 -08:00
Logan Smyth
4561732bce Revert .requeue changes made in earlier ES3 fixes. 2016-02-29 23:55:47 -08:00
Henry Zhu
b8cdd6e28c Merge pull request #3365 from jridgewell/replace-implicit-arrow-with-block
Replace arrow expression body with block statement
2016-02-25 22:02:31 -05:00
Logan Smyth
01003b954a Re-queue nodes inserted with .replaceWith and centralize logic - fixes T2817 2016-02-22 22:44:03 -08:00
Justin Ridgewell
de1431e8c6 Replace arrow expression body with block statement
Original PR: https://github.com/babel/babel/pull/2469. Seems this got
lost in the v6 changes.

- - -

Without this, the only way to replace the arrow function is to either
manually override its `node.body`, or duplicate the arrow:

```js
// Old
ArrowFunctionExpression: function (node) {
  node.body = t.blockStatement(...);
  // Or
  return t.ArrowFunctionExpression(
    node.params,
    t.blockStatement(...),
    node.async
  );
}

// New
ArrowFunctionExpression: function() {
  this.get("body").replaceWith(t.blockStatement(...));
}
```
2016-02-20 04:36:40 -05:00
Logan Smyth
39c9066e40 Merge pull request #3359 from loganfsmyth/context-queueing-order
Queue regeneratorRuntime so it is transformed before Program#exit
2016-02-15 21:23:45 -08:00
Sebastian McKenzie
5b89849f43 Switch to klint, fix some lint rules 2016-02-14 23:25:14 +00:00
Logan Smyth
96a6d9f92e Queue regeneratorRuntime so it is transformed before Program#exit - fixes T7041 2016-02-13 22:56:03 -08:00
Henry Zhu
c2d7e95e1a add some more flow types 2016-02-04 11:07:03 -05:00
Jason
523a9d1d00 [traverse] nit 2016-02-03 17:46:34 +08:00
Jason
bbdd4aaf21 Ignore isolated paths when traversing 2016-01-23 18:39:14 +08:00
Amjad Masad
1264709226 Merge pull request #3274 from babel/fix-function-decl
Method names should not be bound to body
2016-01-18 10:57:19 -08:00
Henry Zhu
51dfd2237e Internal: temporarily remove flow types
- Will need to investigate the issue regarding eslint/babel-eslint.
2016-01-17 17:14:57 -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
Jordan Klassen
0c1eddfd52 Add documentation comment for visitors.explode 2016-01-14 13:41:19 -08:00