From c3e48cba184f2f8aaf3d30196b674c8a7dd8449b Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 29 Aug 2022 14:24:10 -0400 Subject: fix(compile): panic when running with a populated dep analysis cache (#15672) Closes #15612 --- cli/cache/parsed_source.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cli/cache/parsed_source.rs') diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs index b35a89a14..0c9fe5c97 100644 --- a/cli/cache/parsed_source.rs +++ b/cli/cache/parsed_source.rs @@ -88,7 +88,7 @@ impl ParsedSourceCache { source: Arc, media_type: MediaType, ) -> deno_core::anyhow::Result { - let parser = CapturingModuleParser::new(None, &self.sources); + let parser = self.as_capturing_parser(); // this will conditionally parse because it's using a CapturingModuleParser parser.parse_module(specifier, source, media_type) } @@ -124,6 +124,12 @@ impl ParsedSourceCache { } } } + + /// Creates a parser that will reuse a ParsedSource from the store + /// if it exists, or else parse. + pub fn as_capturing_parser(&self) -> CapturingModuleParser { + CapturingModuleParser::new(None, &self.sources) + } } struct ParsedSourceCacheModuleAnalyzer { -- cgit v1.2.3