@@ -208,6 +208,14 @@ export class Aleph implements IAleph {
208
208
209
209
// init framework
210
210
await frameworks [ this . #config. framework ] . init ( this )
211
+ // compile and import framework renderer
212
+ if ( this . #config. ssr ) {
213
+ const mod = await this . compile ( `${ getAlephPkgUri ( ) } /framework/${ this . #config. framework } /renderer.ts` )
214
+ const { render } = await this . importModule ( mod )
215
+ if ( util . isFunction ( render ) ) {
216
+ this . #renderer. setFrameworkRenderer ( { render } )
217
+ }
218
+ }
211
219
ms . stop ( `init ${ this . #config. framework } framework` )
212
220
213
221
const appFile = await findFile ( srcDir , builtinModuleExts . map ( ext => `app.${ ext } ` ) )
@@ -634,14 +642,6 @@ export class Aleph implements IAleph {
634
642
}
635
643
636
644
async #renderPage( url : RouterURL , nestedModules : string [ ] ) : Promise < [ string , Record < string , SSRData > | null ] > {
637
- // compile and import framework renderer
638
- if ( ! this . #renderer. ready ) {
639
- const mod = await this . compile ( `${ getAlephPkgUri ( ) } /framework/${ this . #config. framework } /renderer.ts` )
640
- const { render } = await this . importModule ( mod )
641
- if ( util . isFunction ( render ) ) {
642
- this . #renderer. setFrameworkRenderer ( { render } )
643
- }
644
- }
645
645
let [ html , data ] = await this . #renderer. renderPage ( url , nestedModules )
646
646
for ( const callback of this . #renderListeners) {
647
647
callback ( { path : url . toString ( ) , html, data } )
0 commit comments