question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support SSR in plugin-vue-jsx

See original GitHub issue

Describe the bug

Vite is unable to SSR when using jsx/tsx style Vue components. I have been told by a Vue maintainer this is is because @vite/plugin-vue-jsx is failing to inject modules into ssr context. Please see original issue for more context

Reproduction

Please provide a link to a repo that can reproduce the problem you ran into.

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

  1. clone
  2. yarn
  3. yarn dev
  4. open localhost:3000

Cannot read property forEach of undefined

I previously assumed this error came from renderToString from @vue/server-renderer, see line 16 of entry-server.ts. Apparently this comes from the jsx plugin not injecting modules into ssr context.

System Info

  • vite version: 2.0.0 beta 65
  • Operating System: Mac OS Big Sur M1 Chip
  • Node version: 15.3.0
  • Package manager (npm/yarn/pnpm) and version: yarn 1.22.10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
seanayecommented, Feb 8, 2021

I think I will try my hand at a PR for this tomorrow. Would love to contribute to such an awesome project

0reactions
seanayecommented, Feb 9, 2021

@yyx990803 I think it’s getting very close. Using with the latest vite core gives following error. Maybe this is a vue-router issue now and not a vite one?

TypeError: Cannot read property 'beforeRouteEnter' of undefined
    at /Users/seanaye/dev/vue3-tsx-tailwind/node_modules/vue-router/dist/vue-router.cjs.js:1986:52
node:internal/process/promises:225
          triggerUncaughtException(err, true /* fromPromise */);
          ^

TypeError: Cannot read property 'beforeRouteEnter' of undefined
    at /Users/seanaye/dev/vue3-tsx-tailwind/node_modules/vue-router/dist/vue-router.cjs.js:1986:52
Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering (SSR) - Vue.js
Vite provides built-in support for Vue server-side rendering, but it is intentionally low-level. If you wish to go directly with Vite, check out...
Read more >
Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >
ssr-plugin-vue - npm
Start using ssr-plugin-vue in your project by running `npm i ... There are no other projects in the npm registry using ssr-plugin-vue.
Read more >
vite-plugin-ssr
With vite-plugin-ssr you integrate tools manually; while it means more work, it gives you a fundamentally simpler & more stable foundation to build...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Nuxt.js is based off an implementation of SSR for the popular React library called Next. After seeing the advantages of this design, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found