1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

fix: deno info should respect import map (#19781)

Closes #19742
This commit is contained in:
Vedant Pandey 2023-07-25 21:53:43 +05:30 committed by Matt Mastracci
parent 49b99b5dfe
commit 2b73ea9b16
6 changed files with 57 additions and 1 deletions

View file

@ -147,3 +147,10 @@ itest!(package_json_basic {
copy_temp_dir: Some("package_json/basic"), copy_temp_dir: Some("package_json/basic"),
exit_code: 0, exit_code: 0,
}); });
itest!(info_import_map {
args: "info preact/debug",
output: "info/with_import_map/with_import_map.out",
cwd: Some("info/with_import_map"),
exit_code: 0,
});

View file

@ -0,0 +1,6 @@
{
"imports": {
"preact": "https://esm.sh/preact@10.15.1",
"preact/": "https://esm.sh/preact@10.15.1/"
}
}

View file

@ -0,0 +1,7 @@
{
"version": "2",
"remote": {
"https://esm.sh/preact@10.15.1": "2b79349676a4942fbcf835c4efa909791c2f0aeca195225bf22bac9866e94b4e",
"https://esm.sh/stable/preact@10.15.1/denonext/preact.mjs": "30710ac1d5ff3711ae0c04eddbeb706f34f82d97489f61aaf09897bc75d2a628"
}
}

View file

@ -0,0 +1,2 @@
import { render } from "preact";
console.log(render);

View file

@ -0,0 +1,16 @@
Download https://esm.sh/preact@10.15.1/debug
Download https://esm.sh/stable/preact@10.15.1/denonext/preact.mjs
Download https://esm.sh/stable/preact@10.15.1/denonext/devtools.js
Download https://esm.sh/stable/preact@10.15.1/denonext/debug.js
local: [WILDCARD]
type: JavaScript
dependencies: 3 unique
size: [WILDCARD]
https://esm.sh/preact@10.15.1/debug [WILDCARD]
├── https://esm.sh/stable/preact@10.15.1/denonext/preact.mjs [WILDCARD]
├─┬ https://esm.sh/stable/preact@10.15.1/denonext/devtools.js [WILDCARD]
│ └── https://esm.sh/stable/preact@10.15.1/denonext/preact.mjs [WILDCARD]
└─┬ https://esm.sh/stable/preact@10.15.1/denonext/debug.js [WILDCARD]
├── https://esm.sh/stable/preact@10.15.1/denonext/preact.mjs [WILDCARD]
└── https://esm.sh/stable/preact@10.15.1/denonext/devtools.js [WILDCARD]

View file

@ -40,7 +40,25 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
let module_graph_builder = factory.module_graph_builder().await?; let module_graph_builder = factory.module_graph_builder().await?;
let npm_resolver = factory.npm_resolver().await?; let npm_resolver = factory.npm_resolver().await?;
let maybe_lockfile = factory.maybe_lockfile(); let maybe_lockfile = factory.maybe_lockfile();
let specifier = resolve_url_or_path(&specifier, cli_options.initial_cwd())?; let maybe_imports_map = factory.maybe_import_map().await?;
let maybe_import_specifier = if let Some(imports_map) = maybe_imports_map {
if let Ok(imports_specifier) =
imports_map.resolve(&specifier, imports_map.base_url())
{
Some(imports_specifier)
} else {
None
}
} else {
None
};
let specifier = match maybe_import_specifier {
Some(specifier) => specifier,
None => resolve_url_or_path(&specifier, cli_options.initial_cwd())?,
};
let mut loader = module_graph_builder.create_graph_loader(); let mut loader = module_graph_builder.create_graph_loader();
loader.enable_loading_cache_info(); // for displaying the cache information loader.enable_loading_cache_info(); // for displaying the cache information
let graph = module_graph_builder let graph = module_graph_builder