expose import.meta syntax parser option as plugin (#7008)
This commit is contained in:
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");
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user