diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2022-02-23 10:51:14 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 10:51:14 +1100 |
commit | ee27b9dd7e8ef311c6bfaa3264f7b9908a784a24 (patch) | |
tree | 34c5f1735defe6e6680ec97ba2f8f875721f94b1 /cli/main.rs | |
parent | 6613a312b160374ba7a86c3b88fb67c0fe4247e0 (diff) |
feat: allow specification of import map in config file (#13739)
Closes: #12800
Diffstat (limited to 'cli/main.rs')
-rw-r--r-- | cli/main.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/cli/main.rs b/cli/main.rs index f8c5d69df..091c33b13 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -803,9 +803,14 @@ async fn bundle_command( }) .collect(); - if let Some(import_map) = ps.flags.import_map_path.as_ref() { - paths_to_watch - .push(fs_util::resolve_from_cwd(std::path::Path::new(import_map))?); + if let Ok(Some(import_map_path)) = + config_file::resolve_import_map_specifier( + ps.flags.import_map_path.as_deref(), + ps.maybe_config_file.as_ref(), + ) + .map(|ms| ms.map(|ref s| s.to_file_path().ok()).flatten()) + { + paths_to_watch.push(import_map_path); } Ok((paths_to_watch, graph, ps)) @@ -1047,9 +1052,14 @@ async fn run_with_watch(flags: Flags, script: String) -> Result<i32, AnyError> { paths_to_watch.extend(watch_paths); } - if let Some(import_map) = ps.flags.import_map_path.as_ref() { - paths_to_watch - .push(fs_util::resolve_from_cwd(std::path::Path::new(import_map))?); + if let Ok(Some(import_map_path)) = + config_file::resolve_import_map_specifier( + ps.flags.import_map_path.as_deref(), + ps.maybe_config_file.as_ref(), + ) + .map(|ms| ms.map(|ref s| s.to_file_path().ok()).flatten()) + { + paths_to_watch.push(import_map_path); } Ok((paths_to_watch, main_module, ps)) |