@@ -216,15 +216,6 @@ export class Aleph implements IAleph {
216
216
const { init } = await import ( `../framework/${ this . #config. framework } /init.ts` )
217
217
await init ( this )
218
218
219
- // compile and import framework renderer
220
- if ( this . #config. ssr ) {
221
- const mod = await this . compile ( `${ alephPkgUri } /framework/${ this . #config. framework } /renderer.ts` )
222
- const { render } = await this . importModule ( mod )
223
- if ( util . isFunction ( render ) ) {
224
- this . #renderer. setFrameworkRenderer ( { render } )
225
- }
226
- }
227
-
228
219
ms . stop ( `init ${ this . #config. framework } framework` )
229
220
230
221
const appFile = await findFile ( srcDir , builtinModuleExts . map ( ext => `app.${ ext } ` ) )
@@ -651,6 +642,14 @@ export class Aleph implements IAleph {
651
642
}
652
643
653
644
async #renderPage( url : RouterURL , nestedModules : string [ ] ) : Promise < [ string , Record < string , SSRData > | null ] > {
645
+ // compile and import framework renderer
646
+ if ( ! this . #renderer. ready ) {
647
+ const mod = await this . compile ( `${ getAlephPkgUri ( ) } /framework/${ this . #config. framework } /renderer.ts` )
648
+ const { render } = await this . importModule ( mod )
649
+ if ( util . isFunction ( render ) ) {
650
+ this . #renderer. setFrameworkRenderer ( { render } )
651
+ }
652
+ }
654
653
let [ html , data ] = await this . #renderer. renderPage ( url , nestedModules )
655
654
for ( const callback of this . #renderListeners) {
656
655
callback ( { path : url . toString ( ) , html, data } )
0 commit comments