source: trip-planner-front/node_modules/babel-plugin-dynamic-import-node/README.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# babel-plugin-dynamic-import-node
2
3Babel plugin to transpile `import()` to a deferred `require()`, for node. Matches the [proposed spec](https://github.com/domenic/proposal-import-function).
4
5**NOTE:** Babylon >= v6.12.0 is required to correctly parse dynamic imports.
6
7## Installation
8
9```sh
10npm install babel-plugin-dynamic-import-node --save-dev
11```
12
13## Usage
14
15### Via `.babelrc` (Recommended)
16
17**.babelrc**
18
19```json
20{
21 "plugins": ["dynamic-import-node"]
22}
23```
24
25#### Options
26
27- *`noInterop`* - A boolean value, that if true will not interop the require calls. Useful to avoid using `require('module').default` on commonjs modules.
28
29```json
30{
31 "plugins": [
32 ["dynamic-import-node", { "noInterop": true }]
33 ]
34}
35```
36
37### Via CLI
38
39```sh
40$ babel --plugins dynamic-import-node script.js
41```
42
43### Via Node API
44
45```javascript
46require('babel-core').transform('code', {
47 plugins: ['dynamic-import-node']
48});
49```
50
51### Code Example
52```javascript
53Promise.all([
54 import('./lib/import1'),
55 import('./lib/import2')
56 ]).then(([
57 Import1,
58 Import2
59 ]) => {
60 console.log(Import1);
61 /* CODE HERE*/
62 });
63```
Note: See TracBrowser for help on using the repository browser.