Improve path handling in sourcemap processing

- Enhanced the logic for creating output file paths by attempting to generate relative paths from the project directory.
- Added a fallback to absolute paths for files outside the project directory, improving robustness in path management.
This commit is contained in:
Joe 2026-01-22 23:05:39 -06:00
parent 9abc0e4728
commit 4a6fdaa02d

View file

@ -207,9 +207,13 @@ fn recurse_create_node<'a>(
} }
} else { } else {
for val in file_paths { for val in file_paths {
output_file_paths.push(Cow::from( // Try to create relative path, fall back to absolute if path is outside project dir
val.strip_prefix(project_dir).expect(PATH_STRIP_FAILED_ERR), match val.strip_prefix(project_dir) {
)); Ok(relative) => output_file_paths.push(Cow::from(relative)),
Err(_) => output_file_paths.push(Cow::Owned(
path::absolute(val).expect(ABSOLUTE_PATH_FAILED_ERR),
)),
}
} }
}; };