Skip to content

Different scope.binding.references in Babel v7 and Babel v8 #17566

@coderaiser

Description

@coderaiser

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

In Babel v7:

import * as parser from "@babel/parser";
import traverse from "@babel/traverse";
import * as t from "@babel/types";

const code = `
    export const two = () => {};
    export const one = two;
`;

const ast = parser.parse(code, {
  sourceType: "module",
});

traverse(ast, {
  Identifier(path) {
    const binding = path.scope.getBinding('two');
    console.log(binding.references);
  }
});

Produces:

2
2
2

In Babel v8 result is:

1
1
1

Which one is correct?

Configuration file name

No response

Configuration

No response

Current and expected behavior

Expected references to be aligned with Babel v7

Environment

Babel v8 Beta 3

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions