vue hello world项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
1.1 KiB

3 years ago
"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 importSource="@vue/composition-api",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)=>{if(hasJSX(e,t)){const n=t.get("body").filter(e=>e.isImportDeclaration()).map(e=>e.node),i=n.filter(e=>e.source.value===importSource),o=i.some(t=>t.specifiers.some(t=>e.isImportSpecifier(t)&&"h"===t.local.name));if(!o){const n=e.importSpecifier(e.identifier("h"),e.identifier("h"));i.length>0?i[0].specifiers.push(n):t.unshiftContainer("body",e.importDeclaration([n],e.stringLiteral(importSource)))}}};var index=e=>{const t=e.types;return{inherits:syntaxJsx,visitor:{Program(e){remove$createElement(t,e),autoImportH(t,e)}}}};module.exports=index;