Skip to content

Commit a421844

Browse files
Merge branch 'canary' into fix/78813-eslint-pnpm-missing-deps
2 parents c0d0431 + 002754d commit a421844

File tree

148 files changed

+3657
-1919
lines changed

Some content is hidden

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

148 files changed

+3657
-1919
lines changed

.github/actions/setup-rust/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ runs:
1919
- name: 'Install LLD (LLVM Linker) for Linux'
2020
if: runner.os == 'Linux'
2121
shell: bash
22-
run: sudo apt-get -y update && sudo apt-get install -y lld
22+
run: |
23+
sudo apt-get -y -o DPkg::Lock::Timeout=60 update
24+
sudo apt-get -o DPkg::Lock::Timeout=60 -y install lld
2325
2426
- name: 'Add cargo problem matchers'
2527
shell: bash

.github/labeler.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,35 @@
55
"examples": ["examples/**"],
66
"Font (next/font)": ["**/*font*"],
77
"tests": ["test/**", "bench/**"],
8-
"Turbopack": ["crates/next-*/**"],
8+
"Turbopack": ["crates/next-*/**", "crates/napi/**", "turbopack/**"],
9+
"Rspack": [
10+
{ "type": "user", "pattern": "9aoy" },
11+
{ "type": "user", "pattern": "ahabhgk" },
12+
{ "type": "user", "pattern": "bvanjoi" },
13+
{ "type": "user", "pattern": "chenjiahan" },
14+
{ "type": "user", "pattern": "CPunisher" },
15+
{ "type": "user", "pattern": "easy1090" },
16+
{ "type": "user", "pattern": "fi3ework" },
17+
{ "type": "user", "pattern": "GiveMe-A-Name" },
18+
{ "type": "user", "pattern": "h-a-n-a" },
19+
{ "type": "user", "pattern": "hardfist" },
20+
{ "type": "user", "pattern": "inottn" },
21+
{ "type": "user", "pattern": "jerrykingxyz" },
22+
{ "type": "user", "pattern": "JSerFeng" },
23+
{ "type": "user", "pattern": "lingyucoder" },
24+
{ "type": "user", "pattern": "nyqykk" },
25+
{ "type": "user", "pattern": "sanyuan0704" },
26+
{ "type": "user", "pattern": "ScriptedAlchemy" },
27+
{ "type": "user", "pattern": "SoonIter" },
28+
{ "type": "user", "pattern": "stormslowly" },
29+
{ "type": "user", "pattern": "SyMind" },
30+
{ "type": "user", "pattern": "Timeless0911" },
31+
{ "type": "user", "pattern": "valorkin" },
32+
{ "type": "user", "pattern": "xc2" },
33+
{ "type": "user", "pattern": "zackarychapple" },
34+
{ "type": "user", "pattern": "zoolsher" },
35+
"packages/next/src/build/**"
36+
],
937
"created-by: Chrome Aurora": [
1038
{ "type": "user", "pattern": "atcastle" },
1139
{ "type": "user", "pattern": "devknoll" },

crates/next-api/src/app.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ impl AppProject {
194194

195195
#[turbo_tasks::function]
196196
fn app_entrypoints(&self) -> Vc<AppEntrypoints> {
197-
get_entrypoints(*self.app_dir, self.project.next_config().page_extensions())
197+
let conf = self.project.next_config();
198+
get_entrypoints(
199+
*self.app_dir,
200+
conf.page_extensions(),
201+
conf.is_global_not_found_enabled(),
202+
)
198203
}
199204

200205
#[turbo_tasks::function]

crates/next-core/src/app_page_loader_tree.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ impl AppPageLoaderTreeBuilder {
335335
default,
336336
error,
337337
global_error,
338+
global_not_found,
338339
layout,
339340
loading,
340341
template,
@@ -375,6 +376,8 @@ impl AppPageLoaderTreeBuilder {
375376
.await?;
376377
self.write_modules_entry(AppDirModuleType::GlobalError, *global_error)
377378
.await?;
379+
self.write_modules_entry(AppDirModuleType::GlobalNotFound, *global_not_found)
380+
.await?;
378381

379382
let modules_code = replace(&mut self.loader_tree_code, temp_loader_tree_code);
380383

@@ -399,6 +402,7 @@ impl AppPageLoaderTreeBuilder {
399402
let loader_tree = &*loader_tree.await?;
400403

401404
let modules = &loader_tree.modules;
405+
// load global-error module
402406
if let Some(global_error) = modules.global_error {
403407
let module = self
404408
.base
@@ -407,6 +411,17 @@ impl AppPageLoaderTreeBuilder {
407411
.await?;
408412
self.base.inner_assets.insert(GLOBAL_ERROR.into(), module);
409413
};
414+
// load global-not-found module
415+
if let Some(global_not_found) = modules.global_not_found {
416+
let module = self
417+
.base
418+
.process_source(Vc::upcast(FileSource::new(*global_not_found)))
419+
.to_resolved()
420+
.await?;
421+
self.base
422+
.inner_assets
423+
.insert(GLOBAL_NOT_FOUND.into(), module);
424+
};
410425

411426
self.walk_tree(loader_tree, true).await?;
412427
Ok(AppPageLoaderTreeModule {
@@ -439,3 +454,4 @@ impl AppPageLoaderTreeModule {
439454
}
440455

441456
pub const GLOBAL_ERROR: &str = "GLOBAL_ERROR_MODULE";
457+
pub const GLOBAL_NOT_FOUND: &str = "GLOBAL_NOT_FOUND_MODULE";

crates/next-core/src/app_structure.rs

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub struct AppDirModules {
3939
#[serde(skip_serializing_if = "Option::is_none")]
4040
pub global_error: Option<ResolvedVc<FileSystemPath>>,
4141
#[serde(skip_serializing_if = "Option::is_none")]
42+
pub global_not_found: Option<ResolvedVc<FileSystemPath>>,
43+
#[serde(skip_serializing_if = "Option::is_none")]
4244
pub loading: Option<ResolvedVc<FileSystemPath>>,
4345
#[serde(skip_serializing_if = "Option::is_none")]
4446
pub template: Option<ResolvedVc<FileSystemPath>>,
@@ -63,6 +65,7 @@ impl AppDirModules {
6365
layout: self.layout,
6466
error: self.error,
6567
global_error: self.global_error,
68+
global_not_found: self.global_not_found,
6669
loading: self.loading,
6770
template: self.template,
6871
not_found: self.not_found,
@@ -322,6 +325,7 @@ async fn get_directory_tree_internal(
322325
"layout" => modules.layout = Some(file),
323326
"error" => modules.error = Some(file),
324327
"global-error" => modules.global_error = Some(file),
328+
"global-not-found" => modules.global_not_found = Some(file),
325329
"loading" => modules.loading = Some(file),
326330
"template" => modules.template = Some(file),
327331
"forbidden" => modules.forbidden = Some(file),
@@ -730,11 +734,13 @@ fn add_app_metadata_route(
730734
pub fn get_entrypoints(
731735
app_dir: Vc<FileSystemPath>,
732736
page_extensions: Vc<Vec<RcStr>>,
737+
is_global_not_found_enabled: Vc<bool>,
733738
) -> Vc<Entrypoints> {
734739
directory_tree_to_entrypoints(
735740
app_dir,
736741
get_directory_tree(app_dir, page_extensions),
737742
get_global_metadata(app_dir, page_extensions),
743+
is_global_not_found_enabled,
738744
Default::default(),
739745
)
740746
}
@@ -744,11 +750,13 @@ fn directory_tree_to_entrypoints(
744750
app_dir: Vc<FileSystemPath>,
745751
directory_tree: Vc<DirectoryTree>,
746752
global_metadata: Vc<GlobalMetadata>,
753+
is_global_not_found_enabled: Vc<bool>,
747754
root_layouts: Vc<FileSystemPathVec>,
748755
) -> Vc<Entrypoints> {
749756
directory_tree_to_entrypoints_internal(
750757
app_dir,
751758
global_metadata,
759+
is_global_not_found_enabled,
752760
"".into(),
753761
directory_tree,
754762
AppPage::new(),
@@ -1124,6 +1132,7 @@ async fn default_route_tree(
11241132
async fn directory_tree_to_entrypoints_internal(
11251133
app_dir: ResolvedVc<FileSystemPath>,
11261134
global_metadata: Vc<GlobalMetadata>,
1135+
is_global_not_found_enabled: Vc<bool>,
11271136
directory_name: RcStr,
11281137
directory_tree: Vc<DirectoryTree>,
11291138
app_page: AppPage,
@@ -1133,6 +1142,7 @@ async fn directory_tree_to_entrypoints_internal(
11331142
directory_tree_to_entrypoints_internal_untraced(
11341143
app_dir,
11351144
global_metadata,
1145+
is_global_not_found_enabled,
11361146
directory_name,
11371147
directory_tree,
11381148
app_page,
@@ -1145,6 +1155,7 @@ async fn directory_tree_to_entrypoints_internal(
11451155
async fn directory_tree_to_entrypoints_internal_untraced(
11461156
app_dir: ResolvedVc<FileSystemPath>,
11471157
global_metadata: Vc<GlobalMetadata>,
1158+
is_global_not_found_enabled: Vc<bool>,
11481159
directory_name: RcStr,
11491160
directory_tree: Vc<DirectoryTree>,
11501161
app_page: AppPage,
@@ -1284,6 +1295,13 @@ async fn directory_tree_to_entrypoints_internal_untraced(
12841295

12851296
// Next.js has this logic in "collect-app-paths", where the root not-found page
12861297
// is considered as its own entry point.
1298+
1299+
// Determine if we enable the global not-found feature.
1300+
let is_global_not_found_enabled = *is_global_not_found_enabled.await?;
1301+
let use_global_not_found =
1302+
is_global_not_found_enabled || modules.global_not_found.is_some();
1303+
1304+
let not_found_root_modules = modules.without_leafs();
12871305
let not_found_tree = AppPageLoaderTree {
12881306
page: app_page.clone(),
12891307
segment: directory_name.clone(),
@@ -1296,24 +1314,54 @@ async fn directory_tree_to_entrypoints_internal_untraced(
12961314
page: app_page.clone(),
12971315
segment: "__PAGE__".into(),
12981316
parallel_routes: FxIndexMap::default(),
1299-
modules: AppDirModules {
1300-
page: match modules.not_found {
1301-
Some(v) => Some(v),
1302-
None => Some(get_next_package(*app_dir)
1303-
.join("dist/client/components/not-found-error.js".into())
1304-
.to_resolved()
1305-
.await?),
1306-
},
1307-
..Default::default()
1317+
modules: if use_global_not_found {
1318+
// if global-not-found.js is present:
1319+
// we use it for the page and no layout, since layout is included in global-not-found.js;
1320+
AppDirModules {
1321+
layout: None,
1322+
page: match modules.global_not_found {
1323+
Some(v) => Some(v),
1324+
None => Some(get_next_package(*app_dir)
1325+
.join("dist/client/components/global-not-found.js".into())
1326+
.to_resolved()
1327+
.await?),
1328+
},
1329+
..Default::default()
1330+
}
1331+
} else {
1332+
// if global-not-found.js is not present:
1333+
// we search if we can compose root layout with the root not-found.js;
1334+
AppDirModules {
1335+
page: match modules.not_found {
1336+
Some(v) => Some(v),
1337+
None => Some(get_next_package(*app_dir)
1338+
.join("dist/client/components/not-found-error.js".into())
1339+
.to_resolved()
1340+
.await?),
1341+
},
1342+
..Default::default()
1343+
}
13081344
},
13091345
global_metadata: global_metadata.to_resolved().await?,
13101346
}
13111347
},
1312-
modules: AppDirModules::default(),
1348+
modules: AppDirModules {
1349+
..Default::default()
1350+
},
13131351
global_metadata: global_metadata.to_resolved().await?,
13141352
},
13151353
},
1316-
modules: modules.without_leafs(),
1354+
modules: AppDirModules {
1355+
// `global-not-found.js` does not need a layout since it's included.
1356+
// Skip it if it's present.
1357+
// Otherwise, we need to compose it with the root layout to compose with not-found.js boundary.
1358+
layout: if use_global_not_found {
1359+
None
1360+
} else {
1361+
modules.layout
1362+
},
1363+
..not_found_root_modules
1364+
},
13171365
global_metadata: global_metadata.to_resolved().await?,
13181366
}
13191367
.resolved_cell();
@@ -1345,6 +1393,7 @@ async fn directory_tree_to_entrypoints_internal_untraced(
13451393
let map = directory_tree_to_entrypoints_internal(
13461394
*app_dir,
13471395
global_metadata,
1396+
is_global_not_found_enabled,
13481397
subdir_name.clone(),
13491398
*subdirectory,
13501399
child_app_page.clone(),

crates/next-core/src/base_loader_tree.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub enum AppDirModuleType {
3232
Forbidden,
3333
Unauthorized,
3434
GlobalError,
35+
GlobalNotFound,
3536
}
3637

3738
impl AppDirModuleType {
@@ -47,6 +48,7 @@ impl AppDirModuleType {
4748
AppDirModuleType::Forbidden => "forbidden",
4849
AppDirModuleType::Unauthorized => "unauthorized",
4950
AppDirModuleType::GlobalError => "global-error",
51+
AppDirModuleType::GlobalNotFound => "global-not-found",
5052
}
5153
}
5254
}

crates/next-core/src/next_config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,8 @@ pub struct ExperimentalConfig {
799799
turbopack_persistent_caching: Option<bool>,
800800
turbopack_source_maps: Option<bool>,
801801
turbopack_tree_shaking: Option<bool>,
802+
// Whether to enable the global-not-found convention
803+
global_not_found: Option<bool>,
802804
}
803805

804806
#[derive(
@@ -1189,6 +1191,11 @@ impl NextConfig {
11891191
Vc::cell(self.page_extensions.clone())
11901192
}
11911193

1194+
#[turbo_tasks::function]
1195+
pub fn is_global_not_found_enabled(&self) -> Vc<bool> {
1196+
Vc::cell(self.experimental.global_not_found.unwrap_or_default())
1197+
}
1198+
11921199
#[turbo_tasks::function]
11931200
pub fn transpile_packages(&self) -> Vc<Vec<RcStr>> {
11941201
Vc::cell(self.transpile_packages.clone().unwrap_or_default())

crates/next-core/src/next_font/font_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl FontFallback {
6060
}
6161

6262
#[turbo_tasks::value(transparent)]
63-
pub(crate) struct FontFallbacks(Vec<ResolvedVc<FontFallback>>);
63+
pub(crate) struct FontFallbacks(pub Vec<ResolvedVc<FontFallback>>);
6464

6565
#[turbo_tasks::value_impl]
6666
impl FontFallbacks {
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
use thiserror::Error;
1+
use std::fmt::Display;
2+
3+
use serde::{Deserialize, Serialize};
24
use turbo_rcstr::RcStr;
5+
use turbo_tasks::{trace::TraceRawVcs, NonLocalValue};
6+
7+
pub(crate) enum FontResult<T> {
8+
Ok(T),
9+
FontFileNotFound(FontFileNotFound),
10+
}
11+
12+
#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, NonLocalValue, TraceRawVcs)]
13+
pub(crate) struct FontFileNotFound(pub RcStr);
314

4-
#[derive(Debug, Error)]
5-
pub enum FontError {
6-
#[error("could not find font file")]
7-
FontFileNotFound(RcStr),
15+
impl Display for FontFileNotFound {
16+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
17+
write!(f, "Font file not found: Can't resolve {}'", self.0)
18+
}
819
}

0 commit comments

Comments
 (0)