@babel/traverse 7.0.0-beta.49 → 7.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @babel/traverse might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,33 +1,19 @@
1
1
  # @babel/traverse
2
2
 
3
- > @babel/traverse maintains the overall tree state, and is responsible for replacing, removing, and adding nodes.
3
+ > The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
4
+
5
+ See our website [@babel/traverse](https://babeljs.io/docs/en/next/babel-traverse.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen) associated with this package.
4
6
 
5
7
  ## Install
6
8
 
9
+ Using npm:
10
+
7
11
  ```sh
8
- $ npm install --save @babel/traverse
12
+ npm install --save-dev @babel/traverse
9
13
  ```
10
14
 
11
- ## Usage
12
-
13
- We can use it alongside the babel parser to traverse and update nodes:
14
-
15
- ```js
16
- import * as parser from "@babel/parser";
17
- import traverse from "@babel/traverse";
15
+ or using yarn:
18
16
 
19
- const code = `function square(n) {
20
- return n * n;
21
- }`;
22
-
23
- const ast = parser.parse(code);
24
-
25
- traverse(ast, {
26
- enter(path) {
27
- if (path.isIdentifier({ name: "n" })) {
28
- path.node.name = "x";
29
- }
30
- }
31
- });
17
+ ```sh
18
+ yarn add @babel/traverse --dev
32
19
  ```
33
- [:book: **Read the full docs here**](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse)
@@ -311,12 +311,8 @@ function _resolve(dangerous, resolved) {
311
311
  function isConstantExpression() {
312
312
  if (this.isIdentifier()) {
313
313
  const binding = this.scope.getBinding(this.node.name);
314
-
315
- if (!binding) {
316
- return false;
317
- }
318
-
319
- return binding.constant && binding.path.get("init").isConstantExpression();
314
+ if (!binding) return false;
315
+ return binding.constant;
320
316
  }
321
317
 
322
318
  if (this.isLiteral()) {
@@ -110,7 +110,11 @@ class Renamer {
110
110
  const parentDeclar = path.find(path => path.isDeclaration() || path.isFunctionExpression() || path.isClassExpression());
111
111
 
112
112
  if (parentDeclar) {
113
- this.maybeConvertFromExportDeclaration(parentDeclar);
113
+ const bindingIds = parentDeclar.getBindingIdentifiers();
114
+
115
+ if (bindingIds[oldName] === binding.identifier) {
116
+ this.maybeConvertFromExportDeclaration(parentDeclar);
117
+ }
114
118
  }
115
119
 
116
120
  scope.traverse(block || scope.block, renameVisitor, this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babel/traverse",
3
- "version": "7.0.0-beta.49",
3
+ "version": "7.0.0-beta.52",
4
4
  "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
5
5
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
6
6
  "homepage": "https://babeljs.io/",
@@ -8,18 +8,18 @@
8
8
  "repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse",
9
9
  "main": "lib/index.js",
10
10
  "dependencies": {
11
- "@babel/code-frame": "7.0.0-beta.49",
12
- "@babel/generator": "7.0.0-beta.49",
13
- "@babel/helper-function-name": "7.0.0-beta.49",
14
- "@babel/helper-split-export-declaration": "7.0.0-beta.49",
15
- "@babel/parser": "7.0.0-beta.49",
16
- "@babel/types": "7.0.0-beta.49",
11
+ "@babel/code-frame": "7.0.0-beta.52",
12
+ "@babel/generator": "7.0.0-beta.52",
13
+ "@babel/helper-function-name": "7.0.0-beta.52",
14
+ "@babel/helper-split-export-declaration": "7.0.0-beta.52",
15
+ "@babel/parser": "7.0.0-beta.52",
16
+ "@babel/types": "7.0.0-beta.52",
17
17
  "debug": "^3.1.0",
18
18
  "globals": "^11.1.0",
19
19
  "invariant": "^2.2.0",
20
20
  "lodash": "^4.17.5"
21
21
  },
22
22
  "devDependencies": {
23
- "@babel/helper-plugin-test-runner": "7.0.0-beta.49"
23
+ "@babel/helper-plugin-test-runner": "7.0.0-beta.52"
24
24
  }
25
25
  }
package/.npmignore DELETED
@@ -1,3 +0,0 @@
1
- src
2
- test
3
- *.log