From d9ebb6121624c3f8c1cc1a223251ee4b37265fd8 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 18 Mar 2024 13:03:02 +0000 Subject: [PATCH] add react-server condition to middleware, and apis --- .../crates/next-core/src/next_server/context.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/next-swc/crates/next-core/src/next_server/context.rs b/packages/next-swc/crates/next-core/src/next_server/context.rs index c5ffcf80b333e..1c1bc5f00b7f8 100644 --- a/packages/next-swc/crates/next-core/src/next_server/context.rs +++ b/packages/next-swc/crates/next-core/src/next_server/context.rs @@ -161,13 +161,15 @@ pub async fn get_server_resolve_options_context( custom_conditions.extend(ty.conditions().iter().map(ToString::to_string)); match ty { - ServerContextType::AppRSC { .. } => custom_conditions.push("react-server".to_string()), - ServerContextType::AppRoute { .. } - | ServerContextType::Pages { .. } - | ServerContextType::PagesData { .. } + ServerContextType::AppRSC { .. } + | ServerContextType::AppRoute { .. } | ServerContextType::PagesApi { .. } + | ServerContextType::Middleware { .. } => { + custom_conditions.push("react-server".to_string()) + } + ServerContextType::Pages { .. } + | ServerContextType::PagesData { .. } | ServerContextType::AppSSR { .. } - | ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } => {} }; let external_cjs_modules_plugin = ExternalCjsModulesResolvePlugin::new(