Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR in dev (2.0) #1290

Closed
egoist opened this issue Jan 2, 2021 · 12 comments
Closed

SSR in dev (2.0) #1290

egoist opened this issue Jan 2, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@egoist
Copy link
Contributor

egoist commented Jan 2, 2021

Is your feature request related to a problem? Please describe.

Vite 2.0 beta doesn't seem to have any sort of SSR solution included, I assume it's still in development and things might catch up later?

Describe the solution you'd like

A new transformRequest API to load and transform a URL and get the result that is optimized for server:

transformRequest(url, { ssr: true })

Plugins should also be able to tell if it's requesting the build for server.

Describe alternatives you've considered

No other solution is available, maybe I'm missing something.

Additional context

Trying to build something like Nuxt.js using Vite, SSR in dev is necessary.

@remorses
Copy link
Contributor

remorses commented Jan 2, 2021

Can you elaborate on what transformRequest would do?

@egoist
Copy link
Contributor Author

egoist commented Jan 2, 2021

Can you elaborate on what transformRequest would do?

transformRequest already exists (https://vitejs.dev/guide/api-javascript.html#vitedevserver), I'm suggesting that adding a ssr option so Vite and plugins can apply server optimizations like:

  • Setting import.meta.env.SERVER to true
  • Maybe output in CJS format
  • etc.

Then you can use it like this:

transformRequest('/render-routes/index.js', { ssr: true })
// result, string => `module.exports = { /* server-compatible code */ }`

@yyx990803
Copy link
Member

yyx990803 commented Jan 2, 2021

Yes, this is on the roadmap, just don't want to finalize the API before I get a working prototype running on top of it.

FWIW, you can already use the build JavaScript API to bundle a route on the fly (with tweaked rollupOptions).

@yyx990803 yyx990803 added discussion enhancement New feature or request labels Jan 2, 2021
@arpowers
Copy link
Contributor

arpowers commented Jan 2, 2021

Don't you think it's time to pay attention to SSR? For all the elegance and work that goes into the Vue/Vite ecosystem, rendering the source has always been a super complicated, undocumented experience.

Typically I'd "roll my own" solution, but very few of us understand the nuances of rendering SFCs and I've always personally felt like a decent effort to support metatags and SEO with Vue must be around the corner from the core team.

@yyx990803
Copy link
Member

@arpowers I'll pay attention to it when I think it's time. This is open source and you are not paying me money to prioritize things you want.

@hmaurer
Copy link

hmaurer commented Jan 2, 2021

@arpowers Isn't there a guide at https://ssr.vuejs.org/? Vite is a fairly new project, especially Vite 2.0 (a month old? not even). If you feel SSR is a must for your use-case I'd suggest using a more mature build tool.

@arpowers
Copy link
Contributor

🙏🏼 our prayers have been answered, Evan is working on SSR

Screen Shot 2021-01-18 at 5 16 12 PM

@yyx990803
Copy link
Member

Closing (landed)

@brillout
Copy link
Contributor

brillout commented Feb 2, 2021

I'm currently building a vite-plugin-ssr, the goal being to provide an interface à la Nuxt/Next.js. Anyone else inerested in this?

@lewebsimple
Copy link

@brillout very much interested, how can we help ?

@brillout
Copy link
Contributor

I'm currently building a vite-plugin-ssr

Almost done. To get a preview of what vite-plugin-ssr is going to be about: https://github.com/brillout/vite-plugin-ssr.

how can we help ?

By using it :) I will post a comment in this ticket as soon as a first beta is ready to be used.

@brillout
Copy link
Contributor

Finished the implementation of https://github.com/brillout/vite-plugin-ssr. The API and overall design are stable. Beta is released. Stable 1.x release in the coming weeks.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants