forked from babel/babel
/
plugin.js
29 lines (29 loc) 路 811 Bytes
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module.exports = function () {
return {
visitor: {
Program: {
exit(programPath) {
// Sub-traversal to ensure runs after ESM->CJS transform
programPath.traverse({
ReferencedIdentifier(path) {
if (!path.findParent(p => p.isFunction())) return;
const varName = path.node.name;
path.addComment(
"leading",
` ${varName} ${
path.scope.hasBinding(varName)
? "hasBinding"
: "no hasBinding"
}, ${
path.scope.getBinding(varName)
? "getBinding"
: "no getBinding"
} `
);
},
});
},
},
},
};
};