Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ regex-syntax = { version = "0.8.5", default-features = false, features =
regress = { version = "0.10.4", default-features = false, features = ["pattern"] }
ropey = { version = "1.6.1", default-features = false }
rspack_resolver = { features = ["package_json_raw_json_api", "yarn_pnp"], version = "0.6.3", default-features = false }
rspack_sources = { version = "=0.4.11", default-features = false }
rspack_sources = { git = "https://github.com/SyMind/rspack-sources.git", rev = "1cbefbd08acf0225a9eae9bb4e01084b6886f650", default-features = false }
rustc-hash = { version = "2.1.0", default-features = false }
ryu-js = { version = "1.0.2", default-features = false }
scopeguard = { version = "1.2.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_binding_api/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'s> From<JsCompatSource<'s>> for BoxSource {
match value.source {
Either::A(string) => {
if let Some(map) = value.map {
match SourceMap::from_slice(map.as_ref()).ok() {
match SourceMap::from_json(map).ok() {
Some(source_map) => SourceMapSource::new(WithoutOriginalOptions {
value: string,
name: "inmemory://from js",
Expand Down Expand Up @@ -55,7 +55,7 @@ impl From<JsCompatSourceOwned> for BoxSource {
match value.source {
Either::A(string) => {
if let Some(map) = value.map {
match SourceMap::from_slice(map.as_ref()).ok() {
match SourceMap::from_json(map).ok() {
Some(source_map) => SourceMapSource::new(WithoutOriginalOptions {
value: string,
name: "inmemory://from js",
Expand Down
7 changes: 4 additions & 3 deletions crates/rspack_binding_api/src/swc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ impl From<CompilerTransformOutput> for TransformOutput {
fn from(value: CompilerTransformOutput) -> Self {
Self {
code: value.code,
map: value
.map
.map(|v| serde_json::to_string(&v).expect("failed to serialize transformOutput.map")),
map: value.map.map(|v| {
v.to_json()
.expect("failed to serialize transformOutput.map")
}),
diagnostics: value.diagnostics,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
deserializer: &mut D,
) -> Result<BoxSource, DeserializeError> {
let CacheableSource { buffer, map } = field.deserialize(deserializer)?;
if let Some(map) = &map
if let Some(map) = map
&& let Ok(source_map) = SourceMap::from_json(map)
{
return Ok(
Expand Down
5 changes: 4 additions & 1 deletion crates/rspack_core/src/utils/extract_source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ pub async fn extract_source_map(
};

// Get sources from SourceMap and take ownership
let sources = source_map.sources().to_vec();
let sources = source_map
.sources()
.map(|s| s.to_string())
.collect::<Vec<_>>();
let source_root = source_map.source_root().map(|s| s.to_string());

// Pre-collect all source content to avoid borrowing issues
Expand Down
1 change: 0 additions & 1 deletion crates/rspack_loader_swc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl SwcLoader {
map.set_sources(
map
.sources()
.iter()
.map(|source| {
let source_path = Path::new(source);
if source_path.is_relative() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn eval_source_map_devtool_plugin_render_module_content(
let source = &origin_source.source();

{
let modules = map.sources().iter().map(|source| {
let modules = map.sources().map(|source| {
if let Some(stripped) = source.strip_prefix("webpack://") {
let source = make_paths_absolute(compilation.options.context.as_str(), stripped);
let identifier = ModuleIdentifier::from(source.as_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,7 @@ impl SourceMapDevToolPlugin {
let source_map_modules = mapped_sources
.par_iter()
.filter_map(|(file, _asset, source_map)| source_map.as_ref().map(|s| (file, s)))
.flat_map(|(file, source_map)| {
source_map
.sources()
.iter()
.map(|i| (file, i))
.collect::<Vec<_>>()
})
.flat_map(|(file, source_map)| source_map.sources().map(|i| (file, i)).collect::<Vec<_>>())
.map(|(file, source)| {
let module_or_source = if let Some(stripped) = source.strip_prefix("webpack://") {
let source = make_paths_absolute(compilation.options.context.as_str(), stripped);
Expand Down Expand Up @@ -415,7 +409,6 @@ impl SourceMapDevToolPlugin {
source_map.set_sources(
source_map
.sources()
.iter()
.map(|source| {
let module_or_source = source_map_modules
.get(source)
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_plugin_rsdoctor/src/module_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ pub fn collect_module_original_sources(
.source()
.and_then(|s| s.map(&MapOptions::default()))
.and_then(|s| {
let idx = s.sources().iter().position(|s| s.eq(&resource))?;
let source = s.sources_content().get(idx)?;
let idx = s.sources().position(|s| s.eq(&resource))?;
let source = s.get_source_content(idx)?;
Some(RsdoctorModuleOriginalSource {
module: *module_ukey,
source: source.to_string(),
Expand Down
Loading