@@ -254,6 +254,7 @@ struct BundleResponse {
254
254
struct CompileResponse {
255
255
diagnostics : Diagnostic ,
256
256
emit_map : HashMap < String , EmittedSource > ,
257
+ sources : Vec < String > ,
257
258
}
258
259
259
260
// TODO(bartlomieju): possible deduplicate once TS refactor is stabilized
@@ -392,29 +393,6 @@ impl TsCompiler {
392
393
return self . get_compiled_module ( & source_file. url ) ;
393
394
}
394
395
395
- if self . use_disk_cache {
396
- // Try to load cached version:
397
- // 1. check if there's 'meta' file
398
- if let Some ( metadata) = self . get_metadata ( & source_file. url ) {
399
- // 2. compare version hashes
400
- // TODO: it would probably be good idea to make it method implemented on SourceFile
401
- let version_hash_to_validate = source_code_version_hash (
402
- & source_file. source_code ,
403
- version:: DENO ,
404
- & self . config . hash ,
405
- ) ;
406
-
407
- if metadata. version_hash == version_hash_to_validate {
408
- debug ! ( "load_cache metadata version hash match" ) ;
409
- if let Ok ( compiled_module) =
410
- self . get_compiled_module ( & source_file. url )
411
- {
412
- self . mark_compiled ( & source_file. url ) ;
413
- return Ok ( compiled_module) ;
414
- }
415
- }
416
- }
417
- }
418
396
let source_file_ = source_file. clone ( ) ;
419
397
let module_url = source_file. url . clone ( ) ;
420
398
let target = match target {
@@ -444,6 +422,11 @@ impl TsCompiler {
444
422
445
423
let compile_response: CompileResponse = serde_json:: from_str ( json_str) ?;
446
424
425
+ for source in compile_response. sources . iter ( ) {
426
+ let ref url = Url :: parse ( source) ?;
427
+ self . mark_compiled ( url) ;
428
+ }
429
+
447
430
if !compile_response. diagnostics . items . is_empty ( ) {
448
431
return Err ( ErrBox :: from ( compile_response. diagnostics ) ) ;
449
432
}
@@ -484,6 +467,8 @@ impl TsCompiler {
484
467
self . cache_source_map ( & specifier, & source. contents ) ?;
485
468
} else if emitted_name. ends_with ( ".js" ) {
486
469
self . cache_compiled_file ( & specifier, & source. contents ) ?;
470
+ } else if emitted_name. ends_with ( "tsbuildinfo.json" ) {
471
+ self . cache_build_info ( & specifier, & source. contents ) ?;
487
472
} else {
488
473
panic ! ( "Trying to cache unknown file type {}" , emitted_name) ;
489
474
}
@@ -558,7 +543,6 @@ impl TsCompiler {
558
543
. disk_cache
559
544
. get_cache_filename_with_extension ( module_specifier. as_url ( ) , "js" ) ;
560
545
self . disk_cache . set ( & js_key, contents. as_bytes ( ) ) ?;
561
- self . mark_compiled ( module_specifier. as_url ( ) ) ;
562
546
563
547
let version_hash = source_code_version_hash (
564
548
& source_file. source_code ,
@@ -627,6 +611,18 @@ impl TsCompiler {
627
611
. get_cache_filename_with_extension ( module_specifier. as_url ( ) , "js.map" ) ;
628
612
self . disk_cache . set ( & source_map_key, contents. as_bytes ( ) )
629
613
}
614
+
615
+ /// Save TS build info file to on-disk cache.
616
+ fn cache_build_info (
617
+ & self ,
618
+ module_specifier : & ModuleSpecifier ,
619
+ contents : & str ,
620
+ ) -> std:: io:: Result < ( ) > {
621
+ let build_info_key = self
622
+ . disk_cache
623
+ . get_cache_filename ( module_specifier. as_url ( ) ) ;
624
+ self . disk_cache . set ( & build_info_key, contents. as_bytes ( ) )
625
+ }
630
626
}
631
627
632
628
impl SourceMapGetter for TsCompiler {
0 commit comments