@vue/babel-plugin-jsx
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -27,3 +27,4 @@ import * as t from '@babel/types'; | ||
Program: { | ||
enter(path: NodePath, state: State): void; | ||
enter(path: NodePath<t.Program>, state: State): void; | ||
exit(path: NodePath<t.Program>): void; | ||
}; | ||
@@ -30,0 +31,0 @@ JSXFragment: { |
@@ -121,3 +121,26 @@ "use strict"; | ||
}, | ||
exit(path) { | ||
const body = path.get('body'); | ||
const specifiersMap = new Map(); | ||
body.filter((nodePath) => t.isImportDeclaration(nodePath.node) | ||
&& nodePath.node.source.value === 'vue') | ||
.forEach((nodePath) => { | ||
const { specifiers } = nodePath.node; | ||
let shouldRemove = false; | ||
specifiers.forEach((specifier) => { | ||
if (!specifier.loc && t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) { | ||
specifiersMap.set(specifier.imported.name, specifier); | ||
shouldRemove = true; | ||
} | ||
}); | ||
if (shouldRemove) { | ||
nodePath.remove(); | ||
} | ||
}); | ||
const specifiers = [...specifiersMap.keys()].map((imported) => specifiersMap.get(imported)); | ||
if (specifiers.length) { | ||
path.unshiftContainer('body', t.importDeclaration(specifiers, t.stringLiteral('vue'))); | ||
} | ||
}, | ||
} }), | ||
}); |
{ | ||
"name": "@vue/babel-plugin-jsx", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Babel plugin for Vue 3.0 JSX", | ||
@@ -31,3 +31,3 @@ "author": "Amour1688 <lcz_1996@foxmail.com>", | ||
"@babel/types": "^7.0.0", | ||
"@vue/babel-helper-vue-transform-on": "^1.0.0", | ||
"@vue/babel-helper-vue-transform-on": "^1.0.2", | ||
"camelcase": "^6.0.0", | ||
@@ -34,0 +34,0 @@ "html-tags": "^3.1.0", |
@@ -67,3 +67,3 @@ # Babel Plugin JSX for Vue 3.0 | ||
Whether to enable `object slots` (mentioned below the document) syntax". It might be useful in JSX, but it will add a lot of `_isSlot` condition expressions which increases your bundle size. And `v-slots` is still available even if `enableObjectSlots` is turned off. | ||
Whether to enable `object slots` (mentioned below the document) syntax". It might be useful in JSX, but it will add a lot of `_isSlot` condition expressions which increase your bundle size. And `v-slots` is still available even if `enableObjectSlots` is turned off. | ||
@@ -70,0 +70,0 @@ ## Syntax |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58147
1250