Skip to content

Commit 6b82d2f

Browse files
authored
Merge branch 'canary' into patch-3
2 parents e91de03 + 5b97f1f commit 6b82d2f

File tree

169 files changed

+3036
-1547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+3036
-1547
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/bundle-analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/bundle-analyzer-ui",
3-
"version": "16.0.2-canary.16",
3+
"version": "16.0.2-canary.27",
44
"private": true,
55
"scripts": {
66
"build": "cross-env NEXT_TEST_NATIVE_DIR=no next build --no-mangling",

apps/bundle-analyzer/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"**/*.ts",
2828
"**/*.tsx",
2929
".next/types/**/*.ts",
30-
".next/dev/types/**/*.ts"
30+
".next/dev/types/**/*.ts",
31+
"dist/types/**/*.ts",
32+
"dist/dev/types/**/*.ts"
3133
],
3234
"exclude": ["node_modules"]
3335
}

crates/napi/src/next_api/project.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use next_api::{
2121
ProjectOptions, WatchOptions,
2222
},
2323
route::Endpoint,
24+
routes_hashes_manifest::routes_hashes_manifest_asset_if_enabled,
2425
};
2526
use next_core::tracing_presets::{
2627
TRACING_NEXT_OVERVIEW_TARGETS, TRACING_NEXT_TARGETS, TRACING_NEXT_TURBO_TASKS_TARGETS,
@@ -175,6 +176,9 @@ pub struct NapiProjectOptions {
175176
/// debugging/profiling purposes.
176177
pub no_mangling: bool,
177178

179+
/// Whether to write the route hashes manifest.
180+
pub write_routes_hashes_manifest: bool,
181+
178182
/// The version of Node.js that is available/currently running.
179183
pub current_node_js_version: RcStr,
180184
}
@@ -220,6 +224,9 @@ pub struct NapiPartialProjectOptions {
220224
/// The browserslist query to use for targeting browsers.
221225
pub browserslist_query: Option<RcStr>,
222226

227+
/// Whether to write the route hashes manifest.
228+
pub write_routes_hashes_manifest: Option<bool>,
229+
223230
/// When the code is minified, this opts out of the default mangling of
224231
/// local names for variables, functions etc., which can be useful for
225232
/// debugging/profiling purposes.
@@ -277,6 +284,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
277284
preview_props,
278285
browserslist_query,
279286
no_mangling,
287+
write_routes_hashes_manifest,
280288
current_node_js_version,
281289
} = val;
282290
ProjectOptions {
@@ -292,6 +300,7 @@ impl From<NapiProjectOptions> for ProjectOptions {
292300
preview_props: preview_props.into(),
293301
browserslist_query,
294302
no_mangling,
303+
write_routes_hashes_manifest,
295304
current_node_js_version,
296305
}
297306
}
@@ -312,6 +321,7 @@ impl From<NapiPartialProjectOptions> for PartialProjectOptions {
312321
preview_props,
313322
browserslist_query,
314323
no_mangling,
324+
write_routes_hashes_manifest,
315325
} = val;
316326
PartialProjectOptions {
317327
root_path,
@@ -326,6 +336,7 @@ impl From<NapiPartialProjectOptions> for PartialProjectOptions {
326336
preview_props: preview_props.map(|props| props.into()),
327337
browserslist_query,
328338
no_mangling,
339+
write_routes_hashes_manifest,
329340
}
330341
}
331342
}
@@ -1057,12 +1068,15 @@ async fn output_assets_operation(
10571068

10581069
let nft = next_server_nft_assets(project).await?;
10591070

1071+
let routes_hashes_manifest = routes_hashes_manifest_asset_if_enabled(project).await?;
1072+
10601073
whole_app_module_graphs.as_side_effect().await?;
10611074

10621075
Ok(Vc::cell(
10631076
output_assets
10641077
.into_iter()
10651078
.chain(nft.iter().copied())
1079+
.chain(routes_hashes_manifest.iter().copied())
10661080
.collect(),
10671081
))
10681082
}

