UNPKG

583 BJavaScriptView Raw
1const {declare} = require('@babel/helper-plugin-utils')
2
3class BabelPluginExtractImportNames {
4 constructor() {
5 const names = []
6 this.state = {names}
7
8 this.plugin = declare(api => {
9 api.assertVersion(7)
10
11 return {
12 visitor: {
13 ImportDeclaration(path) {
14 path.traverse({
15 Identifier(path) {
16 if (path.key === 'local') {
17 names.push(path.node.name)
18 }
19 }
20 })
21 }
22 }
23 }
24 })
25 }
26}
27
28module.exports = BabelPluginExtractImportNames