diff --git a/packages/babel-plugin-jsx/src/index.js b/packages/babel-plugin-jsx/src/index.js index 497014f..3084b5e 100644 --- a/packages/babel-plugin-jsx/src/index.js +++ b/packages/babel-plugin-jsx/src/index.js @@ -3,12 +3,12 @@ const tranformVueJSX = require('./transform-vue-jsx'); const sugarVModel = require('./sugar-v-model'); const sugarFragment = require('./sugar-fragment'); -module.exports = ({ types: t }, opts = {}) => ({ +module.exports = ({ types: t }) => ({ name: 'babel-plugin-jsx', inherits: syntaxJsx, visitor: { ...sugarVModel(t), - ...tranformVueJSX(t, opts), + ...tranformVueJSX(t), ...sugarFragment(t), }, }); diff --git a/packages/babel-plugin-jsx/src/transform-vue-jsx.js b/packages/babel-plugin-jsx/src/transform-vue-jsx.js index dc65deb..1077375 100644 --- a/packages/babel-plugin-jsx/src/transform-vue-jsx.js +++ b/packages/babel-plugin-jsx/src/transform-vue-jsx.js @@ -287,6 +287,7 @@ const getChildren = (t, paths) => paths && !t.isJSXEmptyExpression(value) )); + const transformJSXElement = (t, path, state) => { const directives = []; const tag = getTag(t, path); @@ -294,7 +295,7 @@ const transformJSXElement = (t, path, state) => { const h = t.callExpression(state.h, [ tag, getAttributes(t, path, state, directives), - !t.isStringLiteral(tag) + !t.isStringLiteral(tag) && !tag.name.includes('Fragment') ? t.objectExpression([ t.objectProperty( t.identifier('default'), @@ -326,9 +327,7 @@ module.exports = (t) => ({ JSXElement: { exit(path, state) { imports.forEach((m) => { - if (!state[m]) { - state[m] = addNamed(path, m, 'vue'); - } + state[m] = addNamed(path, m, 'vue'); }); path.replaceWith( transformJSXElement(t, path, state),