@@ -560,12 +560,40 @@ export class Application implements ServerApplication {
560560
561561 /** get ssr html scripts */
562562 getSSRHTMLScripts ( pagePath ?: string ) {
563- const { baseUrl } = this . config
563+ const { framework } = this . config
564+ const baseUrl = util . trimSuffix ( this . config . baseUrl , '/' )
565+ const alephPkgPath = getAlephPkgUri ( ) . replace ( 'https://' , '' ) . replace ( 'http://localhost:' , 'http_localhost_' )
566+ const fullAlephPkgPath = `${ baseUrl } /_aleph/-/${ alephPkgPath } `
564567
565568 if ( this . isDev ) {
569+ const preload : string [ ] = [
570+ `${ fullAlephPkgPath } /framework/core/module.js` ,
571+ `${ fullAlephPkgPath } /framework/core/events.js` ,
572+ `${ fullAlephPkgPath } /framework/core/routing.js` ,
573+ `${ fullAlephPkgPath } /framework/core/hmr.js` ,
574+ `${ fullAlephPkgPath } /framework/${ framework } /bootstrap.js` ,
575+ `${ fullAlephPkgPath } /shared/util.js` ,
576+ ]
577+
578+ Array . from ( this . #modules. keys ( ) ) . forEach ( url => {
579+ switch ( trimModuleExt ( url ) ) {
580+ case '/app' :
581+ preload . push ( `${ baseUrl } /_aleph/app.js` )
582+ break
583+ case '/404' :
584+ preload . push ( `${ baseUrl } /_aleph/404.js` )
585+ break
586+ }
587+ } )
588+
589+ if ( pagePath ) {
590+ preload . push ( `${ baseUrl } /_aleph/pages/${ pagePath . replace ( / \/ $ / , '/index' ) } .js` )
591+ }
592+
566593 return [
567- { src : util . cleanPath ( `${ baseUrl } /_aleph/main.js` ) , type : 'module' } ,
568- { src : util . cleanPath ( `${ baseUrl } /_aleph/-/deno.land/x/aleph/nomodule.js` ) , nomodule : true } ,
594+ ...preload . map ( src => ( { src, type : 'module' , preload : true } ) ) ,
595+ { src : `${ baseUrl } /_aleph/main.js` , type : 'module' } ,
596+ { src : `${ fullAlephPkgPath } /nomodule.js` , nomodule : true } ,
569597 ]
570598 }
571599
@@ -574,7 +602,7 @@ export class Application implements ServerApplication {
574602 ...[ 'polyfill' , 'deps' , 'shared' , 'main' , pagePath ? '/pages' + pagePath . replace ( / \/ $ / , '/index' ) : '' ]
575603 . filter ( name => name !== "" && this . #bundler. getBundledFile ( name ) !== null )
576604 . map ( name => ( {
577- src : util . cleanPath ( `${ baseUrl } /_aleph/${ this . #bundler. getBundledFile ( name ) } ` )
605+ src : `${ baseUrl } /_aleph/${ this . #bundler. getBundledFile ( name ) } `
578606 } ) )
579607 ]
580608 }
0 commit comments