1 | # Dynamic import support in acorn
|
2 |
|
3 | This is plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript.
|
4 |
|
5 | For more information, check out the [proposal repo](https://github.com/tc39/proposal-dynamic-import).
|
6 |
|
7 | ## Usage
|
8 |
|
9 | Importing this module gives you a plugin that can be used to extend an Acorn parser:
|
10 |
|
11 | ```js
|
12 | import Parser from 'acorn';
|
13 | import dynamicImport from 'acorn-dynamic-import';
|
14 |
|
15 | Parser.extend(dynamicImport).parse('import("something");');
|
16 | ```
|
17 |
|
18 | To extend the AST walker for dynamic imports, you can injecting the new node type into [`acorn-walk`](https://www.npmjs.com/package/acorn-walk) like this:
|
19 |
|
20 | ```js
|
21 | import inject from 'acorn-dynamic-import/lib/walk';
|
22 | import * as acornWalk from 'acorn-walk';
|
23 |
|
24 | const walk = inject(acornWalk);
|
25 | ```
|
26 |
|
27 | ## License
|
28 |
|
29 | This plugin is issued under the [MIT license](./LICENSE).
|