@@ -246,41 +246,32 @@ export default class Compiler {
246246        // Cache compiled files so identical input files are only compiled once 
247247        const  compiledFiles  =  new  Map ( ) ; 
248248
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 , 
249+         await  asc . ready ( ) ; 
250+ 
251+         subgraph  =  subgraph . update ( 'dataSources' ,  ( dataSources : any [ ] )  => 
252+           dataSources . map ( ( dataSource : any )  => 
253+             dataSource . updateIn ( [ 'mapping' ,  'file' ] ,  ( mappingPath : string )  => 
254+               this . _compileDataSourceMapping ( 
255+                 this . protocol , 
256+                 dataSource , 
275257                mappingPath , 
276258                compiledFiles , 
277259                spinner , 
278-               ) ; 
279-               return  template . setIn ( [ 'mapping' ,  'file' ] ,  compiledPath ) ; 
280-             } ) , 
281-           ) ; 
282-           subgraph  =  subgraph . set ( 'templates' ,  compiledTemplates ) ; 
283-         } 
260+                 validate , 
261+               ) , 
262+             ) , 
263+           ) , 
264+         ) ; 
265+ 
266+         subgraph  =  subgraph . update ( 'templates' ,  ( templates : any )  => 
267+           templates  ===  undefined 
268+             ? templates 
269+             : templates . map ( ( template : any )  => 
270+                 template . updateIn ( [ 'mapping' ,  'file' ] ,  ( mappingPath : string )  => 
271+                   this . _compileTemplateMapping ( template ,  mappingPath ,  compiledFiles ,  spinner ) , 
272+                 ) , 
273+               ) , 
274+         ) ; 
284275
285276        return  subgraph ; 
286277      } , 
@@ -343,7 +334,7 @@ export default class Compiler {
343334    return  missingHandlers ; 
344335  } 
345336
346-   async   _compileDataSourceMapping ( 
337+   _compileDataSourceMapping ( 
347338    protocol : Protocol , 
348339    dataSource : immutable . Map < any ,  any > , 
349340    mappingPath : string , 
@@ -397,7 +388,7 @@ export default class Compiler {
397388      } 
398389      const  global  =  path . relative ( baseDir ,  this . globalsFile ) ; 
399390
400-       await   asc . compile ( { 
391+       asc . compile ( { 
401392        inputFile, 
402393        global, 
403394        baseDir, 
@@ -424,7 +415,7 @@ export default class Compiler {
424415    } 
425416  } 
426417
427-   async   _compileTemplateMapping ( 
418+   _compileTemplateMapping ( 
428419    template : immutable . Collection < any ,  any > , 
429420    mappingPath : string , 
430421    compiledFiles : Map < any ,  any > , 
@@ -478,7 +469,7 @@ export default class Compiler {
478469      } 
479470      const  global  =  path . relative ( baseDir ,  this . globalsFile ) ; 
480471
481-       await   asc . compile ( { 
472+       asc . compile ( { 
482473        inputFile, 
483474        global, 
484475        baseDir, 
0 commit comments