@@ -50,10 +50,16 @@ export class ResourceService {
5050 }
5151
5252 public async getScriptResources ( script : Script , load : boolean ) : Promise < { [ key : string ] : Resource } > {
53+ const [ require , require_css , resource ] = await Promise . all ( [
54+ this . getResourceByType ( script , "require" , load ) ,
55+ this . getResourceByType ( script , "require-css" , load ) ,
56+ this . getResourceByType ( script , "resource" , load ) ,
57+ ] ) ;
58+
5359 return {
54- ...( ( await this . getResourceByType ( script , " require" , load ) ) || { } ) ,
55- ...( ( await this . getResourceByType ( script , "require-css" , load ) ) || { } ) ,
56- ...( ( await this . getResourceByType ( script , " resource" , load ) ) || { } ) ,
60+ ...require ,
61+ ...require_css ,
62+ ...resource ,
5763 } ;
5864 }
5965
@@ -97,10 +103,17 @@ export class ResourceService {
97103
98104 // 更新资源
99105 async checkScriptResource ( script : Script ) {
106+ const [ require , require_css , resource ] = await Promise . all ( [
107+ this . checkResourceByType ( script , "require" ) ,
108+ this . checkResourceByType ( script , "require-css" ) ,
109+ this . checkResourceByType ( script , "resource" ) ,
110+ ] ) ;
111+
112+ // wait https://github.com/tc39/proposal-await-dictionary
100113 return {
101- ...( ( await this . checkResourceByType ( script , " require" ) ) || { } ) ,
102- ...( ( await this . checkResourceByType ( script , "require-css" ) ) || { } ) ,
103- ...( ( await this . checkResourceByType ( script , " resource" ) ) || { } ) ,
114+ ...require ,
115+ ...require_css ,
116+ ...resource ,
104117 } ;
105118 }
106119
0 commit comments