diff options
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r-- | cli/tsc.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs index 1b3208e75..8d0f0d5de 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -405,7 +405,6 @@ impl TsCompiler { }))) } - // TODO(bartlomieju): this method is no longer needed /// Mark given module URL as compiled to avoid multiple compilations of same /// module in single run. fn mark_compiled(&self, url: &Url) { @@ -413,6 +412,11 @@ impl TsCompiler { c.insert(url.clone()); } + fn has_compiled(&self, url: &Url) -> bool { + let c = self.compiled.lock().unwrap(); + c.contains(url) + } + /// Check if there is compiled source in cache that is valid /// and can be used again. // TODO(bartlomieju): there should be check that cached file actually exists @@ -459,10 +463,14 @@ impl TsCompiler { target: TargetLib, permissions: Permissions, module_graph: HashMap<String, ModuleGraphFile>, + allow_js: bool, ) -> Result<(), ErrBox> { let mut has_cached_version = false; - if self.use_disk_cache { + // Only use disk cache if `--reload` flag was not used or + // this file has already been compiled during current process + // lifetime. + if self.use_disk_cache || self.has_compiled(&source_file.url) { if let Some(metadata) = self.get_graph_metadata(&source_file.url) { has_cached_version = true; @@ -503,6 +511,7 @@ impl TsCompiler { let j = match (compiler_config.path, compiler_config.content) { (Some(config_path), Some(config_data)) => json!({ "type": msg::CompilerRequestType::Compile as i32, + "allowJs": allow_js, "target": target, "rootNames": root_names, "bundle": bundle, @@ -514,6 +523,7 @@ impl TsCompiler { }), _ => json!({ "type": msg::CompilerRequestType::Compile as i32, + "allowJs": allow_js, "target": target, "rootNames": root_names, "bundle": bundle, @@ -1151,6 +1161,7 @@ mod tests { TargetLib::Main, Permissions::allow_all(), module_graph, + false, ) .await; assert!(result.is_ok()); |