expose import.meta syntax parser option as plugin (#7008)
This commit is contained in:
parent
209a598d51
commit
ed4d90b33d
3
packages/babel-plugin-syntax-import-meta/.npmignore
Normal file
3
packages/babel-plugin-syntax-import-meta/.npmignore
Normal file
@ -0,0 +1,3 @@
|
||||
src
|
||||
test
|
||||
*.log
|
||||
35
packages/babel-plugin-syntax-import-meta/README.md
Normal file
35
packages/babel-plugin-syntax-import-meta/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# @babel/plugin-syntax-import-meta
|
||||
|
||||
> Allow parsing of `import.meta`.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-syntax-import-meta
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Via `.babelrc` (Recommended)
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": ["@babel/plugin-syntax-import-meta"]
|
||||
}
|
||||
```
|
||||
|
||||
### Via CLI
|
||||
|
||||
```sh
|
||||
babel --plugins @babel/plugin-syntax-import-meta script.js
|
||||
```
|
||||
|
||||
### Via Node API
|
||||
|
||||
```javascript
|
||||
require("@babel/core").transform("code", {
|
||||
plugins: ["@babel/plugin-syntax-import-meta"]
|
||||
});
|
||||
```
|
||||
17
packages/babel-plugin-syntax-import-meta/package.json
Normal file
17
packages/babel-plugin-syntax-import-meta/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@babel/plugin-syntax-import-meta",
|
||||
"version": "7.0.0-beta.35",
|
||||
"description": "Allow parsing of import.meta",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-import-meta",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.0.0-beta.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.35"
|
||||
}
|
||||
}
|
||||
7
packages/babel-plugin-syntax-import-meta/src/index.js
Normal file
7
packages/babel-plugin-syntax-import-meta/src/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default function() {
|
||||
return {
|
||||
manipulateOptions(opts, parserOpts) {
|
||||
parserOpts.plugins.push("importMeta");
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -13,7 +13,8 @@
|
||||
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.35",
|
||||
"@babel/plugin-proposal-optional-catch-binding": "7.0.0-beta.35",
|
||||
"@babel/plugin-proposal-unicode-property-regex": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.35"
|
||||
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-import-meta": "7.0.0-beta.35"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "7.0.0-beta.35"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import";
|
||||
import syntaxImportMeta from "@babel/plugin-syntax-import-meta";
|
||||
import transformAsyncGeneratorFunctions from "@babel/plugin-proposal-async-generator-functions";
|
||||
import transformClassProperties from "@babel/plugin-proposal-class-properties";
|
||||
import transformObjectRestSpread from "@babel/plugin-proposal-object-rest-spread";
|
||||
@ -26,6 +27,7 @@ export default function(context, opts = {}) {
|
||||
return {
|
||||
plugins: [
|
||||
syntaxDynamicImport,
|
||||
syntaxImportMeta,
|
||||
transformAsyncGeneratorFunctions,
|
||||
[transformClassProperties, { loose }],
|
||||
[transformObjectRestSpread, { useBuiltIns }],
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
"@babel/plugin-syntax-flow": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-function-bind": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-function-sent": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-import-meta": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-jsx": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.35",
|
||||
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.35",
|
||||
|
||||
@ -152,6 +152,7 @@ registerPlugins({
|
||||
"syntax-flow": require("@babel/plugin-syntax-flow"),
|
||||
"syntax-function-bind": require("@babel/plugin-syntax-function-bind"),
|
||||
"syntax-function-sent": require("@babel/plugin-syntax-function-sent"),
|
||||
"syntax-import-meta": require("@babel/plugin-syntax-import-meta"),
|
||||
"syntax-jsx": require("@babel/plugin-syntax-jsx"),
|
||||
"syntax-object-rest-spread": require("@babel/plugin-syntax-object-rest-spread"),
|
||||
"syntax-optional-catch-binding": require("@babel/plugin-syntax-optional-catch-binding"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user