Skip to content

Commit

Permalink
Merge branch 'canary' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
abdonrd committed Dec 13, 2024
2 parents 23e5ed8 + 7a124bc commit d165d02
Show file tree
Hide file tree
Showing 330 changed files with 2,381 additions and 1,050 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue_stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
repo-token: ${{ secrets.STALE_TOKEN }}
any-of-labels: 'please add a complete reproduction'
close-issue-message: 'This issue has been automatically closed due to 2 days of inactivity and the avsence of a complete reproduction. If you believe this was done in error, please leave a comment. If you are experiencing a similar issue, consider opening a new issue with a complete reproduction. Thank you.'
close-issue-message: 'This issue has been automatically closed due to 2 days of inactivity and the absence of a complete reproduction. If you believe this was done in error, please leave a comment. If you are experiencing a similar issue, consider opening a new issue with a complete reproduction. Thank you.'
days-before-issue-close: 1
days-before-issue-stale: 2
days-before-pr-close: -1
Expand Down
2 changes: 1 addition & 1 deletion crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ struct NapiEntrypoints {
pub pages_error_endpoint: External<ExternalEndpoint>,
}

#[turbo_tasks::value(serialization = "none")]
#[turbo_tasks::value(serialization = "none", local)]
struct EntrypointsWithIssues {
entrypoints: ReadRef<Entrypoints>,
issues: Arc<Vec<ReadRef<PlainIssue>>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ enum AppEndpointType {
},
}

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
struct AppEndpoint {
ty: AppEndpointType,
app_project: ResolvedVc<AppProject>,
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
route::{Endpoint, Route},
};

#[turbo_tasks::value(shared)]
#[turbo_tasks::value(shared, local)]
pub struct Entrypoints {
pub routes: FxIndexMap<RcStr, Route>,
pub middleware: Option<Middleware>,
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/module_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<N: TraceRawVcs, E: TraceRawVcs> Deref for TracedDiGraph<N, E> {
}
}

