[import()] Initial support for dynamic-import (#4699)
* [import()] Initial support for function-like import * [import()] Renaming import-functions to dynamic-import * [stage-2] Fixing lint error * add to package.json
This commit is contained in:
parent
b8eeddf960
commit
391e5bd813
@ -205,6 +205,7 @@ These just enable the transform plugins to be able to parse certain features (th
|
|||||||
| [`babel-plugin-syntax-flow`](/packages/babel-plugin-syntax-flow) | [](https://www.npmjs.com/package/babel-plugin-syntax-flow) |
|
| [`babel-plugin-syntax-flow`](/packages/babel-plugin-syntax-flow) | [](https://www.npmjs.com/package/babel-plugin-syntax-flow) |
|
||||||
| [`babel-plugin-syntax-function-bind`](/packages/babel-plugin-syntax-function-bind) | [](https://www.npmjs.com/package/babel-plugin-syntax-function-bind) |
|
| [`babel-plugin-syntax-function-bind`](/packages/babel-plugin-syntax-function-bind) | [](https://www.npmjs.com/package/babel-plugin-syntax-function-bind) |
|
||||||
| [`babel-plugin-syntax-function-sent`](/packages/babel-plugin-syntax-function-sent) | [](https://www.npmjs.com/package/babel-plugin-syntax-function-sent) |
|
| [`babel-plugin-syntax-function-sent`](/packages/babel-plugin-syntax-function-sent) | [](https://www.npmjs.com/package/babel-plugin-syntax-function-sent) |
|
||||||
|
| [`babel-plugin-syntax-dynamic-import`](/packages/babel-plugin-syntax-dynamic-import) | [](https://www.npmjs.com/package/babel-plugin-syntax-dynamic-import) |
|
||||||
| [`babel-plugin-syntax-jsx`](/packages/babel-plugin-syntax-jsx) | [](https://www.npmjs.com/package/babel-plugin-syntax-jsx) |
|
| [`babel-plugin-syntax-jsx`](/packages/babel-plugin-syntax-jsx) | [](https://www.npmjs.com/package/babel-plugin-syntax-jsx) |
|
||||||
| [`babel-plugin-syntax-object-rest-spread`](/packages/babel-plugin-syntax-object-rest-spread) | [](https://www.npmjs.com/package/babel-plugin-syntax-object-rest-spread) |
|
| [`babel-plugin-syntax-object-rest-spread`](/packages/babel-plugin-syntax-object-rest-spread) | [](https://www.npmjs.com/package/babel-plugin-syntax-object-rest-spread) |
|
||||||
|
|
||||||
|
|||||||
3
packages/babel-plugin-syntax-dynamic-import/.npmignore
Normal file
3
packages/babel-plugin-syntax-dynamic-import/.npmignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
*.log
|
||||||
|
src
|
||||||
35
packages/babel-plugin-syntax-dynamic-import/README.md
Normal file
35
packages/babel-plugin-syntax-dynamic-import/README.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# babel-plugin-syntax-dynamic-import
|
||||||
|
|
||||||
|
Allow parsing of `import()`.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install babel-plugin-syntax-dynamic-import
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Via `.babelrc` (Recommended)
|
||||||
|
|
||||||
|
**.babelrc**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"plugins": ["syntax-dynamic-import"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Via CLI
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ babel --plugins syntax-dynamic-import script.js
|
||||||
|
```
|
||||||
|
|
||||||
|
### Via Node API
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
require("babel-core").transform("code", {
|
||||||
|
plugins: ["syntax-dynamic-import"]
|
||||||
|
});
|
||||||
|
```
|
||||||
13
packages/babel-plugin-syntax-dynamic-import/package.json
Normal file
13
packages/babel-plugin-syntax-dynamic-import/package.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "babel-plugin-syntax-dynamic-import",
|
||||||
|
"version": "6.13.0",
|
||||||
|
"description": "Allow parsing of import()",
|
||||||
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-dynamic-import",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"keywords": [
|
||||||
|
"babel-plugin"
|
||||||
|
],
|
||||||
|
"dependencies": {},
|
||||||
|
"devDependencies": {}
|
||||||
|
}
|
||||||
7
packages/babel-plugin-syntax-dynamic-import/src/index.js
Normal file
7
packages/babel-plugin-syntax-dynamic-import/src/index.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export default function () {
|
||||||
|
return {
|
||||||
|
manipulateOptions(opts, parserOpts) {
|
||||||
|
parserOpts.plugins.push("dynamicImport");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-plugin-transform-class-properties": "^6.16.0",
|
"babel-plugin-transform-class-properties": "^6.16.0",
|
||||||
"babel-plugin-transform-decorators": "^6.13.0",
|
"babel-plugin-transform-decorators": "^6.13.0",
|
||||||
|
"babel-plugin-syntax-dynamic-import": "^6.13.0",
|
||||||
"babel-preset-stage-3": "^6.17.0"
|
"babel-preset-stage-3": "^6.17.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,14 @@ import presetStage3 from "babel-preset-stage-3";
|
|||||||
|
|
||||||
import transformClassProperties from "babel-plugin-transform-class-properties";
|
import transformClassProperties from "babel-plugin-transform-class-properties";
|
||||||
import transformDecorators from "babel-plugin-transform-decorators";
|
import transformDecorators from "babel-plugin-transform-decorators";
|
||||||
|
import syntaxDynamicImport from "babel-plugin-syntax-dynamic-import";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
presets: [
|
presets: [
|
||||||
presetStage3
|
presetStage3
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
|
syntaxDynamicImport,
|
||||||
transformClassProperties,
|
transformClassProperties,
|
||||||
transformDecorators
|
transformDecorators
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user