@@ -4,11 +4,28 @@ import { moduleFederationPlugin } from '@module-federation/modern-js-v3';
44
55const remotePort = process . env . RSC_MF_REMOTE_PORT || process . env . PORT || '3008' ;
66const enableRemoteServeSsr = Boolean ( process . env . PORT ) ;
7+ const serverOnlyEmptyPath = path . join (
8+ path . dirname ( require . resolve ( 'server-only' ) ) ,
9+ 'empty.js' ,
10+ ) ;
11+ const reactRuntimeDir = path . dirname ( require . resolve ( 'react' ) ) ;
12+ const reactJsxRuntimeServerPath = path . join (
13+ reactRuntimeDir ,
14+ 'jsx-runtime.react-server.js' ,
15+ ) ;
16+ const reactJsxDevRuntimeServerPath = path . join (
17+ reactRuntimeDir ,
18+ 'jsx-dev-runtime.react-server.js' ,
19+ ) ;
20+ const reactServerDomClientBrowserPath = require . resolve (
21+ 'react-server-dom-rspack/client.browser' ,
22+ ) ;
723
824export default defineConfig ( {
925 server : {
1026 rsc : true ,
1127 ssr : enableRemoteServeSsr ,
28+ port : Number ( remotePort ) ,
1229 } ,
1330 // Keep RSC server entries synchronous for MF+RSC handlers.
1431 source : {
@@ -26,29 +43,29 @@ export default defineConfig({
2643 bundlerChain ( chain ) {
2744 const target = chain . get ( 'target' ) ;
2845 const targets = Array . isArray ( target ) ? target : [ target ] ;
46+ chain . resolve . alias . set (
47+ 'rsc-mf-react-server-dom-client-browser$' ,
48+ reactServerDomClientBrowserPath ,
49+ ) ;
2950 if ( targets . some ( item => String ( item ) . includes ( 'node' ) ) ) {
3051 chain . target ( 'async-node' ) ;
3152 chain . resolve . conditionNames
3253 . clear ( )
33- . add ( 'react-server' )
34- . add ( 'require' )
35- . add ( 'import' )
36- . add ( 'default' ) ;
37- chain . module
38- . rule ( 'rsc-mf-ssr-no-react-server' )
39- . test ( / \. [ c m ] ? [ j t ] s x ? $ / )
40- . issuerLayer ( 'server-side-rendering' )
41- . resolve . conditionNames . clear ( )
4254 . add ( 'require' )
4355 . add ( 'import' )
4456 . add ( 'default' ) ;
57+ chain . resolve . alias
58+ . set ( 'react/jsx-runtime$' , reactJsxRuntimeServerPath )
59+ . set ( 'react/jsx-dev-runtime$' , reactJsxDevRuntimeServerPath )
60+ . set ( 'server-only$' , serverOnlyEmptyPath ) ;
4561 chain . output . publicPath ( `http://127.0.0.1:${ remotePort } /bundles/` ) ;
4662 chain . module
4763 . rule ( 'rsc-mf-remote-components-layer' )
4864 . test ( / s r c [ \\ / ] c o m p o n e n t s [ \\ / ] .* \. [ t j ] s x ? $ / )
4965 . layer ( 'react-server-components' ) ;
5066 } else {
5167 chain . optimization . splitChunks ( false ) ;
68+ chain . output . chunkLoadingGlobal ( 'chunk_rscHost' ) ;
5269 chain . output . publicPath ( `http://127.0.0.1:${ remotePort } /` ) ;
5370 }
5471
0 commit comments