Skip to content

Commit f930435

Browse files
feat: add support for edge app pages
1 parent a723ff1 commit f930435

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
@@ -101,14 +101,14 @@ pub async fn get_app_page_entry(
101101
let file = File::from(result.build());
102102
let source = VirtualSource::new(source.ident().path(), AssetContent::file(file.into()));
103103

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

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

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

0 commit comments

Comments
 (0)