diff --git a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts
index d4a0167c0ee83e..f4a490582f2cd1 100644
--- a/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts
+++ b/packages/playground/ssr-vue/__tests__/ssr-vue.spec.ts
@@ -80,6 +80,10 @@ test('asset', async () => {
)
})
+test('jsx', async () => {
+ expect(await page.textContent('.jsx')).toMatch('from JSX')
+})
+
test('hydration', async () => {
expect(await page.textContent('button')).toMatch('0')
await page.click('button')
diff --git a/packages/playground/ssr-vue/src/components/Foo.jsx b/packages/playground/ssr-vue/src/components/Foo.jsx
new file mode 100644
index 00000000000000..d810b40886c596
--- /dev/null
+++ b/packages/playground/ssr-vue/src/components/Foo.jsx
@@ -0,0 +1,9 @@
+import { defineComponent } from 'vue'
+
+// named exports w/ variable declaration: ok
+export const Foo = defineComponent({
+ name: 'foo',
+ setup() {
+ return () =>
from JSX
+ }
+})
\ No newline at end of file
diff --git a/packages/playground/ssr-vue/src/pages/Home.vue b/packages/playground/ssr-vue/src/pages/Home.vue
index f1b3c4742b721a..bec719062d6805 100644
--- a/packages/playground/ssr-vue/src/pages/Home.vue
+++ b/packages/playground/ssr-vue/src/pages/Home.vue
@@ -1,13 +1,15 @@
Home
-
+
count is: {{ state.count }}
+
diff --git a/packages/playground/ssr-vue/vite.config.js b/packages/playground/ssr-vue/vite.config.js
index d20f4dd734e760..3c3ba42947a538 100644
--- a/packages/playground/ssr-vue/vite.config.js
+++ b/packages/playground/ssr-vue/vite.config.js
@@ -1,10 +1,11 @@
const vuePlugin = require('@vitejs/plugin-vue')
+const vueJsx = require('@vitejs/plugin-vue-jsx')
/**
* @type {import('vite').UserConfig}
*/
module.exports = {
- plugins: [vuePlugin()],
+ plugins: [vuePlugin(), vueJsx()],
build: {
minify: false
}
diff --git a/packages/plugin-vue-jsx/index.js b/packages/plugin-vue-jsx/index.js
index 86d27be65008b2..cdacfe1ae542d2 100644
--- a/packages/plugin-vue-jsx/index.js
+++ b/packages/plugin-vue-jsx/index.js
@@ -5,7 +5,7 @@ const importMeta = require('@babel/plugin-syntax-import-meta')
const hash = require('hash-sum')
/**
- * @param {import('.').Options} options
+ * @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions} options
* @returns {import('vite').Plugin}
*/
function vueJsxPlugin(options = {}) {
@@ -35,7 +35,7 @@ function vueJsxPlugin(options = {}) {
needSourceMap = config.command === 'serve' || !!config.build.sourcemap
},
- transform(code, id) {
+ transform(code, id, ssr) {
if (/\.[jt]sx$/.test(id)) {
const plugins = [importMeta, [jsx, options]]
if (id.endsWith('.tsx')) {
@@ -53,7 +53,7 @@ function vueJsxPlugin(options = {}) {
sourceFileName: id
})
- if (!needHmr) {
+ if (ssr || !needHmr) {
return {
code: result.code,
map: result.map