Skip to content

Commit 76bce6e

Browse files
committed
review feedback
1 parent add88b6 commit 76bce6e

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

crates/next-core/src/next_server/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ pub async fn get_server_chunking_context_with_client_assets(
10611061
builder = builder.source_map_source_type(SourceMapSourceType::AbsoluteFileUri);
10621062
} else {
10631063
builder = builder
1064-
.source_map_source_type(SourceMapSourceType::RelativeFileUri)
1064+
.source_map_source_type(SourceMapSourceType::RelativeUri)
10651065
.chunking_config(
10661066
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
10671067
ChunkingConfig {
@@ -1143,7 +1143,7 @@ pub async fn get_server_chunking_context(
11431143
builder = builder.source_map_source_type(SourceMapSourceType::AbsoluteFileUri);
11441144
} else {
11451145
builder = builder
1146-
.source_map_source_type(SourceMapSourceType::RelativeFileUri)
1146+
.source_map_source_type(SourceMapSourceType::RelativeUri)
11471147
.chunking_config(
11481148
Vc::<EcmascriptChunkType>::default().to_resolved().await?,
11491149
ChunkingConfig {

examples/with-turbopack/next.config.mjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

turbopack/crates/turbopack-core/src/chunk/chunking_context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct ChunkingConfigs(FxHashMap<ResolvedVc<Box<dyn ChunkType>>, ChunkingCon
137137
#[derive(Debug, Clone, Copy, Hash, TaskInput, Default)]
138138
pub enum SourceMapSourceType {
139139
AbsoluteFileUri,
140-
RelativeFileUri,
140+
RelativeUri,
141141
#[default]
142142
TurbopackUriScheme,
143143
}
@@ -549,7 +549,6 @@ async fn relative_path_from_chunk_root_to_project_root(
549549
let output_root_to_chunk_root_path = chunking_context.output_root_to_root_path().await?;
550550

551551
// Note we cannot use `normalize_path` here since it rejects paths that start with `../`
552-
// So this path might
553552
Ok(Vc::cell(
554553
format!(
555554
"{}/{}",

turbopack/crates/turbopack-core/src/source_map/utils.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ fn unencoded_str_to_raw_value(unencoded: &str) -> Box<RawValue> {
229229
/// Helper function to transform turbopack:/// file references in a sourcemap.
230230
/// Handles parsing the sourcemap, resolving the filesystem, applying transformations, and
231231
/// serializing back.
232+
/// The transform function is given the source string as found in the sourcemap (i.e. a URI).
232233
async fn transform_relative_files<F>(
233234
map: Option<&Rope>,
234235
context_path: &FileSystemPath,
@@ -293,15 +294,16 @@ pub async fn relative_fileify_source_map(
293294
context_path: FileSystemPath,
294295
relative_path_to_output_root: RcStr,
295296
) -> Result<Option<Rope>> {
297+
let relative_path_to_output_root = relative_path_to_output_root
298+
.split('/')
299+
.map(|s| urlencoding::encode(s))
300+
.collect::<Vec<_>>()
301+
.join("/");
296302
transform_relative_files(map, &context_path, |_context_fs, src_rest| {
297-
// Uri encode a source root relative path.
298303
// NOTE: we just include the relative path prefix here instead of using `sourceRoot`
299304
// since the spec on sourceRoot is broken.
300-
Ok(format!("{relative_path_to_output_root}/{src_rest}")
301-
.split('/')
302-
.map(|s| urlencoding::encode(s))
303-
.collect::<Vec<_>>()
304-
.join("/"))
305+
// src_rest is already uri encoded as it was part of a sourcemap
306+
Ok(format!("{relative_path_to_output_root}/{src_rest}"))
305307
})
306308
.await
307309
}

turbopack/crates/turbopack-css/src/chunk/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl CssChunk {
108108
)
109109
.await?
110110
}
111-
SourceMapSourceType::RelativeFileUri => {
111+
SourceMapSourceType::RelativeUri => {
112112
relative_fileify_source_map(
113113
content.source_map.as_ref(),
114114
chunking_context.root_path().owned().await?,

turbopack/crates/turbopack-ecmascript/src/chunk/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl EcmascriptChunkItemContent {
8080
SourceMapSourceType::AbsoluteFileUri => {
8181
RewriteSourcePath::AbsoluteFilePath(chunking_context.root_path().owned().await?)
8282
}
83-
SourceMapSourceType::RelativeFileUri => RewriteSourcePath::RelativeFilePath(
83+
SourceMapSourceType::RelativeUri => RewriteSourcePath::RelativeFilePath(
8484
chunking_context.root_path().owned().await?,
8585
chunking_context
8686
.relative_path_from_chunk_root_to_project_root()

turbopack/crates/turbopack-tests/tests/snapshot/debug-ids/node/options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"minifyType": "NoMinify",
55
"environment": "NodeJs",
66
"enableDebugIds": true,
7-
"sourceMapSourceType": "RelativeFileUri"
7+
"sourceMapSourceType": "RelativeUri"
88
}

0 commit comments

Comments
 (0)