Subscribe on changes!

Vue/server-renderer tsx support

avatar
Feb 7th 2021

Version

3.0.5

Reproduction link

https://github.com/seanaye/vue3-tsx-tailwind

Steps to reproduce

  1. clone repro
  2. yarn
  3. yarn dev
  4. Open localhost:3000

Cannot read property 'forEach' of undefined

This is because ctx is not being populated via the renderToString function from @vue/server-renderer when using tsx files. (see line 16 in server-entry.ts)

I have copied the files from the vite ssg example repo, but I am using .tsx vue files instead of standard vue SFC files.

What is expected?

App should render with vite SSR

What is actually happening?

The renderToString function from @vue/server-renderer is not populating the ctx object found on line 16 inside of server-entry.ts

I am 90% sure that vue server renderer is not recognizing the .tsx files since I have tried changing the references to .vue files and the app renders as expected.

avatar
Feb 8th 2021

You should submit the issue to Vite, @vite/plugin-vue injects modules into ssr context by wrapping user setup, see https://github.com/vitejs/vite/blob/main/packages/plugin-vue/src/main.ts#L133. I think the @vite/plugin-vue-jsx needs to do the same thing.