Skip to content

Commit

Permalink
Merge branch 'canary' into leerob-patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
samcx authored Nov 22, 2024
2 parents fbccbbc + be82865 commit b2228fc
Show file tree
Hide file tree
Showing 163 changed files with 1,858 additions and 727 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"files": ["packages/**"],
"excludedFiles": [
"packages/next/taskfile*.js",
"packages/next/webpack.config.js"
"packages/next/next-runtime.webpack-config.js"
],
"rules": {
"no-shadow": ["error", { "builtinGlobals": false }],
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ crates/next-custom-transforms/tests/errors/react-server-components/client-graph/
crates/next-custom-transforms/tests/errors/react-server-components/server-graph/fake-client-entry/input.js
crates/next-custom-transforms/tests/errors/server-actions/server-graph/8/input.js
crates/next-custom-transforms/tests/errors/server-actions/server-graph/9/input.js
crates/next-custom-transforms/tests/errors/server-actions/server-graph/18/input.js
crates/next-custom-transforms/tests/fixture/optimize-barrel/normal/4/input.js
crates/next-custom-transforms/tests/fixture/react-server-components/client-graph/client-entry/input.js
crates/next-custom-transforms/tests/fixture/react-server-components/server-graph/client-entry/input.js
Expand Down
2 changes: 1 addition & 1 deletion bench/heavy-npm-deps/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const nextConfig = {
},
experimental: {
turbo: {
unstablePersistentCaching: process.env.TURBO_CACHE ? 1 : false,
unstablePersistentCaching: process.env.TURBO_CACHE ? true : false,
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions crates/next-core/src/app_page_loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ impl AppPageLoaderTreeBuilder {
template,
not_found,
metadata,
forbidden,
unauthorized,
route: _,
} = &modules;

Expand All @@ -343,6 +345,10 @@ impl AppPageLoaderTreeBuilder {
.await?;
self.write_modules_entry(AppDirModuleType::NotFound, *not_found)
.await?;
self.write_modules_entry(AppDirModuleType::Forbidden, *forbidden)
.await?;
self.write_modules_entry(AppDirModuleType::Unauthorized, *unauthorized)
.await?;
self.write_modules_entry(AppDirModuleType::Page, *page)
.await?;
self.write_modules_entry(AppDirModuleType::DefaultPage, *default)
Expand Down
29 changes: 25 additions & 4 deletions crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub struct AppDirModules {
#[serde(skip_serializing_if = "Option::is_none")]
pub template: Option<Vc<FileSystemPath>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub forbidden: Option<Vc<FileSystemPath>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unauthorized: Option<Vc<FileSystemPath>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub not_found: Option<Vc<FileSystemPath>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default: Option<Vc<FileSystemPath>>,
Expand All @@ -62,6 +66,8 @@ impl AppDirModules {
loading: self.loading,
template: self.template,
not_found: self.not_found,
forbidden: self.forbidden,
unauthorized: self.unauthorized,
default: None,
route: None,
metadata: self.metadata.clone(),
Expand Down Expand Up @@ -306,6 +312,8 @@ async fn get_directory_tree_internal(
"global-error" => modules.global_error = Some(file),
"loading" => modules.loading = Some(*file),
"template" => modules.template = Some(*file),
"forbidden" => modules.forbidden = Some(*file),
"unauthorized" => modules.unauthorized = Some(*file),
"not-found" => modules.not_found = Some(*file),
"default" => modules.default = Some(*file),
"route" => modules.route = Some(file),
Expand Down Expand Up @@ -857,10 +865,23 @@ fn directory_tree_to_loader_tree_internal(
// the path).
let is_root_layout = app_path.is_root() && modules.layout.is_some();

if (is_root_directory || is_root_layout) && modules.not_found.is_none() {
modules.not_found = Some(
get_next_package(app_dir).join("dist/client/components/not-found-error.js".into()),
);
if is_root_directory || is_root_layout {
if modules.not_found.is_none() {
modules.not_found = Some(
get_next_package(app_dir).join("dist/client/components/not-found-error.js".into()),
);
}
if modules.forbidden.is_none() {
modules.forbidden = Some(
get_next_package(app_dir).join("dist/client/components/forbidden-error.js".into()),
);
}
if modules.unauthorized.is_none() {
modules.unauthorized = Some(
get_next_package(app_dir)
.join("dist/client/components/unauthorized-error.js".into()),
);
}
}

let mut tree = AppPageLoaderTree {
Expand Down
4 changes: 4 additions & 0 deletions crates/next-core/src/base_loader_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub enum AppDirModuleType {
Loading,
Template,
NotFound,
Forbidden,
Unauthorized,
GlobalError,
}

Expand All @@ -42,6 +44,8 @@ impl AppDirModuleType {
AppDirModuleType::Loading => "loading",
AppDirModuleType::Template => "template",
AppDirModuleType::NotFound => "not-found",
AppDirModuleType::Forbidden => "forbidden",
AppDirModuleType::Unauthorized => "unauthorized",
AppDirModuleType::GlobalError => "global-error",
}
}
Expand Down
Loading

0 comments on commit b2228fc

Please sign in to comment.