Add @babel/traverse tests for re-exported bindings (#12429)

This commit is contained in:
Nicolò Ribaudo 2020-12-06 19:33:21 +01:00 committed by GitHub
parent 285402d82f
commit b5b95f81dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 0 deletions

View File

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

View File

@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}

View File

@ -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';

View File

@ -0,0 +1,9 @@
module.exports = function() {
return {
visitor: {
Function(path) {
path.scope.rename("x", "a");
}
}
};
}

View File

@ -351,6 +351,13 @@ describe("scope", () => {
expect(path.scope.generateUid("Cls")).toBe("_Cls2"); 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", () => { describe("duplicate bindings", () => {