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

[Question] Does SSR with Vue really need a build? (i.e. Handle component files like Ts-Node) #1122

Closed
arpowers opened this issue Nov 20, 2020 · 9 comments

Comments

@arpowers
Copy link
Contributor

Since SSR is essentially just rendering a "snapshot" of the initial state of the HTML generated by components, shouldn't it be possible to handle component files in a similar way to how ts-node deals with .ts files?

Essentially we could use require.extensions to convert .vue files to es modules, add a .ts extension and then handle them with ts-node... giving us the ability to use Vue components without the hassle of a build.

I know, for some reason, Node says not to use this but it's a critically useful feature when implemented carefully (as with ts-node)

@underfin
Copy link
Member

Essentially we could use require.extensions to convert .vue files to es modules, add a .ts extension and then handle them with ts-node... giving us the ability to use Vue components without the hassle of a build.

That can be do. But most case we need fast performannce at runtime, vue template always need tranformed (this is what build is going to do).If you not transform it at build, you must do it at runtime.

@arpowers
Copy link
Contributor Author

@underfin its not a performance issue, as in TsNode, the compiled code is cached after the first run.

@underfin
Copy link
Member

Yeah. That always need tranformed at runtime whaterever cached or not cached.

@arpowers
Copy link
Contributor Author

arpowers commented Nov 23, 2020

@underfin In a way different than ts-node? If so, why?

@underfin
Copy link
Member

If you want to run it by the similar way of ts-node, it can should work for you. But for most users, them need build for ssr for now.

This question same as why we need build with component for browser runtime.The performance actually is important for node server and client.

@arpowers
Copy link
Contributor Author

What I'm trying to say is that ts-node is quite performant, and Vue/Vite could work the same way.

This is accomplished because the FIRST time any .ts file is run, it is transpiled and that transpiled version is cached via require.cache....

I believe that we could do the same with vue files. Transpile them and cache that result.

The advantages being:

  • Real time development with SSR and no builds
  • Simplification of SSR (no build logistics)

Can we keep this open as a suggestion please? I believe it needs more feedback. @underfin

@underfin
Copy link
Member

underfin commented Nov 24, 2020

Real time development with SSR and no builds

This is a nice point, it can be faster with ssr hmr .But I also think need build for production. I reopen this hope get other people give opion.

@underfin underfin reopened this Nov 24, 2020
@frandiox
Copy link
Contributor

@arpowers Very interesting idea. It could be useful at least for development in order to have a local SSR environment that doesn't require build watching, like what you mentioned in another issue.

In production, however, I think a build would still be better at least for short-lived environments such as serverless functions or workers. Maybe it could be fine for Node servers 🤔

@yyx990803
Copy link
Member

Closing for #1290

@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
None yet
Projects
None yet
Development

No branches or pull requests

4 participants