-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Provide Server-Side-Rendering helper using more purely JavaScript #5415
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
Comments
Added a note about Nashorn |
I would love to see that happen. I'm trying to use Vue.js with nashorn too. I've made some research:
so this is can be replaced with function if we are not on node.js
I made small modifications in source code to get rid of
result sizes:
|
@wojtask9 suprised to see you go further! Would you mind share us a demo code? |
Yes of course. I can share my code. But you must be patient (because of Easter Holiday) |
@wojtask9 Thanks! I will also try to design and implement some helper for Nashorn, to see how it will be going. |
@wojtask9 Hey, we're interested in seeing your solution as well. Can you post it somewhere? |
yeah. I'm finishing it. have been busy for the last days. |
You can find "my" code here: packages/vue-server-renderer-nashorn/vue-nashorn.js -> complete JS file with all required dependencies and polyfills for Nashorn. I tried to do modify Vue sources as less as possible. Currently only
If you have any questions I'll try answer :) |
Ok i fixed streams and other issues. There is only one left issue that I'm aware of ( read -> everything works) Not sure where the problem is :/ Another thing that make me wonder is |
Now everything is solved. Performance (on the same linux machine) --- renderToStream ---
--- renderToStream --- so it is rather slow :/ but why? |
The result is consistent to what i tried using React. repo Benchmark using JMH framework shows that typically nashorn version server side render is 1000% slower than Node.js version. I thought of wasting time in Since Vue.js use Run SSR in Nashorn is more robust than in Node.js. Thread-control, ability to terminate render at any time, cache across thread. @wojtask9 how about share your benchmark code to see if something can be optimized? |
I honestly think this is simply because V8 produces much better optimized machine code than Nashorn... not much can be done in Vue/React to solve that :/ |
Nashorn directly map js to JVM bytecode, implementation now may not great enough as V8. I believe things will get better. It's valuable to make Vue.js SSR not bond to a specific JavaScript Runtime. Nashorn (etc. Browser's Service-Worker, Embedded JavaScript Engine) Define some abstract interface and provide Node.js implementation as default will be great. |
@denghongcai yeah, that's probably what we will do in the future - but for now we want to focus on providing a good, stable and performant Node-based SSR solution first. |
@denghongcai Vue with my packackage doesn't use I think nashorn doesn't optimize recursive calls at beginning and doesn't like huge stacks. results (nashorn) Maybe there is room for improvements in Vue. For example instead of recursion use iterate version? |
I removed recursion from next() function (some async test are falling but benchrmarks don't use asyncComponents and currently it's out of my scope). Now StackTraces looks nicer and I see performance improvement (sadly no difference using node.js) Some results (btw i generate dynamic data on every loop to be sure that nashorn don't optimize whole scripts). Loading benchmarks
|
@wojtask9 I can't find your optimized code in your repo... |
I just get a hint that you're definitely from alibaba. hahah |
@denghongcai |
FYI: in 2.4 we already shipped a pure js build of |
Given your comment above, if I were to write something simple like this: |
@sowhatdoido |
@yyx990803 Ah! Sorry, I thought when you said the base renderer, you meant |
Uh oh!
There was an error while loading. Please reload this page.
What problem does this feature solve?
Current Server-Side-Rendering implementation is bond to Node.js, makes it hard to use in Nashorn (lightweight high-performance JavaScript runtime in Java with a native JVM) or other JavaScript runtime.
Foundations needed by Vue like
vm
andfs
modules may be passed into renderer or runner as parameter which implements some interfaces.What does the proposed API look like?
The text was updated successfully, but these errors were encountered: