diff --git a/crates/turbopack-core/src/source_map/mod.rs b/crates/turbopack-core/src/source_map/mod.rs index c58b8eb9bfa96..db41d7e920a02 100644 --- a/crates/turbopack-core/src/source_map/mod.rs +++ b/crates/turbopack-core/src/source_map/mod.rs @@ -159,6 +159,7 @@ impl TryInto for Token { src_col: t.original_column as u32, src_line: t.original_line as u32, src_id: t.original_file.parse()?, + is_range: false, }, Self::Synthetic(t) => sourcemap::RawToken { dst_col: t.generated_column as u32, @@ -167,6 +168,7 @@ impl TryInto for Token { src_col: SOURCEMAP_CRATE_NONE_U32, src_line: SOURCEMAP_CRATE_NONE_U32, src_id: SOURCEMAP_CRATE_NONE_U32, + is_range: false, }, }) } @@ -240,7 +242,7 @@ impl SourceMap { #[turbo_tasks::function] pub fn empty() -> Vc { let mut builder = SourceMapBuilder::new(None); - builder.add(0, 0, 0, 0, None, None); + builder.add(0, 0, 0, 0, None, None, false); SourceMap::new_regular(builder.into_sourcemap()).cell() } @@ -389,23 +391,23 @@ impl SourceMap { origin: Vc, ) -> Result> { async fn resolve_source( - source_request: String, - source_content: Option, + source_request: Arc, + source_content: Option>, origin: Vc, - ) -> Result<(String, String)> { + ) -> Result<(Arc, Arc)> { Ok( if let Some(path) = *origin.parent().try_join(source_request.to_string()).await? { let path_str = path.to_string().await?; let source = format!("/{SOURCE_MAP_ROOT_NAME}/{}", path_str); let source_content = if let Some(source_content) = source_content { - source_content.to_string() + source_content } else if let FileContent::Content(file) = &*path.read().await? { let text = file.content().to_str()?; - text.to_string() + text.to_string().into() } else { - format!("unable to read source {path_str}") + format!("unable to read source {path_str}").into() }; - (source, source_content) + (source.into(), source_content) } else { let origin_str = origin.to_string().await?; static INVALID_REGEX: Lazy = @@ -420,8 +422,9 @@ impl SourceMap { "unable to access {source_request} in {origin_str} (it's leaving the \ filesystem root)" ) + .into() }); - (source, source_content) + (source.into(), source_content) }, ) } @@ -430,14 +433,14 @@ impl SourceMap { origin: Vc, ) -> Result { let map = &map.0; - let file = map.get_file().map(ToString::to_string); + let file = map.get_file().map(Arc::::from); let tokens = map.tokens().map(|t| t.get_raw_token()).collect(); - let names = map.names().map(ToString::to_string).collect(); + let names = map.names().map(Arc::::from).collect(); let count = map.get_source_count() as usize; - let sources = map.sources().map(ToString::to_string).collect::>(); + let sources = map.sources().map(Arc::::from).collect::>(); let source_contents = map .source_contents() - .map(|s| s.map(ToString::to_string)) + .map(|s| s.map(Arc::::from)) .collect::>(); let mut new_sources = Vec::with_capacity(count); let mut new_source_contents = Vec::with_capacity(count); diff --git a/crates/turbopack-css/src/process.rs b/crates/turbopack-css/src/process.rs index 8c7c849d8ac0d..36ae1987ac699 100644 --- a/crates/turbopack-css/src/process.rs +++ b/crates/turbopack-css/src/process.rs @@ -991,6 +991,7 @@ impl GenerateSourceMap for ParseCssResultSourceMap { m.original.map(|v| v.original_column).unwrap_or_default(), Some(0), None, + false, ); } diff --git a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js index 3a669289822d5..1bb656791d4e7 100644 --- a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js +++ b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js @@ -12,7 +12,7 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests ; ; const StyledButton = /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$node_modules$2f40$emotion$2f$styled$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["default"])("button", { - target: "ekkrg800" + target: "ekn3dmj0" })("background:blue;"); function ClassNameButton({ children }) { return /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$node_modules$2f40$emotion$2f$react$2f$jsx$2d$dev$2d$runtime$2e$js__$5b$test$5d$__$28$ecmascript$29$__["jsxDEV"])("button", {