Unverified Commit 8cc9630d authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

fix app routes (#54701)

### What?

fix app routes again after adding app pages

### Why?

### How?


Closes WEB-1469
parent 952c536a
...@@ -471,12 +471,14 @@ impl AppEndpoint { ...@@ -471,12 +471,14 @@ impl AppEndpoint {
async fn output(self: Vc<Self>) -> Result<Vc<AppEndpointOutput>> { async fn output(self: Vc<Self>) -> Result<Vc<AppEndpointOutput>> {
let this = self.await?; let this = self.await?;
let app_entry = match this.ty { let (app_entry, ty) = match this.ty {
AppEndpointType::Page { ty: _, loader_tree } => self.app_page_entry(loader_tree), AppEndpointType::Page { ty: _, loader_tree } => {
(self.app_page_entry(loader_tree), "page")
}
// NOTE(alexkirsz) For routes, technically, a lot of the following code is not needed, // NOTE(alexkirsz) For routes, technically, a lot of the following code is not needed,
// as we know we won't have any client references. However, for now, for simplicity's // as we know we won't have any client references. However, for now, for simplicity's
// sake, we just do the same thing as for pages. // sake, we just do the same thing as for pages.
AppEndpointType::Route { path } => self.app_route_entry(path), AppEndpointType::Route { path } => (self.app_route_entry(path), "route"),
}; };
let node_root = this.app_project.project().node_root(); let node_root = this.app_project.project().node_root();
...@@ -589,7 +591,7 @@ impl AppEndpoint { ...@@ -589,7 +591,7 @@ impl AppEndpoint {
let manifest_path_prefix = get_asset_prefix_from_pathname(&app_entry.pathname); let manifest_path_prefix = get_asset_prefix_from_pathname(&app_entry.pathname);
let app_build_manifest_output = Vc::upcast(VirtualOutputAsset::new( let app_build_manifest_output = Vc::upcast(VirtualOutputAsset::new(
node_root.join(format!( node_root.join(format!(
"server/app{manifest_path_prefix}/page/app-build-manifest.json", "server/app{manifest_path_prefix}/{ty}/app-build-manifest.json",
)), )),
AssetContent::file( AssetContent::file(
File::from(serde_json::to_string_pretty(&app_build_manifest)?).into(), File::from(serde_json::to_string_pretty(&app_build_manifest)?).into(),
...@@ -603,7 +605,7 @@ impl AppEndpoint { ...@@ -603,7 +605,7 @@ impl AppEndpoint {
}; };
let build_manifest_output = Vc::upcast(VirtualOutputAsset::new( let build_manifest_output = Vc::upcast(VirtualOutputAsset::new(
node_root.join(format!( node_root.join(format!(
"server/app{manifest_path_prefix}/page/build-manifest.json", "server/app{manifest_path_prefix}/{ty}/build-manifest.json",
)), )),
AssetContent::file(File::from(serde_json::to_string_pretty(&build_manifest)?).into()), AssetContent::file(File::from(serde_json::to_string_pretty(&build_manifest)?).into()),
)); ));
...@@ -622,13 +624,14 @@ impl AppEndpoint { ...@@ -622,13 +624,14 @@ impl AppEndpoint {
fn create_app_paths_manifest( fn create_app_paths_manifest(
node_root: Vc<FileSystemPath>, node_root: Vc<FileSystemPath>,
ty: &'static str,
pathname: &str, pathname: &str,
original_name: &str, original_name: &str,
filename: String, filename: String,
) -> Result<Vc<Box<dyn OutputAsset>>> { ) -> Result<Vc<Box<dyn OutputAsset>>> {
let manifest_path_prefix = get_asset_prefix_from_pathname(pathname); let manifest_path_prefix = get_asset_prefix_from_pathname(pathname);
let path = node_root.join(format!( let path = node_root.join(format!(
"server/app{manifest_path_prefix}/page/app-paths-manifest.json", "server/app{manifest_path_prefix}/{ty}/app-paths-manifest.json",
)); ));
let app_paths_manifest = AppPathsManifest { let app_paths_manifest = AppPathsManifest {
node_server_app_paths: PagesManifest { node_server_app_paths: PagesManifest {
...@@ -720,16 +723,16 @@ impl AppEndpoint { ...@@ -720,16 +723,16 @@ impl AppEndpoint {
..Default::default() ..Default::default()
}; };
let middleware_manifest_v2 = MiddlewaresManifestV2 { let middleware_manifest_v2 = MiddlewaresManifestV2 {
sorted_middleware: vec![app_entry.pathname.clone()], sorted_middleware: vec![app_entry.original_name.clone()],
middleware: Default::default(), middleware: Default::default(),
functions: [(app_entry.pathname.clone(), edge_function_definition)] functions: [(app_entry.original_name.clone(), edge_function_definition)]
.into_iter() .into_iter()
.collect(), .collect(),
}; };
let manifest_path_prefix = get_asset_prefix_from_pathname(&app_entry.pathname); let manifest_path_prefix = get_asset_prefix_from_pathname(&app_entry.pathname);
let middleware_manifest_v2 = Vc::upcast(VirtualOutputAsset::new( let middleware_manifest_v2 = Vc::upcast(VirtualOutputAsset::new(
node_root.join(format!( node_root.join(format!(
"server/app{manifest_path_prefix}/page/middleware-manifest.json", "server/app{manifest_path_prefix}/{ty}/middleware-manifest.json",
)), )),
AssetContent::file( AssetContent::file(
FileContent::Content(File::from(serde_json::to_string_pretty( FileContent::Content(File::from(serde_json::to_string_pretty(
...@@ -743,6 +746,7 @@ impl AppEndpoint { ...@@ -743,6 +746,7 @@ impl AppEndpoint {
// create app paths manifest // create app paths manifest
let app_paths_manifest_output = create_app_paths_manifest( let app_paths_manifest_output = create_app_paths_manifest(
node_root, node_root,
ty,
&app_entry.pathname, &app_entry.pathname,
&app_entry.original_name, &app_entry.original_name,
base_file, base_file,
...@@ -772,6 +776,7 @@ impl AppEndpoint { ...@@ -772,6 +776,7 @@ impl AppEndpoint {
let app_paths_manifest_output = create_app_paths_manifest( let app_paths_manifest_output = create_app_paths_manifest(
node_root, node_root,
ty,
&app_entry.pathname, &app_entry.pathname,
&app_entry.original_name, &app_entry.original_name,
server_path server_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment