Skip to content

Commit b7688cc

Browse files
authored
refactor: path relative in source map plugin (#8903)
fix: path relative
1 parent 283324b commit b7688cc

File tree

5 files changed

+13
-166
lines changed

5 files changed

+13
-166
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rspack_plugin_devtool/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rspack_util = { workspace = true }
2727
rustc-hash = { workspace = true }
2828
simd-json = { workspace = true }
2929
tracing = { workspace = true }
30+
sugar_path = { workspace = true }
3031

3132
[package.metadata.cargo-shear]
3233
ignored = ["tracing"]

crates/rspack_plugin_devtool/src/source_map_dev_tool_plugin.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use rspack_error::{error, miette::IntoDiagnostic, Result};
1919
use rspack_hash::RspackHash;
2020
use rspack_hook::{plugin, plugin_hook};
2121
use rspack_util::asset_condition::AssetConditions;
22-
use rspack_util::{
23-
identifier::make_paths_absolute, infallible::ResultInfallibleExt, path::relative,
24-
};
22+
use rspack_util::{identifier::make_paths_absolute, infallible::ResultInfallibleExt};
2523
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
24+
use sugar_path::SugarPath;
2625

2726
use crate::{
2827
mapped_assets_cache::MappedAssetsCache, module_filename_helpers::ModuleFilenameHelpers,
@@ -448,7 +447,8 @@ impl SourceMapDevToolPlugin {
448447
let chunk = file_to_chunk.get(&source_filename);
449448
let filename = match &self.file_context {
450449
Some(file_context) => Cow::Owned(
451-
relative(Path::new(file_context), Path::new(&source_filename))
450+
Path::new(&source_filename)
451+
.relative(Path::new(file_context))
452452
.to_string_lossy()
453453
.to_string(),
454454
),
@@ -493,13 +493,13 @@ impl SourceMapDevToolPlugin {
493493
source_map_path.push(Component::RootDir);
494494
source_map_path.extend(Path::new(&source_map_filename).components());
495495

496-
relative(
497-
#[allow(clippy::unwrap_used)]
498-
file_path.parent().unwrap(),
499-
&source_map_path,
500-
)
501-
.to_string_lossy()
502-
.to_string()
496+
source_map_path
497+
.relative(
498+
#[allow(clippy::unwrap_used)]
499+
file_path.parent().unwrap(),
500+
)
501+
.to_string_lossy()
502+
.to_string()
503503
};
504504
let data = data.url(&source_map_url);
505505
let current_source_mapping_url_comment = match &current_source_mapping_url_comment {

crates/rspack_util/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub mod infallible;
1313
pub mod itoa;
1414
pub mod location;
1515
pub mod number_hash;
16-
pub mod path;
1716
pub mod queue;
1817
pub mod size;
1918
pub mod source_map;

crates/rspack_util/src/path.rs

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)