@@ -285,33 +285,10 @@ exports.main = function main(argv, options, callback) {
285
285
}
286
286
}
287
287
288
- // Include entry files
289
- for ( let i = 0 , k = argv . length ; i < k ; ++ i ) {
290
- const filename = argv [ i ] ;
291
-
292
- let sourcePath = String ( filename ) . replace ( / \\ / g, "/" ) . replace ( / ( \. t s | \/ ) $ / , "" ) ;
293
-
294
- // Try entryPath.ts, then entryPath/index.ts
295
- let sourceText = readFile ( path . join ( baseDir , sourcePath ) + ".ts" ) ;
296
- if ( sourceText === null ) {
297
- sourceText = readFile ( path . join ( baseDir , sourcePath , "index.ts" ) ) ;
298
- if ( sourceText === null ) {
299
- return callback ( Error ( "Entry file '" + sourcePath + ".ts' not found." ) ) ;
300
- } else {
301
- sourcePath += "/index.ts" ;
302
- }
303
- } else {
304
- sourcePath += ".ts" ;
305
- }
306
-
307
- stats . parseCount ++ ;
308
- stats . parseTime += measure ( ( ) => {
309
- parser = assemblyscript . parseFile ( sourceText , sourcePath , true , parser ) ;
310
- } ) ;
311
-
312
- // Process backlog
288
+ // Parses the backlog of imported files after including entry files
289
+ function parseBacklog ( ) {
290
+ var sourcePath , sourceText ;
313
291
while ( ( sourcePath = parser . nextFile ( ) ) != null ) {
314
- let found = false ;
315
292
316
293
// Load library file if explicitly requested
317
294
if ( sourcePath . startsWith ( exports . libraryPrefix ) ) {
@@ -390,7 +367,38 @@ exports.main = function main(argv, options, callback) {
390
367
}
391
368
}
392
369
370
+ // Include entry files
371
+ for ( let i = 0 , k = argv . length ; i < k ; ++ i ) {
372
+ const filename = argv [ i ] ;
373
+
374
+ let sourcePath = String ( filename ) . replace ( / \\ / g, "/" ) . replace ( / ( \. t s | \/ ) $ / , "" ) ;
375
+
376
+ // Try entryPath.ts, then entryPath/index.ts
377
+ let sourceText = readFile ( path . join ( baseDir , sourcePath ) + ".ts" ) ;
378
+ if ( sourceText === null ) {
379
+ sourceText = readFile ( path . join ( baseDir , sourcePath , "index.ts" ) ) ;
380
+ if ( sourceText === null ) {
381
+ return callback ( Error ( "Entry file '" + sourcePath + ".ts' not found." ) ) ;
382
+ } else {
383
+ sourcePath += "/index.ts" ;
384
+ }
385
+ } else {
386
+ sourcePath += ".ts" ;
387
+ }
388
+
389
+ stats . parseCount ++ ;
390
+ stats . parseTime += measure ( ( ) => {
391
+ parser = assemblyscript . parseFile ( sourceText , sourcePath , true , parser ) ;
392
+ } ) ;
393
+ let code = parseBacklog ( ) ;
394
+ if ( code ) return code ;
395
+ }
396
+
393
397
applyTransform ( "afterParse" , parser ) ;
398
+ {
399
+ let code = parseBacklog ( ) ;
400
+ if ( code ) return code ;
401
+ }
394
402
395
403
// Finish parsing
396
404
const program = assemblyscript . finishParsing ( parser ) ;
0 commit comments