Skip to content

fix(turbopack): propagating css source parsing error #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
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
19 changes: 5 additions & 14 deletions turbopack/crates/turbopack-css/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,11 @@ pub async fn finalize_css(
_ => bail!("this case should be filtered out while parsing"),
};

/*
* Ignore origin_source_map when it's not valid, and then fallback to lightningcss
* generated sourcemap in next steps
*/

let origin_source_map = origin_source_map.await?.as_ref().and_then(|rope| {
rope.to_str().ok().and_then(|cow| {
if cow.is_empty() {
None
} else {
parcel_sourcemap::SourceMap::from_json("", &cow).ok()
}
})
});
let origin_source_map = if let Some(rope) = &*origin_source_map.await? {
Some(parcel_sourcemap::SourceMap::from_json("", &rope.to_str()?)?)
} else {
None
};

let (result, srcmap) =
stylesheet.to_css(&code, minify_type, true, true, origin_source_map)?;
Expand Down
Loading