From 41f44f486e8f37a217caf188d97f765fee350979 Mon Sep 17 00:00:00 2001 From: wattanx Date: Fri, 5 Jan 2024 14:58:40 +0900 Subject: [PATCH 1/2] feat: support jsx/tsx --- packages/bridge/src/typescript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bridge/src/typescript.ts b/packages/bridge/src/typescript.ts index 79519742..ad2972fc 100644 --- a/packages/bridge/src/typescript.ts +++ b/packages/bridge/src/typescript.ts @@ -21,7 +21,7 @@ export function setupTypescript () { nuxt.options.build.babel.plugins.unshift( _require.resolve('@babel/plugin-proposal-optional-chaining'), _require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), - _require.resolve('@babel/plugin-transform-typescript') + [_require.resolve('@babel/plugin-transform-typescript'), { isTSX: true }] ) extendWebpackConfig((config) => { From 6ca891b18da30334a8c765f0574a9dd125a36057 Mon Sep 17 00:00:00 2001 From: wattanx Date: Fri, 5 Jan 2024 14:58:56 +0900 Subject: [PATCH 2/2] chore: add jsx test --- playground/components/JSX.jsx | 6 ++++++ playground/components/JsxComponent.vue | 7 +++++++ playground/pages/jsx.vue | 10 ++++++++++ test/bridge.test.ts | 6 ++++++ 4 files changed, 29 insertions(+) create mode 100644 playground/components/JSX.jsx create mode 100644 playground/components/JsxComponent.vue create mode 100644 playground/pages/jsx.vue diff --git a/playground/components/JSX.jsx b/playground/components/JSX.jsx new file mode 100644 index 00000000..8602fb50 --- /dev/null +++ b/playground/components/JSX.jsx @@ -0,0 +1,6 @@ +export default defineComponent({ + name: 'JSX', + render () { + return
JSX component with jsx extention
+ } +}) diff --git a/playground/components/JsxComponent.vue b/playground/components/JsxComponent.vue new file mode 100644 index 00000000..13017898 --- /dev/null +++ b/playground/components/JsxComponent.vue @@ -0,0 +1,7 @@ + diff --git a/playground/pages/jsx.vue b/playground/pages/jsx.vue new file mode 100644 index 00000000..c8713b2e --- /dev/null +++ b/playground/pages/jsx.vue @@ -0,0 +1,10 @@ + + + diff --git a/test/bridge.test.ts b/test/bridge.test.ts index 2d27856d..fd9156c3 100644 --- a/test/bridge.test.ts +++ b/test/bridge.test.ts @@ -95,6 +95,12 @@ describe('pages', () => { it('uses server Vue build', async () => { expect(await $fetch('/')).toContain('Rendered on server: true') }) + it('supports jsx', async () => { + const html = await $fetch('/jsx') + + expect(html).toContain('JSX component') + expect(html).toContain('JSX component with jsx extention') + }) }) describe('legacy async data', () => {