11import Vue from 'vue'
2- import VueServerRenderer from 'vue-server-renderer/build.js '
2+ import { createRenderer } from 'vue-server-renderer'
33import { WebApp } from 'meteor/webapp'
44import cookieParser from 'cookie-parser'
55import { onPageLoad } from 'meteor/server-render'
@@ -62,7 +62,7 @@ VueSSR.inSubscription = new Meteor.EnvironmentVariable() // <-- needed in data.j
6262
6363patchSubscribeData ( VueSSR )
6464
65- const renderer = VueServerRenderer . createRenderer ( )
65+ const renderer = createRenderer ( )
6666
6767function writeServerError ( sink ) {
6868 sink . appendToBody ( 'Server Error' )
@@ -91,24 +91,19 @@ onPageLoad(sink => new Promise((resolve, reject) => {
9191 // }
9292
9393 // Vue
94+ const context = { url : req . url }
9495 let asyncResult
95- const result = VueSSR . createApp ( { url : req . url } )
96+ const result = VueSSR . createApp ( context )
9697 if ( result && typeof result . then === 'function' ) {
9798 asyncResult = result
9899 } else {
99100 asyncResult = Promise . resolve ( result )
100101 }
101102
102- asyncResult . then ( result => {
103- let app
104- if ( result . app ) {
105- app = result . app
106- } else {
107- app = result
108- }
109-
103+ asyncResult . then ( app => {
110104 renderer . renderToString (
111105 app ,
106+ context ,
112107 ( error , html ) => {
113108 if ( error ) {
114109 console . error ( error )
@@ -125,11 +120,11 @@ onPageLoad(sink => new Promise((resolve, reject) => {
125120 // // sink.appendToHead(`<script type="text/inject-data">${encodeURIComponent(injectData)}</script>`)
126121
127122 let appendHtml
128- if ( typeof result . appendHtml === "function" ) appendHtml = result . appendHtml ( )
123+ if ( typeof context . appendHtml === "function" ) appendHtml = context . appendHtml ( )
129124
130- const head = ( ( appendHtml && appendHtml . head ) || result . head ) || ''
131- const body = ( ( appendHtml && appendHtml . body ) || result . body ) || ''
132- const js = ( ( appendHtml && appendHtml . js ) || result . js ) || ''
125+ const head = ( ( appendHtml && appendHtml . head ) || context . head ) || ''
126+ const body = ( ( appendHtml && appendHtml . body ) || context . body ) || ''
127+ const js = ( ( appendHtml && appendHtml . js ) || context . js ) || ''
133128
134129 const script = js && `<script type="text/javascript">${ js } </script>`
135130
0 commit comments