mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 05:14:21 -05:00
fix(install): use locked version of jsr package when fetching exports (#27237)
Fixes #27193.
This commit is contained in:
parent
f098dd02f7
commit
ffac282805
17 changed files with 128 additions and 38 deletions
|
@ -109,6 +109,25 @@ pub fn graph_valid(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fill_graph_from_lockfile(
|
||||
graph: &mut ModuleGraph,
|
||||
lockfile: &deno_lockfile::Lockfile,
|
||||
) {
|
||||
graph.fill_from_lockfile(FillFromLockfileOptions {
|
||||
redirects: lockfile
|
||||
.content
|
||||
.redirects
|
||||
.iter()
|
||||
.map(|(from, to)| (from.as_str(), to.as_str())),
|
||||
package_specifiers: lockfile
|
||||
.content
|
||||
.packages
|
||||
.specifiers
|
||||
.iter()
|
||||
.map(|(dep, id)| (dep, id.as_str())),
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GraphWalkErrorsOptions {
|
||||
pub check_js: bool,
|
||||
|
@ -603,19 +622,7 @@ impl ModuleGraphBuilder {
|
|||
// populate the information from the lockfile
|
||||
if let Some(lockfile) = &self.lockfile {
|
||||
let lockfile = lockfile.lock();
|
||||
graph.fill_from_lockfile(FillFromLockfileOptions {
|
||||
redirects: lockfile
|
||||
.content
|
||||
.redirects
|
||||
.iter()
|
||||
.map(|(from, to)| (from.as_str(), to.as_str())),
|
||||
package_specifiers: lockfile
|
||||
.content
|
||||
.packages
|
||||
.specifiers
|
||||
.iter()
|
||||
.map(|(dep, id)| (dep, id.as_str())),
|
||||
});
|
||||
fill_graph_from_lockfile(graph, &lockfile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::factory::CliFactory;
|
||||
|
@ -37,6 +38,16 @@ pub async fn cache_top_level_deps(
|
|||
factory.file_fetcher()?.clone(),
|
||||
))
|
||||
};
|
||||
let mut graph_permit = factory
|
||||
.main_module_graph_container()
|
||||
.await?
|
||||
.acquire_update_permit()
|
||||
.await;
|
||||
let graph = graph_permit.graph_mut();
|
||||
if let Some(lockfile) = cli_options.maybe_lockfile() {
|
||||
let lockfile = lockfile.lock();
|
||||
crate::graph_util::fill_graph_from_lockfile(graph, &lockfile);
|
||||
}
|
||||
|
||||
let mut roots = Vec::new();
|
||||
|
||||
|
@ -67,13 +78,16 @@ pub async fn cache_top_level_deps(
|
|||
if !seen_reqs.insert(req.req().clone()) {
|
||||
continue;
|
||||
}
|
||||
let resolved_req = graph.packages.mappings().get(req.req());
|
||||
let jsr_resolver = jsr_resolver.clone();
|
||||
info_futures.push(async move {
|
||||
if let Some(nv) = jsr_resolver.req_to_nv(req.req()).await {
|
||||
if let Some(info) = jsr_resolver.package_version_info(&nv).await
|
||||
{
|
||||
return Some((specifier.clone(), info));
|
||||
}
|
||||
let nv = if let Some(req) = resolved_req {
|
||||
Cow::Borrowed(req)
|
||||
} else {
|
||||
Cow::Owned(jsr_resolver.req_to_nv(req.req()).await?)
|
||||
};
|
||||
if let Some(info) = jsr_resolver.package_version_info(&nv).await {
|
||||
return Some((specifier.clone(), info));
|
||||
}
|
||||
None
|
||||
});
|
||||
|
@ -106,12 +120,8 @@ pub async fn cache_top_level_deps(
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut graph_permit = factory
|
||||
.main_module_graph_container()
|
||||
.await?
|
||||
.acquire_update_permit()
|
||||
.await;
|
||||
let graph = graph_permit.graph_mut();
|
||||
drop(info_futures);
|
||||
|
||||
factory
|
||||
.module_load_preparer()
|
||||
.await?
|
||||
|
|
|
@ -18,7 +18,6 @@ use deno_core::futures::stream::FuturesUnordered;
|
|||
use deno_core::futures::FutureExt;
|
||||
use deno_core::futures::StreamExt;
|
||||
use deno_core::serde_json;
|
||||
use deno_graph::FillFromLockfileOptions;
|
||||
use deno_package_json::PackageJsonDepsMap;
|
||||
use deno_package_json::PackageJsonRc;
|
||||
use deno_runtime::deno_permissions::PermissionsContainer;
|
||||
|
@ -533,19 +532,8 @@ impl DepManager {
|
|||
// populate the information from the lockfile
|
||||
if let Some(lockfile) = &self.lockfile {
|
||||
let lockfile = lockfile.lock();
|
||||
graph.fill_from_lockfile(FillFromLockfileOptions {
|
||||
redirects: lockfile
|
||||
.content
|
||||
.redirects
|
||||
.iter()
|
||||
.map(|(from, to)| (from.as_str(), to.as_str())),
|
||||
package_specifiers: lockfile
|
||||
.content
|
||||
.packages
|
||||
.specifiers
|
||||
.iter()
|
||||
.map(|(dep, id)| (dep, id.as_str())),
|
||||
});
|
||||
|
||||
crate::graph_util::fill_graph_from_lockfile(graph, &lockfile);
|
||||
}
|
||||
|
||||
let npm_resolver = self.npm_resolver.as_managed().unwrap();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from "jsr:@denotest/add@1";
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"a": 1
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from "jsr:@denotest/subtract@1";
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"exports": {
|
||||
"./add": "./add.ts",
|
||||
"./subtract": "./subtract.ts",
|
||||
"./data-json": "./data.json"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from "jsr:@denotest/add@1";
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"a": 1
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export function multiply(a: number, b: number): number {
|
||||
return a * b;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from "jsr:@denotest/subtract@1";
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"exports": {
|
||||
"./add": "./add.ts",
|
||||
"./subtract": "./subtract.ts",
|
||||
"./data-json": "./data.json",
|
||||
"./multiply": "./multiply.ts"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"versions": {
|
||||
"1.0.0": {},
|
||||
"0.7.1": {},
|
||||
"0.7.0": {},
|
||||
"0.5.0": {},
|
||||
"0.2.0": {}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"tempDir": true,
|
||||
"steps": [
|
||||
{
|
||||
"args": "install",
|
||||
"output": "install.out"
|
||||
}
|
||||
]
|
||||
}
|
5
tests/specs/install/jsr_exports_uses_locked/deno.json
Normal file
5
tests/specs/install/jsr_exports_uses_locked/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"imports": {
|
||||
"@denotest/multiple-exports": "jsr:@denotest/multiple-exports@^0.7.0"
|
||||
}
|
||||
}
|
28
tests/specs/install/jsr_exports_uses_locked/deno.lock
Normal file
28
tests/specs/install/jsr_exports_uses_locked/deno.lock
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@denotest/add@1": "1.0.0",
|
||||
"jsr:@denotest/multiple-exports@0.7": "0.7.0",
|
||||
"jsr:@denotest/subtract@1": "1.0.0"
|
||||
},
|
||||
"jsr": {
|
||||
"@denotest/add@1.0.0": {
|
||||
"integrity": "3b2e675c1ad7fba2a45bc251992e01aff08a3c974ac09079b11e6a5b95d4bfcb"
|
||||
},
|
||||
"@denotest/multiple-exports@0.7.0": {
|
||||
"integrity": "efe9748a0c0939c7ac245fee04acc0c42bd7a61874ff71a360c4543e4f5f6b36",
|
||||
"dependencies": [
|
||||
"jsr:@denotest/add",
|
||||
"jsr:@denotest/subtract"
|
||||
]
|
||||
},
|
||||
"@denotest/subtract@1.0.0": {
|
||||
"integrity": "e178a7101c073e93d9efa6833d5cbf83bc1bc8d509b7c2a5ecbf74265e917597"
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"jsr:@denotest/multiple-exports@0.7"
|
||||
]
|
||||
}
|
||||
}
|
13
tests/specs/install/jsr_exports_uses_locked/install.out
Normal file
13
tests/specs/install/jsr_exports_uses_locked/install.out
Normal file
|
@ -0,0 +1,13 @@
|
|||
[UNORDERED_START]
|
||||
Download http://127.0.0.1:4250/@denotest/multiple-exports/0.7.0_meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/multiple-exports/meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/multiple-exports/0.7.0/add.ts
|
||||
Download http://127.0.0.1:4250/@denotest/multiple-exports/0.7.0/subtract.ts
|
||||
Download http://127.0.0.1:4250/@denotest/multiple-exports/0.7.0/data.json
|
||||
Download http://127.0.0.1:4250/@denotest/add/meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/subtract/meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/subtract/1.0.0_meta.json
|
||||
Download http://127.0.0.1:4250/@denotest/add/1.0.0/mod.ts
|
||||
Download http://127.0.0.1:4250/@denotest/subtract/1.0.0/mod.ts
|
||||
[UNORDERED_END]
|
Loading…
Reference in a new issue