summaryrefslogtreecommitdiff
path: root/cli/graph_util.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-09-07 08:09:16 -0500
committerGitHub <noreply@github.com>2023-09-07 09:09:16 -0400
commit3fc19dab47492e06043fc7add28e64693a4eb775 (patch)
tree855e952933662aef37bd20c084901ae0e488b2db /cli/graph_util.rs
parent01a761f1d4f7ff4943fbf80464a276b434d8a8f7 (diff)
feat: support import attributes (#20342)
Diffstat (limited to 'cli/graph_util.rs')
-rw-r--r--cli/graph_util.rs48
1 files changed, 44 insertions, 4 deletions
diff --git a/cli/graph_util.rs b/cli/graph_util.rs
index fc530032a..6fb4b7790 100644
--- a/cli/graph_util.rs
+++ b/cli/graph_util.rs
@@ -237,6 +237,8 @@ impl ModuleGraphBuilder {
npm_resolver: Some(graph_npm_resolver),
module_analyzer: Some(&*analyzer),
reporter: maybe_file_watcher_reporter,
+ // todo(dsherret): workspace support
+ workspace_members: vec![],
},
)
.await?;
@@ -280,6 +282,8 @@ impl ModuleGraphBuilder {
npm_resolver: Some(graph_npm_resolver),
module_analyzer: Some(&*analyzer),
reporter: maybe_file_watcher_reporter,
+ // todo(dsherret): workspace support
+ workspace_members: vec![],
},
)
.await?;
@@ -338,15 +342,35 @@ impl ModuleGraphBuilder {
}
}
+ // todo(dsherret): uncomment when adding deno: specifier support
+ // add the deno specifiers to the graph if it's the first time executing
+ // if graph.deno_specifiers.is_empty() {
+ // if let Some(lockfile) = &self.lockfile {
+ // let lockfile = lockfile.lock();
+ // for (key, value) in &lockfile.content.packages.specifiers {
+ // if let Some(key) = key
+ // .strip_prefix("deno:")
+ // .and_then(|key| PackageReq::from_str(key))
+ // {
+ // if let Ok(value) = value
+ // .strip_prefix("deno:")
+ // .and_then(|value| PackageNv::from_str(value))
+ // {
+ // graph.deno_specifiers.add(key, value);
+ // }
+ // }
+ // }
+ // }
+ // }
+
graph.build(roots, loader, options).await;
// add the redirects in the graph to the lockfile
if !graph.redirects.is_empty() {
if let Some(lockfile) = &self.lockfile {
- let graph_redirects = graph
- .redirects
- .iter()
- .filter(|(from, _)| !matches!(from.scheme(), "npm" | "file"));
+ let graph_redirects = graph.redirects.iter().filter(|(from, _)| {
+ !matches!(from.scheme(), "npm" | "file" | "deno")
+ });
let mut lockfile = lockfile.lock();
for (from, to) in graph_redirects {
lockfile.insert_redirect(from.to_string(), to.to_string());
@@ -354,6 +378,21 @@ impl ModuleGraphBuilder {
}
}
+ // todo(dsherret): uncomment when adding support for deno specifiers
+ // add the deno specifiers in the graph to the lockfile
+ // if !graph.deno_specifiers.is_empty() {
+ // if let Some(lockfile) = &self.lockfile {
+ // let mappings = graph.deno_specifiers.mappings();
+ // let mut lockfile = lockfile.lock();
+ // for (from, to) in mappings {
+ // lockfile.insert_package_specifier(
+ // format!("deno:{}", from),
+ // format!("deno:{}", to),
+ // );
+ // }
+ // }
+ // }
+
// ensure that the top level package.json is installed if a
// specifier was matched in the package.json
self
@@ -382,6 +421,7 @@ impl ModuleGraphBuilder {
self.file_fetcher.clone(),
self.options.resolve_file_header_overrides(),
self.global_http_cache.clone(),
+ self.parsed_source_cache.clone(),
permissions,
self.options.node_modules_dir_specifier(),
)