Skip to content

Commit 9a24bfb

Browse files
authored
Merge branch 'canary' into shu/ggya
2 parents faa9e99 + 3f25a2e commit 9a24bfb

File tree

5 files changed

+194
-120
lines changed

5 files changed

+194
-120
lines changed

docs/02-app/01-building-your-application/03-rendering/02-client-components.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ There are a couple of benefits to doing the rendering work on the client, includ
1818

1919
To use Client Components, you can add the React [`"use client"` directive](https://react.dev/reference/react/use-client) at the top of a file, above your imports.
2020

21-
`"use client"` is used to declare a [boundary](/docs/app/building-your-application/rendering#network-boundary) between a Server and Client Component modules. This means that by defining a `"use client"` in a file, all other modules imported into it, including child components, are considered part of the client bundle - and will be rendered by React on the client.
21+
`"use client"` is used to declare a [boundary](/docs/app/building-your-application/rendering#network-boundary) between a Server and Client Component modules. This means that by defining a `"use client"` in a file, all other modules imported into it, including child components, are considered part of the client bundle.
2222

2323
```tsx filename="app/counter.tsx" highlight={1} switcher
2424
'use client'

packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use turbopack_binding::{
99
core::{
1010
asset::{Asset, AssetContent},
1111
context::AssetContext,
12+
module::Module,
1213
reference_type::ReferenceType,
1314
source::Source,
1415
virtual_source::VirtualSource,
@@ -101,14 +102,14 @@ pub async fn get_app_page_entry(
101102
let file = File::from(result.build());
102103
let source = VirtualSource::new(source.ident().path(), AssetContent::file(file.into()));
103104

104-
let rsc_entry = context.process(
105+
let mut rsc_entry = context.process(
105106
Vc::upcast(source),
106107
Value::new(ReferenceType::Internal(Vc::cell(inner_assets))),
107108
);
108109

109110
if is_edge {
110-
todo!("edge pages are not supported yet")
111-
}
111+
rsc_entry = wrap_edge_entry(context, project_root, rsc_entry).await?;
112+
};
112113

113114
let Some(rsc_entry) =
114115
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkPlaceable>>(rsc_entry).await?
@@ -124,3 +125,30 @@ pub async fn get_app_page_entry(
124125
}
125126
.cell())
126127
}
128+
129+
async fn wrap_edge_entry(
130+
context: Vc<ModuleAssetContext>,
131+
project_root: Vc<FileSystemPath>,
132+
entry: Vc<Box<dyn Module>>,
133+
) -> Result<Vc<Box<dyn Module>>> {
134+
const INNER: &str = "INNER_RSC_ENTRY";
135+
136+
let source = load_next_js_template(
137+
"edge-app-route.js",
138+
project_root,
139+
indexmap! {
140+
"VAR_USERLAND" => INNER.to_string(),
141+
},
142+
indexmap! {},
143+
)
144+
.await?;
145+
146+
let inner_assets = indexmap! {
147+
INNER.to_string() => entry
148+
};
149+
150+
Ok(context.process(
151+
Vc::upcast(source),
152+
Value::new(ReferenceType::Internal(Vc::cell(inner_assets))),
153+
))
154+
}

0 commit comments

Comments
 (0)