@@ -246,30 +246,41 @@ export default class Compiler {
246246        // Cache compiled files so identical input files are only compiled once 
247247        const  compiledFiles  =  new  Map ( ) ; 
248248
249-         subgraph  =  subgraph . update ( 'dataSources' ,  ( dataSources : any [ ] )  => 
250-           dataSources . map ( ( dataSource : any )  => 
251-             dataSource . updateIn ( [ 'mapping' ,  'file' ] ,  ( mappingPath : string )  => 
252-               this . _compileDataSourceMapping ( 
253-                 this . protocol , 
254-                 dataSource , 
249+         // Handle data sources 
250+         const  dataSources  =  subgraph . get ( 'dataSources' ) ; 
251+         const  compiledDataSources  =  await  Promise . all ( 
252+           dataSources . map ( async  ( dataSource : any )  =>  { 
253+             const  mappingPath  =  dataSource . getIn ( [ 'mapping' ,  'file' ] ) ; 
254+             const  compiledPath  =  await  this . _compileDataSourceMapping ( 
255+               this . protocol , 
256+               dataSource , 
257+               mappingPath , 
258+               compiledFiles , 
259+               spinner , 
260+               validate , 
261+             ) ; 
262+             return  dataSource . setIn ( [ 'mapping' ,  'file' ] ,  compiledPath ) ; 
263+           } ) , 
264+         ) ; 
265+         subgraph  =  subgraph . set ( 'dataSources' ,  compiledDataSources ) ; 
266+ 
267+         // Handle templates if they exist 
268+         const  templates  =  subgraph . get ( 'templates' ) ; 
269+         if  ( templates  !==  undefined )  { 
270+           const  compiledTemplates  =  await  Promise . all ( 
271+             templates . map ( async  ( template : any )  =>  { 
272+               const  mappingPath  =  template . getIn ( [ 'mapping' ,  'file' ] ) ; 
273+               const  compiledPath  =  await  this . _compileTemplateMapping ( 
274+                 template , 
255275                mappingPath , 
256276                compiledFiles , 
257277                spinner , 
258-                 validate , 
259-               ) , 
260-             ) , 
261-           ) , 
262-         ) ; 
263- 
264-         subgraph  =  subgraph . update ( 'templates' ,  ( templates : any )  => 
265-           templates  ===  undefined 
266-             ? templates 
267-             : templates . map ( ( template : any )  => 
268-                 template . updateIn ( [ 'mapping' ,  'file' ] ,  ( mappingPath : string )  => 
269-                   this . _compileTemplateMapping ( template ,  mappingPath ,  compiledFiles ,  spinner ) , 
270-                 ) , 
271-               ) , 
272-         ) ; 
278+               ) ; 
279+               return  template . setIn ( [ 'mapping' ,  'file' ] ,  compiledPath ) ; 
280+             } ) , 
281+           ) ; 
282+           subgraph  =  subgraph . set ( 'templates' ,  compiledTemplates ) ; 
283+         } 
273284
274285        return  subgraph ; 
275286      } , 
@@ -332,7 +343,7 @@ export default class Compiler {
332343    return  missingHandlers ; 
333344  } 
334345
335-   _compileDataSourceMapping ( 
346+   async   _compileDataSourceMapping ( 
336347    protocol : Protocol , 
337348    dataSource : immutable . Map < any ,  any > , 
338349    mappingPath : string , 
@@ -386,7 +397,7 @@ export default class Compiler {
386397      } 
387398      const  global  =  path . relative ( baseDir ,  this . globalsFile ) ; 
388399
389-       asc . compile ( { 
400+       await   asc . compile ( { 
390401        inputFile, 
391402        global, 
392403        baseDir, 
@@ -413,7 +424,7 @@ export default class Compiler {
413424    } 
414425  } 
415426
416-   _compileTemplateMapping ( 
427+   async   _compileTemplateMapping ( 
417428    template : immutable . Collection < any ,  any > , 
418429    mappingPath : string , 
419430    compiledFiles : Map < any ,  any > , 
@@ -467,7 +478,7 @@ export default class Compiler {
467478      } 
468479      const  global  =  path . relative ( baseDir ,  this . globalsFile ) ; 
469480
470-       asc . compile ( { 
481+       await   asc . compile ( { 
471482        inputFile, 
472483        global, 
473484        baseDir, 
0 commit comments