1 | const {declare} = require('@babel/helper-plugin-utils')
|
2 |
|
3 | class 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 |
|
28 | module.exports = BabelPluginExtractImportNames
|