diff --git a/crates/module_graph/src/edges.rs b/crates/module_graph/src/edges.rs index 2d9a57a..b62645d 100644 --- a/crates/module_graph/src/edges.rs +++ b/crates/module_graph/src/edges.rs @@ -84,7 +84,7 @@ pub fn get_graph(args: Args) -> anyhow::Result { let source_dir_path = path.parent(); let source = - source_path.to_string_lossy().replace('\\', "/").to_string(); + win_path_to_unix(&source_path.to_string_lossy().to_string()); if !ret.errors.is_empty() { syntax_errors @@ -112,7 +112,8 @@ pub fn get_graph(args: Args) -> anyhow::Result { let target_path = pathdiff::diff_paths(resolved.full_path(), cwd_path)?; - let target = target_path.to_string_lossy().to_string(); + let target = + win_path_to_unix(&target_path.to_string_lossy().to_string()); let target_metadata = may_be_node_modules(&target); @@ -253,6 +254,10 @@ fn may_be_node_modules(target: &str) -> Option { None } +fn win_path_to_unix(path: &str) -> String { + path.replace('\\', "/") +} + fn get_main_module_name(module_name: &str) -> String { // e.g. node_modules/antd/lib/Button let module_name = module_name.trim_start_matches("node_modules/");