@@ -1074,9 +1074,9 @@ export default class Project {
10741074 const data = await this . getData ( )
10751075 const html = renderPage ( data , url , appModule ? App : undefined , Page )
10761076 const head = renderHead ( [
1077- pageModule . deps . map ( ( { url } ) => url ) . filter ( url => reStyleModuleExt . test ( url ) ) ,
1078- appModule ?. deps . map ( ( { url } ) => url ) . filter ( url => reStyleModuleExt . test ( url ) )
1079- ] . filter ( Boolean ) . flat ( ) )
1077+ this . _lookupStyles ( pageModule ) ,
1078+ appModule ? this . _lookupStyles ( appModule ) : [ ]
1079+ ] . flat ( ) )
10801080 ret . code = 200
10811081 ret . head = head
10821082 ret . body = `<main>${ html } </main>`
@@ -1090,8 +1090,28 @@ export default class Project {
10901090 }
10911091 return ret
10921092 }
1093+
1094+ private _lookupStyles ( mod : Module , a : string [ ] = [ ] , s : Set < string > = new Set ( ) ) : string [ ] {
1095+ if ( s . has ( mod . id ) ) {
1096+ return a
1097+ }
1098+ s . add ( mod . id )
1099+ a . push ( ...mod . deps . map ( ( { url } ) => url ) . filter ( url => reStyleModuleExt . test ( url ) ) )
1100+ mod . deps . forEach ( ( { url } ) => {
1101+ if ( reModuleExt . test ( url ) && ! reHttp . test ( url ) ) {
1102+ const id = url . replace ( reModuleExt , '.js' )
1103+ const smod = this . getModule ( id )
1104+ if ( smod ) {
1105+ this . _lookupStyles ( smod , a , s )
1106+ }
1107+ }
1108+ } )
1109+ return a
1110+ }
1111+
10931112}
10941113
1114+
10951115function relativePath ( from : string , to : string ) : string {
10961116 let r = path . relative ( from , to )
10971117 if ( ! r . startsWith ( '.' ) && ! r . startsWith ( '/' ) ) {
0 commit comments