Skip to content

Commit

Permalink
Add @babel/traverse tests for re-exported bindings (#12429)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 6, 2020
1 parent 285402d commit b5b95f8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
@@ -0,0 +1,7 @@
// https://github.com/babel/babel/issues/9266

export function x() {
return "YES";
}

export { x as someFunction } from './lib2.js'
@@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}
@@ -0,0 +1,7 @@
// https://github.com/babel/babel/issues/9266
function a() {
return "YES";
}

export { a as x };
export { x as someFunction } from './lib2.js';
@@ -0,0 +1,9 @@
module.exports = function() {
return {
visitor: {
Function(path) {
path.scope.rename("x", "a");
}
}
};
}
7 changes: 7 additions & 0 deletions packages/babel-traverse/test/scope.js
Expand Up @@ -351,6 +351,13 @@ describe("scope", () => {

expect(path.scope.generateUid("Cls")).toBe("_Cls2");
});

it("re-exports are not references", () => {
const path = getPath("export { x } from 'y'", {
sourceType: "module",
});
expect(path.scope.hasGlobal("x")).toBe(false);
});
});

describe("duplicate bindings", () => {
Expand Down

0 comments on commit b5b95f8

Please sign in to comment.