added basic support for module attributes and tests updated (#10962)
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
*.log
|
||||
src
|
||||
test
|
||||
19
packages/babel-plugin-syntax-module-attributes/README.md
Normal file
19
packages/babel-plugin-syntax-module-attributes/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# @babel/plugin-syntax-module-attributes
|
||||
|
||||
> Allow parsing of the module attributes in the import statements
|
||||
|
||||
See our website [@babel/plugin-syntax-module-attributes](https://babeljs.io/docs/en/next/babel-plugin-syntax-module-attributes.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-syntax-module-attributes
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-syntax-module-attributes --dev
|
||||
```
|
||||
23
packages/babel-plugin-syntax-module-attributes/package.json
Normal file
23
packages/babel-plugin-syntax-module-attributes/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@babel/plugin-syntax-module-attributes",
|
||||
"version": "7.8.3",
|
||||
"description": "Allow parsing of the module attributes in the import statement",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-module-attributes",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.8.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.3"
|
||||
}
|
||||
}
|
||||
21
packages/babel-plugin-syntax-module-attributes/src/index.js
Normal file
21
packages/babel-plugin-syntax-module-attributes/src/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
|
||||
export default declare((api, { version }) => {
|
||||
api.assertVersion(7);
|
||||
|
||||
if (typeof version !== "string" || version !== "apr-2020") {
|
||||
throw new Error(
|
||||
"The 'moduleAttributes' plugin requires a 'version' option," +
|
||||
" representing the last proposal update. Currently, the" +
|
||||
" only supported value is 'apr-2020'.",
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
name: "syntax-module-attributes",
|
||||
|
||||
manipulateOptions(opts, parserOpts) {
|
||||
parserOpts.plugins.push(["moduleAttributes", { version }]);
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user