#[turbo_tasks::value(cell = "new", eq = "manual", into = "new")]
#[turbo_tasks::value(cell = "new", eq = "manual", into = "new", local)]
#[derive(Clone, Default)]
pub struct SingleModuleGraph {
graph: TracedDiGraph<SingleModuleGraphNode, ()>,
Expand Down
2 changes: 1 addition & 1 deletion crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub struct Instrumentation {
pub edge: Vc<Box<dyn Endpoint>>,
}

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
pub struct ProjectContainer {
name: RcStr,
options_state: State<Option<ProjectOptions>>,
Expand Down
6 changes: 3 additions & 3 deletions crates/next-api/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl AppPageRoute {
}
}

#[turbo_tasks::value(shared)]
#[turbo_tasks::value(shared, local)]
#[derive(Clone, Debug)]
pub enum Route {
Page {
Expand Down Expand Up @@ -58,7 +58,7 @@ impl Route {
}
}

#[turbo_tasks::value_trait]
#[turbo_tasks::value_trait(local)]
pub trait Endpoint {
fn write_to_disk(self: Vc<Self>) -> Vc<WrittenEndpoint>;
fn server_changed(self: Vc<Self>) -> Vc<Completion>;
Expand All @@ -83,5 +83,5 @@ pub enum WrittenEndpoint {

/// The routes as map from pathname to route. (pathname includes the leading
/// slash)
#[turbo_tasks::value(transparent)]
#[turbo_tasks::value(transparent, local)]
pub struct Routes(FxIndexMap<RcStr, Route>);
6 changes: 3 additions & 3 deletions crates/next-api/src/versioned_content_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use turbopack_core::{
/// An unresolved output assets operation. We need to pass an operation here as
/// it's stored for later usage and we want to reconnect this operation when
/// it's received from the map again.
#[turbo_tasks::value(transparent)]
#[turbo_tasks::value(transparent, local)]
pub struct OutputAssetsOperation(Vc<OutputAssets>);

#[derive(Clone, TraceRawVcs, PartialEq, Eq, ValueDebugFormat, Serialize, Deserialize, Debug)]
Expand All @@ -30,14 +30,14 @@ struct MapEntry {
path_to_asset: HashMap<ResolvedVc<FileSystemPath>, Vc<Box<dyn OutputAsset>>>,
}

#[turbo_tasks::value(transparent)]
#[turbo_tasks::value(transparent, local)]
struct OptionMapEntry(Option<MapEntry>);

type PathToOutputOperation = HashMap<ResolvedVc<FileSystemPath>, FxIndexSet<Vc<OutputAssets>>>;
// A precomputed map for quick access to output asset by filepath
type OutputOperationToComputeEntry = HashMap<Vc<OutputAssets>, Vc<OptionMapEntry>>;

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
pub struct VersionedContentMap {
// TODO: turn into a bi-directional multimap, OutputAssets -> FxIndexSet<FileSystemPath>
map_path_to_op: State<PathToOutputOperation>,
Expand Down
14 changes: 7 additions & 7 deletions crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
};

/// A final route in the app directory.
#[turbo_tasks::value]
#[turbo_tasks::value(local)]
#[derive(Default, Debug, Clone)]
pub struct AppDirModules {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -180,7 +180,7 @@ impl Metadata {
}

/// Metadata files that can be placed in the root of the app directory.
#[turbo_tasks::value]
#[turbo_tasks::value(local)]
#[derive(Default, Clone, Debug)]
pub struct GlobalMetadata {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -202,15 +202,15 @@ impl GlobalMetadata {
}
}

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
#[derive(Debug)]
pub struct DirectoryTree {
/// key is e.g. "dashboard", "(dashboard)", "@slot"
pub subdirectories: BTreeMap<RcStr, ResolvedVc<DirectoryTree>>,
pub modules: AppDirModules,
}

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
#[derive(Clone, Debug)]
struct PlainDirectoryTree {
/// key is e.g. "dashboard", "(dashboard)", "@slot"
Expand Down Expand Up @@ -400,7 +400,7 @@ async fn get_directory_tree_internal(
.cell())
}

#[turbo_tasks::value]
#[turbo_tasks::value(local)]
#[derive(Debug, Clone)]
pub struct AppPageLoaderTree {
pub page: AppPage,
Expand Down Expand Up @@ -523,7 +523,7 @@ impl Entrypoint {
}
}

#[turbo_tasks::value(transparent)]
#[turbo_tasks::value(transparent, local)]
pub struct Entrypoints(FxIndexMap<AppPath, Entrypoint>);

fn is_parallel_route(name: &str) -> bool {
Expand Down Expand Up @@ -1411,7 +1411,7 @@ pub async fn get_global_metadata(
Ok(metadata.cell())
}

#[turbo_tasks::value(shared)]
#[turbo_tasks::value(shared, local)]
struct DirectoryTreeIssue {
pub severity: ResolvedVc<IssueSeverity>,
// no-resolved-vc(kdy1): I'll resolve this later because it's a complex case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Default for ClientReferenceGraphResult {
}
}

#[turbo_tasks::value(shared)]
#[turbo_tasks::value(shared, local)]
pub struct VisitedClientReferenceGraphNodes(HashSet<VisitClientReferenceNode>);

#[turbo_tasks::value_impl]
Expand Down
6 changes: 3 additions & 3 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ pub enum LoaderItem {
LoaderOptions(WebpackLoaderItem),
}

#[turbo_tasks::value(non_local)]
#[turbo_tasks::value]
#[derive(Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub enum ModuleIdStrategy {
Expand All @@ -466,7 +466,7 @@ pub enum MdxRsOptions {
Option(MdxTransformOptions),
}

#[turbo_tasks::value(shared, non_local)]
#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub enum ReactCompilerMode {
Expand All @@ -476,7 +476,7 @@ pub enum ReactCompilerMode {
}

/// Subset of react compiler options
#[turbo_tasks::value(shared, non_local)]
#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ReactCompilerOptions {
Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/next_server/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ pub struct PackagesGlobs {
}

// TODO move that to turbo
#[turbo_tasks::value(transparent)]
#[turbo_tasks::value(transparent, local)]
pub struct OptionPackagesGlobs(Option<PackagesGlobs>);

#[turbo_tasks::function]
Expand Down
39 changes: 34 additions & 5 deletions docs/01-app/01-getting-started/02-project-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ Top-level files are used to configure your application, manage dependencies, run

### Nested routes

| | |
| ---------------------------------------------------------------------------- | -------------------- |
| [`folder`](/docs/app/building-your-application/routing#route-segments) | Route segment |
| [`folder/folder`](/docs/app/building-your-application/routing#nested-routes) | Nested route segment |
| | |
| --------------- | -------------------- |
| `folder` | Route segment |
| `folder/folder` | Nested route segment |

### Dynamic routes

Expand Down Expand Up @@ -168,13 +168,42 @@ Top-level files are used to configure your application, manage dependencies, run

<AppOnly>

## Component hierarchy

The React components defined in special files of a route segment are rendered in a specific hierarchy:

- `layout.js`
- `template.js`
- `error.js` (React error boundary)
- `loading.js` (React suspense boundary)
- `not-found.js` (React error boundary)
- `page.js` or nested `layout.js`

<Image
alt="Component Hierarchy for File Conventions"
srcLight="/docs/light/file-conventions-component-hierarchy.png"
srcDark="/docs/dark/file-conventions-component-hierarchy.png"
width="1600"
height="643"
/>

In a nested route, the components of a segment will be nested **inside** the components of its parent segment.

<Image
alt="Nested File Conventions Component Hierarchy"
srcLight="/docs/light/nested-file-conventions-component-hierarchy.png"
srcDark="/docs/dark/nested-file-conventions-component-hierarchy.png"
width="1600"
height="863"
/>

## Organizing your project

Apart from [folder and file conventions](/docs/app/getting-started/project-structure), Next.js is **unopinionated** about how you organize and colocate your project files. But it does provide several features to help you organize your project.

### Colocation

In the `app` directory, [nested folder hierarchy](/docs/app/building-your-application/routing#route-segments) defines route structure. Each folder represents a route segment that is mapped to a corresponding segment in a URL path.
In the `app` directory, nested folders define route structure. Each folder represents a route segment that is mapped to a corresponding segment in a URL path.

However, even though route structure is defined through folders, a route is **not publicly accessible** until a `page.js` or `route.js` file is added to a route segment.

Expand Down

This file was deleted.

58 changes: 0 additions & 58 deletions docs/01-app/02-building-your-application/01-routing/02-pages.mdx

This file was deleted.

Loading

0 comments on commit d165d02

Please sign in to comment.