summaryrefslogtreecommitdiff
path: root/cli/tools/compile.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-06-06 17:07:46 -0400
committerGitHub <noreply@github.com>2023-06-06 17:07:46 -0400
commit2aba4365ae620a8f097800e7cf85ff86f566b69a (patch)
tree5e3e9b30742455c72f2edc3fa5db0b7cbabe46e8 /cli/tools/compile.rs
parent455b0eb8bb8445f80d9c80a9161f18c1dede5733 (diff)
perf(cli): conditionally load typescript declaration files (#19392)
Closes #18583
Diffstat (limited to 'cli/tools/compile.rs')
-rw-r--r--cli/tools/compile.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs
index 2ce03e353..540c23fc8 100644
--- a/cli/tools/compile.rs
+++ b/cli/tools/compile.rs
@@ -2,6 +2,7 @@
use crate::args::CompileFlags;
use crate::args::Flags;
+use crate::args::TypeCheckMode;
use crate::factory::CliFactory;
use crate::standalone::is_standalone_binary;
use crate::util::path::path_has_trailing_slash;
@@ -10,6 +11,7 @@ use deno_core::anyhow::Context;
use deno_core::error::generic_error;
use deno_core::error::AnyError;
use deno_core::resolve_url_or_path;
+use deno_graph::GraphKind;
use deno_runtime::colors;
use std::path::Path;
use std::path::PathBuf;
@@ -44,10 +46,20 @@ pub async fn compile(
let graph = Arc::try_unwrap(
module_graph_builder
- .create_graph_and_maybe_check(module_roots)
+ .create_graph_and_maybe_check(module_roots.clone())
.await?,
)
.unwrap();
+ let graph = if cli_options.type_check_mode() == TypeCheckMode::None {
+ graph
+ } else {
+ // In this case, the previous graph creation did type checking, which will
+ // create a module graph with types information in it. We don't want to
+ // store that in the eszip so create a code only module graph from scratch.
+ module_graph_builder
+ .create_graph(GraphKind::CodeOnly, module_roots)
+ .await?
+ };
let parser = parsed_source_cache.as_capturing_parser();
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;