Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ityuany committed Dec 19, 2024
1 parent 3c24a5b commit 4106059
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/module_graph/src/edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn get_graph(args: Args) -> anyhow::Result<Graphics> {
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
Expand Down Expand Up @@ -112,7 +112,8 @@ pub fn get_graph(args: Args) -> anyhow::Result<Graphics> {
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);

Expand Down Expand Up @@ -253,6 +254,10 @@ fn may_be_node_modules(target: &str) -> Option<TargetMetadata> {
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/");
Expand Down

0 comments on commit 4106059

Please sign in to comment.