1 | # `babel-plugin-extract-import-names`
|
2 |
|
3 | Babel plugin that extracts all variable names from
|
4 | import statements. Used by the [MDX](https://mdxjs.com)
|
5 | pragma.
|
6 |
|
7 | ## Installation
|
8 |
|
9 | ```sh
|
10 | yarn add babel-plugin-extract-import-names
|
11 | ```
|
12 |
|
13 | ## Usage
|
14 |
|
15 | ```js
|
16 | const babel = require('@babel/core')
|
17 |
|
18 | const BabelPluginExtractImportNames = require('babel-plugin-extract-import-names')
|
19 |
|
20 | const jsx = `
|
21 | import Foo from 'bar'
|
22 | import { Bar } from 'baz'
|
23 | `
|
24 |
|
25 | const plugin = new BabelPluginExtractImportNames()
|
26 |
|
27 | const result = babel.transform(jsx, {
|
28 | configFile: false,
|
29 | plugins: [plugin.plugin]
|
30 | })
|
31 |
|
32 | console.log(plugin.state.names)
|
33 | ```
|
34 |
|
35 | ## License
|
36 |
|
37 | MIT
|