summaryrefslogtreecommitdiff
path: root/cli/cache/parsed_source.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-22 14:15:25 -0500
committerGitHub <noreply@github.com>2023-02-22 14:15:25 -0500
commita6ca4d0d61c95b9f7fa79ecce81a31a6d1f6cc5d (patch)
tree278a915d7722a8a3d1fffbfa1f3a12752f44d13f /cli/cache/parsed_source.rs
parent0f9daaeacb402a7199e58b14ad01ec0091ac2c8d (diff)
refactor: use deno_graph for npm specifiers (#17858)
This changes npm specifiers to be handled by deno_graph and resolved to an npm package name and version when the specifier is encountered. It also slightly changes how npm specifier resolution occurs—previously it would collect all the npm specifiers and resolve them all at once, but now it resolves them on the fly as they are encountered in the module graph. https://github.com/denoland/deno_graph/pull/232 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/cache/parsed_source.rs')
-rw-r--r--cli/cache/parsed_source.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs
index fc1b54ddb..b6a80e82e 100644
--- a/cli/cache/parsed_source.rs
+++ b/cli/cache/parsed_source.rs
@@ -75,19 +75,15 @@ impl ParsedSourceCache {
}
}
- pub fn get_parsed_source_from_module(
+ pub fn get_parsed_source_from_esm_module(
&self,
- module: &deno_graph::Module,
- ) -> Result<Option<ParsedSource>, AnyError> {
- if let Some(source) = &module.maybe_source {
- Ok(Some(self.get_or_parse_module(
- &module.specifier,
- source.clone(),
- module.media_type,
- )?))
- } else {
- Ok(None)
- }
+ module: &deno_graph::EsmModule,
+ ) -> Result<ParsedSource, deno_ast::Diagnostic> {
+ self.get_or_parse_module(
+ &module.specifier,
+ module.source.clone(),
+ module.media_type,
+ )
}
/// Gets the matching `ParsedSource` from the cache