Skip to content

Commit 6386822

Browse files
feat: add support for edge app pages
1 parent 8f9c503 commit 6386822

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ pub async fn get_app_page_entry(
102102
let file = File::from(result.build());
103103
let source = VirtualSource::new(source.ident().path(), AssetContent::file(file.into()));
104104

105-
let rsc_entry = context.process(
105+
let mut rsc_entry = context.process(
106106
Vc::upcast(source),
107107
Value::new(ReferenceType::Internal(Vc::cell(inner_assets))),
108108
);
109109

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

114114
let Some(rsc_entry) =
115115
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkPlaceable>>(rsc_entry).await?
@@ -125,3 +125,30 @@ pub async fn get_app_page_entry(
125125
}
126126
.cell())
127127
}
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)