Skip to content

Commit

Permalink
Turbopack: use file:// uris for server resources in development
Browse files Browse the repository at this point in the history
Follows up from #71489, extending this to sourcemaps for server bundles.

Test Plan:

- [ ] CI
- [x] https://github.com/vercel/next.js/blob/61dbe6fb00885068e7ae89ed397e2112076a4577/test/development/app-dir/source-mapping/README.md
  • Loading branch information
wbinnssmith committed Oct 28, 2024
1 parent d27500c commit ea95183
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ pub async fn get_server_chunking_context_with_client_assets(
)
.asset_prefix(asset_prefix)
.minify_type(next_mode.minify_type())
.use_file_source_map_uris()
.module_id_strategy(module_id_strategy)
.build())
}
Expand Down Expand Up @@ -956,5 +957,6 @@ pub async fn get_server_chunking_context(
)
.minify_type(next_mode.minify_type())
.module_id_strategy(module_id_strategy)
.use_file_source_map_uris()
.build())
}
10 changes: 9 additions & 1 deletion turbopack/crates/turbopack-nodejs/src/chunking_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ impl NodeJsChunkingContextBuilder {
self
}

pub fn use_file_source_map_uris(mut self) -> Self {
self.chunking_context.should_use_file_source_map_uris = true;
self
}

pub fn module_id_strategy(mut self, module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>) -> Self {
self.chunking_context.module_id_strategy = module_id_strategy;
self
Expand Down Expand Up @@ -92,6 +97,8 @@ pub struct NodeJsChunkingContext {
manifest_chunks: bool,
/// The strategy to use for generating module ids
module_id_strategy: Vc<Box<dyn ModuleIdStrategy>>,
/// Whether to use file:// uris for source map sources
should_use_file_source_map_uris: bool,
}

impl NodeJsChunkingContext {
Expand All @@ -117,6 +124,7 @@ impl NodeJsChunkingContext {
runtime_type,
minify_type: MinifyType::NoMinify,
manifest_chunks: false,
should_use_file_source_map_uris: false,
module_id_strategy: Vc::upcast(DevModuleIdStrategy::new()),
},
}
Expand Down Expand Up @@ -233,7 +241,7 @@ impl ChunkingContext for NodeJsChunkingContext {

#[turbo_tasks::function]
fn should_use_file_source_map_uris(&self) -> Vc<bool> {
Vc::cell(false)
Vc::cell(self.should_use_file_source_map_uris)
}

#[turbo_tasks::function]
Expand Down

0 comments on commit ea95183

Please sign in to comment.