Add @babel/traverse tests for re-exported bindings (#12429)
This commit is contained in:
parent
285402d82f
commit
b5b95f81dc
7
packages/babel-traverse/test/fixtures/rename/re-export/input.mjs
vendored
Normal file
7
packages/babel-traverse/test/fixtures/rename/re-export/input.mjs
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// https://github.com/babel/babel/issues/9266
|
||||||
|
|
||||||
|
export function x() {
|
||||||
|
return "YES";
|
||||||
|
}
|
||||||
|
|
||||||
|
export { x as someFunction } from './lib2.js'
|
||||||
3
packages/babel-traverse/test/fixtures/rename/re-export/options.json
vendored
Normal file
3
packages/babel-traverse/test/fixtures/rename/re-export/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["./plugin"]
|
||||||
|
}
|
||||||
7
packages/babel-traverse/test/fixtures/rename/re-export/output.mjs
vendored
Normal file
7
packages/babel-traverse/test/fixtures/rename/re-export/output.mjs
vendored
Normal 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';
|
||||||
9
packages/babel-traverse/test/fixtures/rename/re-export/plugin.js
vendored
Normal file
9
packages/babel-traverse/test/fixtures/rename/re-export/plugin.js
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = function() {
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
Function(path) {
|
||||||
|
path.scope.rename("x", "a");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -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", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user