summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-08-22 12:14:59 -0400
committerGitHub <noreply@github.com>2022-08-22 12:14:59 -0400
commit7a1a082876298a4c9e37237074ea62942180d083 (patch)
tree690b46889987a9f576a1b0601a322141b51b0660 /cli/module_loader.rs
parentc66386dbd20b735161017a239c6af013da1f1718 (diff)
perf: cache swc dependency analysis and don't hold onto `ParsedSource`s in memory (#15502)
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r--cli/module_loader.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index 235c35fcd..05dd5bd73 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -67,10 +67,7 @@ impl CliModuleLoader {
let found_url = graph_data.follow_redirect(specifier);
match graph_data.get(&found_url) {
Some(ModuleEntry::Module {
- code,
- media_type,
- maybe_parsed_source,
- ..
+ code, media_type, ..
}) => {
let code = match media_type {
MediaType::JavaScript
@@ -92,11 +89,12 @@ impl CliModuleLoader {
| MediaType::Jsx
| MediaType::Tsx => {
// get emit text
- let parsed_source = maybe_parsed_source.as_ref().unwrap(); // should always be set
emit_parsed_source(
&self.ps.emit_cache,
+ &self.ps.parsed_source_cache,
&found_url,
- parsed_source,
+ *media_type,
+ code,
&self.ps.emit_options,
self.ps.emit_options_hash,
)?
@@ -105,6 +103,10 @@ impl CliModuleLoader {
panic!("Unexpected media type {} for {}", media_type, found_url)
}
};
+
+ // at this point, we no longer need the parsed source in memory, so free it
+ self.ps.parsed_source_cache.free(specifier);
+
Ok(ModuleCodeSource {
code,
found_url,