UNPKG

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