From ecfafda9d8ead19cb35708f310e49176db2ec2b5 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 1 Oct 2022 06:15:56 -0400 Subject: perf: node cjs & esm analysis cache (#16097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cli/module_loader.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cli/module_loader.rs') 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, -- cgit v1.2.3