@@ -6,6 +6,7 @@ import type {
66 ServerUserConfig ,
77} from '@modern-js/app-tools' ;
88import type { CLIPluginAPI } from '@modern-js/plugin' ;
9+ import type { Entrypoint } from '@modern-js/types' ;
910import { LOADABLE_STATS_FILE , isUseSSRBundle } from '@modern-js/utils' ;
1011import type { RsbuildPlugin } from '@rsbuild/core' ;
1112import { resolveSSRMode } from './mode' ;
@@ -43,12 +44,32 @@ const hasStringSSREntry = (userConfig: AppToolsNormalizedConfig): boolean => {
4344 return false ;
4445} ;
4546
47+ /**
48+ * Check if any entry uses string SSR mode.
49+ * Returns true if at least one entry uses 'string' SSR mode.
50+ */
4651const checkUseStringSSR = (
4752 config : AppToolsNormalizedConfig ,
4853 appDirectory ?: string ,
54+ entrypoints ?: Entrypoint [ ] ,
4955) : boolean => {
50- const ssrMode = resolveSSRMode ( { config, appDirectory } ) ;
51- return ssrMode === 'string' ;
56+ // If entrypoints are provided, check each entry
57+ if ( entrypoints && entrypoints . length > 0 ) {
58+ for ( const entrypoint of entrypoints ) {
59+ const ssrMode = resolveSSRMode ( {
60+ entry : entrypoint . entryName ,
61+ config,
62+ appDirectory,
63+ nestedRoutesEntry : entrypoint . nestedRoutesEntry ,
64+ } ) ;
65+ if ( ssrMode === 'string' ) {
66+ return true ;
67+ }
68+ }
69+ return false ;
70+ }
71+
72+ return true ;
5273} ;
5374
5475const ssrBuilderPlugin = (
@@ -70,12 +91,12 @@ const ssrBuilderPlugin = (
7091 : 'node' ;
7192
7293 const appContext = modernAPI . getAppContext ( ) ;
73- const { appDirectory } = appContext ;
94+ const { appDirectory, entrypoints } = appContext ;
7495
7596 const useLoadablePlugin =
7697 isUseSSRBundle ( userConfig ) &&
7798 ! isServerEnvironment &&
78- checkUseStringSSR ( userConfig , appDirectory ) ;
99+ checkUseStringSSR ( userConfig , appDirectory , entrypoints ) ;
79100
80101 return mergeEnvironmentConfig ( config , {
81102 source : {
0 commit comments