Skip to content

Commit

Permalink
fix: ESM SSR (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 25, 2022
1 parent bedd7af commit 57d782c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/client/app/router.ts
Expand Up @@ -60,12 +60,7 @@ export function createRouter(
const targetLoc = new URL(href, fakeHost)
const pendingPath = (latestPendingPath = targetLoc.pathname)
try {
let page = loadPageModule(pendingPath)
// only await if it returns a Promise - this allows sync resolution
// on initial render in SSR.
if ('then' in page && typeof page.then === 'function') {
page = await page
}
let page = await loadPageModule(pendingPath)
if (latestPendingPath === pendingPath) {
latestPendingPath = null

Expand Down
2 changes: 1 addition & 1 deletion src/node/build/render.ts
Expand Up @@ -25,7 +25,7 @@ export async function renderPage(
const { app, router } = createApp()
const routePath = `/${page.replace(/\.md$/, '')}`
const siteData = resolveSiteDataByRoute(config.site, routePath)
router.go(routePath)
await router.go(routePath)

// lazy require server-renderer for production build
// prioritize project root over vitepress' own dep
Expand Down

0 comments on commit 57d782c

Please sign in to comment.