Skip to content

Commit

Permalink
build: Update swc_core to v0.90.29 (vercel/turborepo#7856)
Browse files Browse the repository at this point in the history
### Description

Update SWC crates.


1. To keep in sync
2. Prepare usage of source map range mappings.
getsentry/rust-sourcemap#77


### Testing Instructions

See next.js counterpart.

#63790

Closes PACK-2861
  • Loading branch information
kdy1 authored Apr 10, 2024
1 parent 4233f19 commit 59c3958
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
29 changes: 16 additions & 13 deletions crates/turbopack-core/src/source_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl TryInto<sourcemap::RawToken> 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,
Expand All @@ -167,6 +168,7 @@ impl TryInto<sourcemap::RawToken> for Token {
src_col: SOURCEMAP_CRATE_NONE_U32,
src_line: SOURCEMAP_CRATE_NONE_U32,
src_id: SOURCEMAP_CRATE_NONE_U32,
is_range: false,
},
})
}
Expand Down Expand Up @@ -240,7 +242,7 @@ impl SourceMap {
#[turbo_tasks::function]
pub fn empty() -> Vc<Self> {
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()
}

Expand Down Expand Up @@ -389,23 +391,23 @@ impl SourceMap {
origin: Vc<FileSystemPath>,
) -> Result<Vc<Self>> {
async fn resolve_source(
source_request: String,
source_content: Option<String>,
source_request: Arc<str>,
source_content: Option<Arc<str>>,
origin: Vc<FileSystemPath>,
) -> Result<(String, String)> {
) -> Result<(Arc<str>, Arc<str>)> {
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<Regex> =
Expand All @@ -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)
},
)
}
Expand All @@ -430,14 +433,14 @@ impl SourceMap {
origin: Vc<FileSystemPath>,
) -> Result<RegularMap> {
let map = &map.0;
let file = map.get_file().map(ToString::to_string);
let file = map.get_file().map(Arc::<str>::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::<str>::from).collect();
let count = map.get_source_count() as usize;
let sources = map.sources().map(ToString::to_string).collect::<Vec<_>>();
let sources = map.sources().map(Arc::<str>::from).collect::<Vec<_>>();
let source_contents = map
.source_contents()
.map(|s| s.map(ToString::to_string))
.map(|s| s.map(Arc::<str>::from))
.collect::<Vec<_>>();
let mut new_sources = Vec::with_capacity(count);
let mut new_source_contents = Vec::with_capacity(count);
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-css/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ impl GenerateSourceMap for ParseCssResultSourceMap {
m.original.map(|v| v.original_column).unwrap_or_default(),
Some(0),
None,
false,
);
}

Expand Down

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

0 comments on commit 59c3958

Please sign in to comment.