expose import.meta syntax parser option as plugin (#7008)

This commit is contained in:
dnalborczyk
2017-12-16 22:06:23 +01:00
committed by Brian Ng
parent 209a598d51
commit ed4d90b33d
8 changed files with 68 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
src
test
*.log

View 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"]
});
```

View 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"
}
}

View File

@@ -0,0 +1,7 @@
export default function() {
return {
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("importMeta");
},
};
}