Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit d0f471e

Browse files
committed
Clean up
1 parent 465db13 commit d0f471e

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

server/aleph.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bold, dim } from 'https://deno.land/[email protected]/fmt/colors.ts'
1+
import { dim } from 'https://deno.land/[email protected]/fmt/colors.ts'
22
import { indexOf, copy, equals } from 'https://deno.land/[email protected]/bytes/mod.ts'
33
import { ensureDir } from 'https://deno.land/[email protected]/fs/ensure_dir.ts'
44
import { walk } from 'https://deno.land/[email protected]/fs/walk.ts'
@@ -555,6 +555,7 @@ export class Aleph implements IAleph {
555555
return null
556556
}
557557

558+
// pre-compile modules to check ssr options
558559
await Promise.all(
559560
nestedModules
560561
.filter(specifier => !this.#modules.has(specifier))
@@ -598,7 +599,7 @@ export class Aleph implements IAleph {
598599
return data
599600
}
600601

601-
/** get ssr page */
602+
/** get page ssr html */
602603
async getPageHTML(loc: { pathname: string, search?: string }): Promise<[number, string]> {
603604
const [router, nestedModules] = this.#pageRouting.createRouter(loc)
604605
const { routePath } = router
@@ -1361,8 +1362,6 @@ export class Aleph implements IAleph {
13611362
return
13621363
}
13631364

1364-
log.info(bold('- Pages (SSG)'))
1365-
13661365
// render pages
13671366
const paths: Set<{ pathname: string, search?: string }> = new Set(this.#pageRouting.paths.map(pathname => ({ pathname })))
13681367
const locales = this.config.locales.filter(l => l !== this.config.defaultLocale)
@@ -1394,7 +1393,9 @@ export class Aleph implements IAleph {
13941393
}
13951394
}
13961395
}
1397-
await Promise.all(Array.from(paths).map((loc) => ([loc, ...locales.map(locale => ({ ...loc, pathname: locale + loc.pathname }))])).flat().map(async ({ pathname, search }) => {
1396+
1397+
// render route pages
1398+
await Promise.all(Array.from(paths).map(loc => ([loc, ...locales.map(locale => ({ ...loc, pathname: locale + loc.pathname }))])).flat().map(async ({ pathname, search }) => {
13981399
if (this.isSSRable(pathname)) {
13991400
const [router, nestedModules] = this.#pageRouting.createRouter({ pathname, search })
14001401
if (router.routePath !== '') {
@@ -1412,7 +1413,7 @@ export class Aleph implements IAleph {
14121413
)
14131414
await ensureTextFile(dataFile, JSON.stringify(data))
14141415
}
1415-
log.info(' ○', href, dim('• ' + util.formatBytes(html.length)))
1416+
log.debug('SSR', href, dim('• ' + util.formatBytes(html.length)))
14161417
}
14171418
}
14181419
}))

server/renderer.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,9 @@ export class Renderer {
103103
const state = { entryFile: '' }
104104
const appModule = this.#aleph.getModule('app')
105105
const { default: App } = appModule ? await this.#aleph.importModule(appModule) : {} as any
106-
await Promise.all(
107-
nestedModules
108-
.filter(specifier => !this.#aleph.getModule(specifier))
109-
.map(specifier => this.#aleph.compile(specifier))
110-
)
111106
const nestedPageComponents = await Promise.all(nestedModules
112-
.filter(specifier => !!this.#aleph.getModule(specifier))
113107
.map(async specifier => {
114-
const module = this.#aleph.getModule(specifier)!
108+
const module = this.#aleph.getModule(specifier) || (await this.#aleph.compile(specifier))
115109
const { default: Component, ssr } = await this.#aleph.importModule(module)
116110
let ssrProps = ssr?.props
117111
if (util.isFunction(ssrProps)) {

0 commit comments

Comments
 (0)