mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(info): resolve workspace member mappings (#26350)
This PR fixes the issue where mapped specifiers in a workspace member would never be found. Only mapped paths from the workspace root would resolve. This was caused by always passing the workspace root url to the import map resolver instead of the workspace member one. Fixes https://github.com/denoland/deno/issues/26138 Fixes https://github.com/denoland/fresh/issues/2615 --------- Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com> Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
This commit is contained in:
parent
d047cab14b
commit
0e60bb9cf7
8 changed files with 57 additions and 13 deletions
|
@ -11,6 +11,7 @@ use deno_core::anyhow::bail;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
|
use deno_core::url;
|
||||||
use deno_graph::Dependency;
|
use deno_graph::Dependency;
|
||||||
use deno_graph::GraphKind;
|
use deno_graph::GraphKind;
|
||||||
use deno_graph::Module;
|
use deno_graph::Module;
|
||||||
|
@ -51,11 +52,13 @@ pub async fn info(
|
||||||
let npmrc = cli_options.npmrc();
|
let npmrc = cli_options.npmrc();
|
||||||
let resolver = factory.workspace_resolver().await?;
|
let resolver = factory.workspace_resolver().await?;
|
||||||
|
|
||||||
let maybe_import_specifier =
|
let cwd_url =
|
||||||
if let Some(import_map) = resolver.maybe_import_map() {
|
url::Url::from_directory_path(cli_options.initial_cwd()).unwrap();
|
||||||
if let Ok(imports_specifier) =
|
|
||||||
import_map.resolve(&specifier, import_map.base_url())
|
let maybe_import_specifier = if let Some(import_map) =
|
||||||
|
resolver.maybe_import_map()
|
||||||
{
|
{
|
||||||
|
if let Ok(imports_specifier) = import_map.resolve(&specifier, &cwd_url) {
|
||||||
Some(imports_specifier)
|
Some(imports_specifier)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
{
|
||||||
|
"steps": [
|
||||||
{
|
{
|
||||||
"args": "info preact/debug",
|
"args": "info preact/debug",
|
||||||
"output": "with_import_map.out",
|
"output": "with_import_map.out",
|
||||||
"exitCode": 0
|
"exitCode": 0
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
16
tests/specs/info/workspace_member/__test__.jsonc
Normal file
16
tests/specs/info/workspace_member/__test__.jsonc
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"tests": {
|
||||||
|
"member_folder": {
|
||||||
|
"args": "info --quiet foo",
|
||||||
|
"cwd": "member",
|
||||||
|
"output": "info_workspace_member.out",
|
||||||
|
"exitCode": 0
|
||||||
|
},
|
||||||
|
"member_folder_sub": {
|
||||||
|
"args": "info --quiet foo",
|
||||||
|
"cwd": "member/sub",
|
||||||
|
"output": "info_workspace_member_sub.out",
|
||||||
|
"exitCode": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
tests/specs/info/workspace_member/deno.json
Normal file
3
tests/specs/info/workspace_member/deno.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"workspace": ["./member"]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
local: [WILDCARD]file.ts
|
||||||
|
type: TypeScript
|
||||||
|
dependencies: 0 unique
|
||||||
|
size: [WILDCARD]
|
||||||
|
|
||||||
|
file://[WILDCARD]/member/sub/file.ts ([WILDCARD])
|
|
@ -0,0 +1,6 @@
|
||||||
|
local: [WILDCARD]file.ts
|
||||||
|
type: TypeScript
|
||||||
|
dependencies: 0 unique
|
||||||
|
size: [WILDCARD]
|
||||||
|
|
||||||
|
file://[WILDCARD]/member/sub/file.ts ([WILDCARD])
|
5
tests/specs/info/workspace_member/member/deno.json
Normal file
5
tests/specs/info/workspace_member/member/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"imports": {
|
||||||
|
"foo": "./sub/file.ts"
|
||||||
|
}
|
||||||
|
}
|
1
tests/specs/info/workspace_member/member/sub/file.ts
Normal file
1
tests/specs/info/workspace_member/member/sub/file.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
Loading…
Reference in a new issue