first commit
This commit is contained in:
54
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/README.md
generated
vendored
Normal file
54
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/README.md
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
## @vue/babel-sugar-composition-api-inject-h
|
||||
|
||||
> Ported from [luwanquan/babel-preset-vca-jsx](https://github.com/luwanquan/babel-preset-vca-jsx) by [@luwanquan](https://github.com/luwanquan)
|
||||
|
||||
Syntactic sugar for automatic `h` inject in JSX with @vue/composition-api.
|
||||
|
||||
### Babel Compatibility Notes
|
||||
|
||||
- This repo is only compatible with Babel 7.x
|
||||
|
||||
### Usage
|
||||
|
||||
Install the dependencies:
|
||||
|
||||
```sh
|
||||
# for yarn:
|
||||
yarn add @vue/babel-sugar-composition-api-inject-h
|
||||
# for npm:
|
||||
npm install @vue/babel-sugar-composition-api-inject-h --save
|
||||
```
|
||||
|
||||
In your `.babelrc`:
|
||||
|
||||
```json
|
||||
{
|
||||
"plugins": ["@vue/babel-sugar-composition-api-inject-h"]
|
||||
}
|
||||
```
|
||||
|
||||
However it is recommended to use the [configurable preset](../babel-preset-jsx/README.md) instead.
|
||||
|
||||
### Details
|
||||
|
||||
This plugin automatically injects `h` in every method that has JSX. By using this plugin you don't have to always import `h` from `@vue/composition-api`.
|
||||
|
||||
```js
|
||||
// Without @vue/babel-sugar-inject-h
|
||||
import { h } from '@vue/composition-api'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
return () => <button />
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
// With @vue/babel-sugar-inject-h
|
||||
export default {
|
||||
setup() {
|
||||
return () => <button />
|
||||
},
|
||||
}
|
||||
```
|
1
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/dist/plugin.js
generated
vendored
Normal file
1
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/dist/plugin.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var syntaxJsx=_interopDefault(require("@babel/plugin-syntax-jsx"));const hasJSX=(e,t)=>{const n={hasJSX:!1};t.traverse({JSXElement(){this.hasJSX=!0}},n);return n.hasJSX},remove$createElement=(e,t)=>{t.traverse({ObjectMethod(t){"setup"===t.node.key.name&&t.traverse({VariableDeclaration(t){t.traverse({MemberExpression(n){e.isThisExpression(n.node.object)&&e.isIdentifier(n.node.property)&&"$createElement"===n.node.property.name&&t.remove()}})}})}})},autoImportH=(e,t,n)=>{if(hasJSX(e,t)){const i=t.get("body").filter(e=>e.isImportDeclaration()).map(e=>e.node),o=i.filter(e=>e.source.value===n),r=o.some(t=>t.specifiers.some(t=>e.isImportSpecifier(t)&&"h"===t.local.name));if(!r){const i=e.importSpecifier(e.identifier("h"),e.identifier("h"));o.length>0?o[0].specifiers.push(i):t.unshiftContainer("body",e.importDeclaration([i],e.stringLiteral(n)))}}};var index=(e,{importSource:importSource="@vue/composition-api"}={})=>{const t=e.types;return{inherits:syntaxJsx,visitor:{Program(e){remove$createElement(t,e),autoImportH(t,e,importSource)}}}};module.exports=index;
|
46
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/package.json
generated
vendored
Normal file
46
app_vue/node_modules/@vue/babel-sugar-composition-api-inject-h/package.json
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@vue/babel-sugar-composition-api-inject-h",
|
||||
"version": "1.4.0",
|
||||
"description": "Babel syntactic sugar for h automatic injection for Vue JSX with @vue/composition-api",
|
||||
"main": "dist/plugin.js",
|
||||
"repository": "https://github.com/vuejs/jsx/tree/master/packages/babel-sugar-composition-api-inject-h",
|
||||
"author": "luwanquan <luwanquan@f-road.com.cn>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [],
|
||||
"scripts": {
|
||||
"prepublish": "yarn build",
|
||||
"build": "rollup -c",
|
||||
"build:test": "rollup -c rollup.config.testing.js",
|
||||
"pretest": "yarn build:test",
|
||||
"test": "nyc --reporter=html --reporter=text-summary ava -v test/test.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.0",
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/preset-env": "^7.2.0",
|
||||
"ava": "^0.25.0",
|
||||
"nyc": "^13.1.0",
|
||||
"rollup": "^0.67.4",
|
||||
"rollup-plugin-babel": "4.0.3",
|
||||
"rollup-plugin-istanbul": "^2.0.1",
|
||||
"rollup-plugin-uglify-es": "^0.0.1",
|
||||
"vue": "^2.5.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-jsx": "^7.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"dist",
|
||||
"test"
|
||||
]
|
||||
},
|
||||
"gitHead": "6566e12067f5d6c02d3849b574a1b84de5634008"
|
||||
}
|
Reference in New Issue
Block a user