@@ -1074,9 +1074,9 @@ export default class Project {
1074
1074
const data = await this . getData ( )
1075
1075
const html = renderPage ( data , url , appModule ? App : undefined , Page )
1076
1076
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 ( ) )
1080
1080
ret . code = 200
1081
1081
ret . head = head
1082
1082
ret . body = `<main>${ html } </main>`
@@ -1090,8 +1090,28 @@ export default class Project {
1090
1090
}
1091
1091
return ret
1092
1092
}
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
+
1093
1112
}
1094
1113
1114
+
1095
1115
function relativePath ( from : string , to : string ) : string {
1096
1116
let r = path . relative ( from , to )
1097
1117
if ( ! r . startsWith ( '.' ) && ! r . startsWith ( '/' ) ) {
0 commit comments