fix client-only alias in SSRed client components (#57484)

### What?

client-only is allows in SSR, server-only should error



Closes WEB-1883
This commit is contained in:
Tobias Koppers 2023-10-26 00:13:59 -07:00 committed by GitHub
parent 581b1be064
commit 9d8dbfa337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -573,7 +573,6 @@ async fn insert_next_server_special_aliases(
// TODO: should include `ServerContextType::PagesApi` routes, but that type doesn't exist.
ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. }
| ServerContextType::AppSSR { .. }
| ServerContextType::Middleware => {
insert_exact_alias_map(
import_map,
@ -586,6 +585,18 @@ async fn insert_next_server_special_aliases(
},
);
}
ServerContextType::AppSSR { .. } => {
insert_exact_alias_map(
import_map,
project_path,
indexmap! {
"server-only" => "next/dist/compiled/server-only/index".to_string(),
"client-only" => "next/dist/compiled/client-only/index".to_string(),
"next/dist/compiled/server-only" => "next/dist/compiled/server-only/index".to_string(),
"next/dist/compiled/client-only" => "next/dist/compiled/client-only/index".to_string(),
},
);
}
}
// Potential the bundle introduced into middleware and api can be poisoned by