mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
Fix import map panics, use import map's location as its base URL (#2770)
This commit is contained in:
parent
d2d3afaf2d
commit
52a66c2796
3 changed files with 40 additions and 18 deletions
23
cli/state.rs
23
cli/state.rs
|
@ -200,14 +200,7 @@ impl ThreadSafeState {
|
|||
|
||||
let import_map: Option<ImportMap> = match &flags.import_map_path {
|
||||
None => None,
|
||||
Some(file_name) => {
|
||||
let base_url = match &main_module {
|
||||
Some(module_specifier) => module_specifier.clone(),
|
||||
None => unreachable!(),
|
||||
};
|
||||
let import_map = ImportMap::load(&base_url.to_string(), file_name)?;
|
||||
Some(import_map)
|
||||
}
|
||||
Some(file_path) => Some(ImportMap::load(file_path)?),
|
||||
};
|
||||
|
||||
let mut seeded_rng = None;
|
||||
|
@ -380,3 +373,17 @@ fn thread_safe() {
|
|||
String::from("hello.js"),
|
||||
]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_map_given_for_repl() {
|
||||
let _result = ThreadSafeState::new(
|
||||
flags::DenoFlags {
|
||||
import_map_path: Some("import_map.json".to_string()),
|
||||
..flags::DenoFlags::default()
|
||||
},
|
||||
vec![String::from("./deno")],
|
||||
ops::op_selector_std,
|
||||
Progress::new(),
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue