@@ -52,8 +52,10 @@ export default abstract class BaseExportFormatter<
5252
5353 protected async fetchAPIData ( ) {
5454 await this . fetchVariants ( ) ;
55- const textItemsMap = await this . fetchTextItemsMap ( ) ;
56- const componentsMap = await this . fetchComponentsMap ( ) ;
55+ const [ textItemsMap , componentsMap ] = await Promise . all ( [
56+ this . fetchTextItemsMap ( ) ,
57+ this . fetchComponentsMap ( ) ,
58+ ] ) ;
5759
5860 return { textItemsMap, componentsMap } ;
5961 }
@@ -120,6 +122,8 @@ export default abstract class BaseExportFormatter<
120122 projects = await fetchProjects ( this . meta ) ;
121123 }
122124
125+ const fetchFileContentRequests = [ ] ;
126+
123127 for ( const project of projects ) {
124128 result [ project . id ] = { } ;
125129
@@ -134,14 +138,18 @@ export default abstract class BaseExportFormatter<
134138 } ) ,
135139 format : this . exportFormat ,
136140 } ;
137- const textItemsFileContent = await fetchText < TTextItemsResponse > (
141+ const addVariantToProjectMap = fetchText < TTextItemsResponse > (
138142 params ,
139143 this . meta
140- ) ;
141- result [ project . id ] [ variant . id ] = textItemsFileContent ;
144+ ) . then ( ( textItemsFileContent ) => {
145+ result [ project . id ] [ variant . id ] = textItemsFileContent ;
146+ } ) ;
147+ fetchFileContentRequests . push ( addVariantToProjectMap ) ;
142148 }
143149 }
144150
151+ await Promise . all ( fetchFileContentRequests ) ;
152+
145153 return result ;
146154 }
147155
@@ -156,6 +164,8 @@ export default abstract class BaseExportFormatter<
156164 if ( ! this . projectConfig . components && ! this . output . components ) return { } ;
157165 const result : ComponentsMap = { } ;
158166
167+ const fetchFileContentRequests = [ ] ;
168+
159169 for ( const variant of this . variants ) {
160170 // map "base" to undefined, as by default export endpoint returns base variant
161171 const variantsParam =
@@ -169,11 +179,13 @@ export default abstract class BaseExportFormatter<
169179 } ) ,
170180 format : this . exportFormat ,
171181 } ;
172- const componentsFileContent = await fetchComponents < TComponentsResponse > (
182+ const addVariantToMap = fetchComponents < TComponentsResponse > (
173183 params ,
174184 this . meta
175- ) ;
176- result [ variant . id ] = componentsFileContent ;
185+ ) . then ( ( componentsFileContent ) => {
186+ result [ variant . id ] = componentsFileContent ;
187+ } ) ;
188+ fetchFileContentRequests . push ( addVariantToMap ) ;
177189 }
178190
179191 return result ;
0 commit comments