summaryrefslogtreecommitdiff
path: root/cli/emit.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2021-11-23 21:20:30 +0000
committerGitHub <noreply@github.com>2021-11-24 08:20:30 +1100
commit7413c96985507e7d129fef9374f560fbc2f38d7e (patch)
treed7f33a4deb180d7ff0f636ac4030249803ba7fce /cli/emit.rs
parentd2c53e7f10086109dc49785a9dbc36023c28b577 (diff)
fix(cli): don't cache .tsbuildinfo unless emitting (#12830)
Fixes #12755 Fixes #12807 Fixes #12832
Diffstat (limited to 'cli/emit.rs')
-rw-r--r--cli/emit.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/cli/emit.rs b/cli/emit.rs
index 9eac892ff..86cb8f57c 100644
--- a/cli/emit.rs
+++ b/cli/emit.rs
@@ -304,6 +304,8 @@ pub(crate) struct CheckOptions {
pub maybe_config_specifier: Option<ModuleSpecifier>,
/// The derived tsconfig that should be used when checking.
pub ts_config: TsConfig,
+ /// If true, existing `.tsbuildinfo` files will be ignored.
+ pub reload: bool,
}
/// The result of a check or emit of a module graph. Note that the actual
@@ -331,8 +333,11 @@ pub(crate) fn check_and_maybe_emit(
// while there might be multiple roots, we can't "merge" the build info, so we
// try to retrieve the build info for first root, which is the most common use
// case.
- let maybe_tsbuildinfo =
- cache.get(CacheType::TypeScriptBuildInfo, &graph.roots[0]);
+ let maybe_tsbuildinfo = if options.reload {
+ None
+ } else {
+ cache.get(CacheType::TypeScriptBuildInfo, &graph.roots[0])
+ };
// to make tsc build info work, we need to consistently hash modules, so that
// tsc can better determine if an emit is still valid or not, so we provide
// that data here.
@@ -352,18 +357,18 @@ pub(crate) fn check_and_maybe_emit(
root_names,
})?;
- if let Some(info) = &response.maybe_tsbuildinfo {
- // while we retrieve the build info for just the first module, it can be
- // used for all the roots in the graph, so we will cache it for all roots
- for root in &graph.roots {
- cache.set(CacheType::TypeScriptBuildInfo, root, info.clone())?;
- }
- }
// sometimes we want to emit when there are diagnostics, and sometimes we
// don't. tsc will always return an emit if there are diagnostics
if (response.diagnostics.is_empty() || options.emit_with_diagnostics)
&& !response.emitted_files.is_empty()
{
+ if let Some(info) = &response.maybe_tsbuildinfo {
+ // while we retrieve the build info for just the first module, it can be
+ // used for all the roots in the graph, so we will cache it for all roots
+ for root in &graph.roots {
+ cache.set(CacheType::TypeScriptBuildInfo, root, info.clone())?;
+ }
+ }
for emit in response.emitted_files.into_iter() {
if let Some(specifiers) = emit.maybe_specifiers {
assert!(specifiers.len() == 1);