crates/next-api/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ swc_core = { workspace = true }
2828
tracing = { workspace = true }
2929
turbo-rcstr = { workspace = true }
3030
turbo-tasks = { workspace = true }
31+
turbo-tasks-hash = { workspace = true }
3132
turbo-tasks-env = { workspace = true }
3233
turbo-tasks-fs = { workspace = true }
3334
turbo-unix-path = { workspace = true }
@@ -39,6 +40,7 @@ turbopack-ecmascript = { workspace = true }
3940
turbopack-node = { workspace = true }
4041
turbopack-nodejs = { workspace = true }
4142
turbopack-wasm = { workspace = true }
43+
urlencoding = { workspace = true }
4244

4345
[dev-dependencies]
4446
turbo-tasks-malloc = { workspace = true }

crates/next-api/src/analyze.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::Write;
1+
use std::{borrow::Cow, io::Write};
22

33
use anyhow::Result;
44
use byteorder::{BE, WriteBytesExt};
@@ -23,7 +23,7 @@ use turbopack_core::{
2323
reference::all_assets_from_entries,
2424
};
2525

26-
use crate::route::{Endpoint, ModuleGraphs};
26+
use crate::route::ModuleGraphs;
2727

2828
#[derive(
2929
Default, Clone, Debug, Deserialize, Eq, NonLocalValue, PartialEq, Serialize, TraceRawVcs,
@@ -371,9 +371,16 @@ pub async fn analyze_output_assets(output_assets: Vc<OutputAssets>) -> Result<Vc
371371
let output_file_index = builder.add_output_file(AnalyzeOutputFile { filename });
372372
let chunk_parts = split_output_asset_into_parts(*asset).await?;
373373
for chunk_part in chunk_parts {
374-
let source_index = builder
375-
.ensure_source(chunk_part.source.trim_start_matches(&prefix))
376-
.1;
374+
let decoded_source = urlencoding::decode(&chunk_part.source)?;
375+
let source = if let Some(stripped) = decoded_source.strip_prefix(&prefix) {
376+
Cow::Borrowed(stripped)
377+
} else {
378+
Cow::Owned(format!(
379+
"[project]/{}",
380+
decoded_source.trim_start_matches("../")
381+
))
382+
};
383+
let source_index = builder.ensure_source(&source).1;
377384
let chunk_part_index = builder.add_chunk_part(AnalyzeChunkPart {
378385
source_index,
379386
output_file_index,
@@ -533,13 +540,6 @@ pub async fn analyze_module_graphs(module_graphs: Vc<ModuleGraphs>) -> Result<Vc
533540
Ok(FileContent::Content(File::from(rope)).cell())
534541
}
535542

536-
#[turbo_tasks::function]
537-
pub async fn analyze_endpoint(endpoint: Vc<Box<dyn Endpoint>>) -> Result<Vc<FileContent>> {
538-
Ok(analyze_output_assets(
539-
*endpoint.output().await?.output_assets,
540-
))
541-
}
542-
543543
#[turbo_tasks::value]
544544
pub struct AnalyzeDataOutputAsset {
545545
pub path: FileSystemPath,
@@ -549,10 +549,13 @@ pub struct AnalyzeDataOutputAsset {
549549
#[turbo_tasks::value_impl]
550550
impl AnalyzeDataOutputAsset {
551551
#[turbo_tasks::function]
552-
pub async fn new(path: FileSystemPath, output_assets: Vc<OutputAssets>) -> Result<Vc<Self>> {
552+
pub async fn new(
553+
path: FileSystemPath,
554+
output_assets: ResolvedVc<OutputAssets>,
555+
) -> Result<Vc<Self>> {
553556
Ok(Self {
554557
path,
555-
output_assets: output_assets.to_resolved().await?,
558+
output_assets,
556559
}
557560
.cell())
558561
}

crates/next-api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod pages;
2121
pub mod paths;
2222
pub mod project;
2323
pub mod route;
24+
pub mod routes_hashes_manifest;
2425
mod server_actions;
2526
mod versioned_content_map;
2627
mod webpack_stats;

crates/next-api/src/pages.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,11 @@ impl Endpoint for PageEndpoint {
17131713
async fn module_graphs(self: Vc<Self>) -> Result<Vc<ModuleGraphs>> {
17141714
let client_module_graph = self.client_module_graph().to_resolved().await?;
17151715
let ssr_module_graph = self.ssr_module_graph().to_resolved().await?;
1716-
Ok(Vc::cell(vec![client_module_graph, ssr_module_graph]))
1716+
Ok(Vc::cell(if client_module_graph != ssr_module_graph {
1717+
vec![client_module_graph, ssr_module_graph]
1718+
} else {
1719+
vec![ssr_module_graph]
1720+
}))
17171721
}
17181722
}
17191723

crates/next-api/src/project.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ pub struct ProjectOptions {
189189
/// debugging/profiling purposes.
190190
pub no_mangling: bool,
191191

192+
/// Whether to write the route hashes manifest.
193+
pub write_routes_hashes_manifest: bool,
194+
192195
/// The version of Node.js that is available/currently running.
193196
pub current_node_js_version: RcStr,
194197
}
@@ -237,6 +240,9 @@ pub struct PartialProjectOptions {
237240
/// local names for variables, functions etc., which can be useful for
238241
/// debugging/profiling purposes.
239242
pub no_mangling: Option<bool>,
243+
244+
/// Whether to write the route hashes manifest.
245+
pub write_routes_hashes_manifest: Option<bool>,
240246
}
241247

242248
#[derive(
@@ -357,6 +363,7 @@ impl ProjectContainer {
357363
preview_props,
358364
browserslist_query,
359365
no_mangling,
366+
write_routes_hashes_manifest,
360367
} = options;
361368

362369
let resolved_self = self.to_resolved().await?;
@@ -404,6 +411,9 @@ impl ProjectContainer {
404411
if let Some(no_mangling) = no_mangling {
405412
new_options.no_mangling = no_mangling;
406413
}
414+
if let Some(write_routes_hashes_manifest) = write_routes_hashes_manifest {
415+
new_options.write_routes_hashes_manifest = write_routes_hashes_manifest;
416+
}
407417

408418
// TODO: Handle mode switch, should prevent mode being switched.
409419
let watch = new_options.watch;
@@ -468,6 +478,7 @@ impl ProjectContainer {
468478
let preview_props;
469479
let browserslist_query;
470480
let no_mangling;
481+
let write_routes_hashes_manifest;
471482
let current_node_js_version;
472483
{
473484
let options = self.options_state.get();
@@ -491,6 +502,7 @@ impl ProjectContainer {
491502
preview_props = options.preview_props.clone();
492503
browserslist_query = options.browserslist_query.clone();
493504
no_mangling = options.no_mangling;
505+
write_routes_hashes_manifest = options.write_routes_hashes_manifest;
494506
current_node_js_version = options.current_node_js_version.clone();
495507
}
496508

@@ -516,6 +528,7 @@ impl ProjectContainer {
516528
encryption_key,
517529
preview_props,
518530
no_mangling,
531+
write_routes_hashes_manifest,
519532
current_node_js_version,
520533
}
521534
.cell())
@@ -603,6 +616,9 @@ pub struct Project {
603616
/// debugging/profiling purposes.
604617
no_mangling: bool,
605618

619+
/// Whether to write the route hashes manifest.
620+
write_routes_hashes_manifest: bool,
621+
606622
current_node_js_version: RcStr,
607623
}
608624

@@ -823,6 +839,11 @@ impl Project {
823839
Ok(Vc::cell(self.watch.enable))
824840
}
825841

842+
#[turbo_tasks::function]
843+
pub(super) fn should_write_routes_hashes_manifest(&self) -> Result<Vc<bool>> {
844+
Ok(Vc::cell(self.write_routes_hashes_manifest))
845+
}
846+
826847
#[turbo_tasks::function]
827848
pub(super) async fn per_page_module_graph(&self) -> Result<Vc<bool>> {
828849
Ok(Vc::cell(*self.mode.await? == NextMode::Development))

0 commit comments

Comments
 (0)