fix(compile): panic when running with a populated dep analysis cache (#15672)

Closes #15612
This commit is contained in:
David Sherret 2022-08-29 14:24:10 -04:00 committed by GitHub
parent b62ef4d37b
commit c3e48cba18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 51 deletions

View file

@ -88,7 +88,7 @@ impl ParsedSourceCache {
source: Arc<str>,
media_type: MediaType,
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
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 {