@@ -1988,6 +1988,30 @@ export default __rs_descriptor__.from(mapping);
19881988 if ( viteCommand === "build" ) {
19891989 await config_init$ ( ) ;
19901990
1991+ // Register every layout/page/middleware/api/resource source as a
1992+ // Rolldown input. Forces per-route chunks (entry-point semantics)
1993+ // — without this, when react-server is consumed from a
1994+ // node_modules-installed CLI that ships its own pages, the
1995+ // per-package chunk-grouping rule in lib/build/server.mjs folds
1996+ // every route into one aggregate chunk, deadlocking on the
1997+ // codegen's layout-import cycle and stripping per-route entries
1998+ // from manifest.server (so init$()'s collectStylesheets can't
1999+ // reach layout CSS via manifest.imports). Workspace builds were
2000+ // unaffected because their source paths don't contain
2001+ // node_modules — the grouping rule never fires there.
2002+ config . build . rolldownOptions . input ??= { } ;
2003+ for ( const [ kind , list ] of Object . entries ( entry ) ) {
2004+ for ( const e of list ) {
2005+ if ( ! e ?. src ) continue ;
2006+ const name =
2007+ `router/${ kind } /` +
2008+ sys
2009+ . normalizePath ( relative ( rootDir , e . src ) )
2010+ . replace ( / \. [ ^ . / ] + $ / , "" ) ;
2011+ config . build . rolldownOptions . input [ name ] ??= e . src ;
2012+ }
2013+ }
2014+
19912015 // Set virtual module content for the client build.
19922016 // The client build doesn't load file-router, so the resources plugin
19932017 // serves these as virtual modules using the shared store.
@@ -2107,7 +2131,8 @@ ${outletExportLines.join("\n")}
21072131 const exportEntry = pathToFileURL (
21082132 join ( cwd , outDir , "static" , `${ hash } .mjs` )
21092133 ) ;
2110- config . build . rollupOptions . input [ `static/${ hash } ` ] = staticSrc ;
2134+ config . build . rolldownOptions . input [ `static/${ hash } ` ] =
2135+ staticSrc ;
21112136 // Streaming loader for *.static.{js,mjs,jsx} files. Mirrors the
21122137 // `config.export` contract: the default export may be an array,
21132138 // a function, an (async) iterable, or an (async) generator
@@ -2746,6 +2771,7 @@ ${lazyMatchersLines.join("\n")}
27462771 ${ errorBoundaries . map ( ( [ src ] , i ) => `import __react_server_router_error_${ i } __ from "${ src } "; errorBoundaryComponents.set("${ src } ", __react_server_router_error_${ i } __);` ) . join ( "\n" ) }
27472772 ${ fallbacks . map ( ( [ src ] , i ) => `import __react_server_router_fallback_${ i } __ from "${ src } "; fallbackComponents.set("${ src } ", __react_server_router_fallback_${ i } __);` ) . join ( "\n" ) }
27482773 ${ loadings . map ( ( [ src ] , i ) => `import __react_server_router_loading_${ i } __ from "${ src } "; loadingComponents.set("${ src } ", __react_server_router_loading_${ i } __);` ) . join ( "\n" ) }
2774+ ${ layouts . map ( ( [ src ] , i ) => `import * as __react_server_router_layout_${ i } _mod__ from "${ src } ";` ) . join ( "\n" ) }
27492775 import * as __react_server_page__ from "${ src } ";
27502776 ${ clientSiblings . map ( ( [ sibSrc ] , i ) => `import __client_page_${ i } __ from "${ sibSrc } ";` ) . join ( "\n " ) }
27512777 ${ routeResources . map ( ( [ resourceSrc ] , i ) => `import __resource_${ i } __ from "${ resourceSrc } ";` ) . join ( "\n " ) }
@@ -2768,8 +2794,8 @@ ${lazyMatchersLines.join("\n")}
27682794 ${ mdxComponents && / \. ( m d | m d x ) / . test ( src ) ? `pageProps.components = typeof MDXComponents === "function" ? MDXComponents() : MDXComponents;` : "" }
27692795 ${ layouts
27702796 . map (
2771- ( [ src ] , i ) =>
2772- `const { default: __react_server_router_layout_${ i } __, ...__react_server_router_layout_props_${ i } __ } = await import(" ${ src } ") ;`
2797+ ( _ , i ) =>
2798+ `const { default: __react_server_router_layout_${ i } __, ...__react_server_router_layout_props_${ i } __ } = __react_server_router_layout_ ${ i } _mod__ ;`
27732799 )
27742800 . join ( "\n" ) }
27752801 ${ layouts
0 commit comments