refactor(emitter): ability to not transpile and specify a source map base (#29996)
Some checks failed
ci / pre-build (push) Has been cancelled
ci / build libs (push) Has been cancelled
ci / test debug linux-aarch64 (push) Has been cancelled
ci / test release linux-aarch64 (push) Has been cancelled
ci / test debug macos-aarch64 (push) Has been cancelled
ci / test release macos-aarch64 (push) Has been cancelled
ci / bench release linux-x86_64 (push) Has been cancelled
ci / lint debug linux-x86_64 (push) Has been cancelled
ci / lint debug macos-x86_64 (push) Has been cancelled
ci / lint debug windows-x86_64 (push) Has been cancelled
ci / test debug linux-x86_64 (push) Has been cancelled
ci / test release linux-x86_64 (push) Has been cancelled
ci / test debug macos-x86_64 (push) Has been cancelled
ci / test release macos-x86_64 (push) Has been cancelled
ci / test debug windows-x86_64 (push) Has been cancelled
ci / test release windows-x86_64 (push) Has been cancelled
ci / publish canary (push) Has been cancelled

This commit is contained in:
David Sherret 2025-07-04 12:51:17 -04:00 committed by GitHub
parent 51c43ce8b4
commit 90058d6732
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 205 additions and 84 deletions

View file

@ -58,13 +58,27 @@ impl ParsedSourceCache {
pub fn get_parsed_source_from_js_module(
&self,
module: &deno_graph::JsModule,
) -> Result<ParsedSource, deno_ast::ParseDiagnostic> {
self.get_matching_parsed_source(
&module.specifier,
module.media_type,
module.source.text.clone(),
)
}
#[allow(clippy::result_large_err)]
pub fn get_matching_parsed_source(
&self,
specifier: &Url,
media_type: MediaType,
source: ArcStr,
) -> Result<ParsedSource, deno_ast::ParseDiagnostic> {
let parser = self.as_capturing_parser();
// this will conditionally parse because it's using a CapturingEsParser
parser.parse_program(deno_graph::ast::ParseOptions {
specifier: &module.specifier,
source: module.source.text.clone(),
media_type: module.media_type,
specifier,
source,
media_type,
scope_analysis: false,
})
}
@ -73,8 +87,8 @@ impl ParsedSourceCache {
pub fn remove_or_parse_module(
&self,
specifier: &Url,
source: ArcStr,
media_type: MediaType,
source: ArcStr,
) -> Result<ParsedSource, deno_ast::ParseDiagnostic> {
if let Some(parsed_source) = self.remove_parsed_source(specifier) {
if parsed_source.media_type() == media_type