From 64cbb2dd58aa3504a60162f356ac5266018f4293 Mon Sep 17 00:00:00 2001 From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:43:13 +0800 Subject: [PATCH] feat: exclude template tag to support jsx-directive (#106) --- packages/core/src/compiler/template.ts | 2 +- packages/playground/vue3/src/Welcome.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/compiler/template.ts b/packages/core/src/compiler/template.ts index 0dd5a5c..775f13a 100644 --- a/packages/core/src/compiler/template.ts +++ b/packages/core/src/compiler/template.ts @@ -77,7 +77,7 @@ export async function compileSFCTemplate( babelTraverse(ast, { enter({ node }) { - if (node.type === 'JSXElement') { + if (node.type === 'JSXElement' && !EXCLUDE_TAG.includes(s.slice(node.openingElement.name.start, node.openingElement.name.end))) { if (node.openingElement.attributes.some(attr => attr.type !== 'JSXSpreadAttribute' && attr.name.name === KEY_DATA, )) return diff --git a/packages/playground/vue3/src/Welcome.tsx b/packages/playground/vue3/src/Welcome.tsx index 4939296..0c1a989 100644 --- a/packages/playground/vue3/src/Welcome.tsx +++ b/packages/playground/vue3/src/Welcome.tsx @@ -4,6 +4,11 @@ export default defineComponent({ name: 'Welcome', setup() { const text = 'Welcome to here 🚀 .' - return () =>
{text}
+ return () => ( ++ {text} + {text} +
+ ) }, })