summaryrefslogtreecommitdiff
path: root/cli/module_loader.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-10-01 06:15:56 -0400
committerGitHub <noreply@github.com>2022-10-01 12:15:56 +0200
commitecfafda9d8ead19cb35708f310e49176db2ec2b5 (patch)
tree222a52e0e5c06cc946d45240a6194c57b46a8724 /cli/module_loader.rs
parent1058d1868fcc28ce115d1cc231e66016308b76ce (diff)
perf: node cjs & esm analysis cache (#16097)
This commit adds a cache for CJS and ESM analysis that is backed by an SQLite file. The connection to the DB is lazily created on first use, so shouldn't have impact on the startup time. Benched with running Vite Deno v1.26: ``` $ deno task dev Warning deno task is unstable and may drastically change in the future Task dev deno run -A --unstable --node-modules-dir npm:vite VITE v3.1.4 ready in 961 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ``` This branch: ``` ../deno/target/release/deno task dev Warning deno task is unstable and may drastically change in the future Task dev deno run -A --unstable --node-modules-dir npm:vite VITE v3.1.4 ready in 330 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ``` Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/module_loader.rs')
-rw-r--r--cli/module_loader.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index 1213358b9..893020321 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -156,10 +156,15 @@ impl CliModuleLoader {
code,
MediaType::Cjs,
&self.ps.npm_resolver,
+ &self.ps.node_analysis_cache,
)?
} else {
// only inject node globals for esm
- node::esm_code_with_node_globals(specifier, code)?
+ node::esm_code_with_node_globals(
+ &self.ps.node_analysis_cache,
+ specifier,
+ code,
+ )?
};
ModuleCodeSource {
code,