Skip to content

Commit d5b82e7

Browse files
committed
feat: support createApp as promise for lazy loading
1 parent 3784af0 commit d5b82e7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/renderer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,15 @@ export function getUsedAsyncFiles (ssrContext: SSRContext, renderContext: Render
165165
return ssrContext._mappedFiles || []
166166
}
167167

168-
export function createRenderer (createApp: any, renderOptions: RenderOptions & { renderToString: typeof import('@vue/server-renderer').renderToString }) {
168+
export function createRenderer (createApp: any, renderOptions: RenderOptions & { renderToString: Function }) {
169169
const renderContext = createRenderContext(renderOptions)
170170

171171
return {
172172
async renderToString (ssrContext: SSRContext) {
173173
ssrContext._registeredComponents = ssrContext._registeredComponents || new Set()
174174

175-
const app = await createApp(ssrContext)
175+
const _createApp = await Promise.resolve(createApp).then(r => r.default || r)
176+
const app = await _createApp(ssrContext)
176177
const html = await renderOptions.renderToString(app, ssrContext)
177178

178179
const wrap = (fn: Function) => () => fn(ssrContext, renderContext)

0 commit comments

Comments
 (0)