@@ -79,50 +79,6 @@ const injectRuntimePlugins = (
7979 }
8080} ;
8181
82- const replaceRemoteUrl = (
83- mfConfig : moduleFederationPlugin . ModuleFederationPluginOptions ,
84- remoteIpStrategy ?: 'ipv4' | 'inherit' ,
85- ) => {
86- if ( remoteIpStrategy && remoteIpStrategy === 'inherit' ) {
87- return ;
88- }
89- if ( ! mfConfig . remotes ) {
90- return ;
91- }
92- const ipv4 = getIPV4 ( ) ;
93- const handleRemoteObject = (
94- remoteObject : moduleFederationPlugin . RemotesObject ,
95- ) => {
96- Object . keys ( remoteObject ) . forEach ( ( remoteKey ) => {
97- const remote = remoteObject [ remoteKey ] ;
98- // no support array items yet
99- if ( Array . isArray ( remote ) ) {
100- return ;
101- }
102- if ( typeof remote === 'string' && remote . includes ( LOCALHOST ) ) {
103- remoteObject [ remoteKey ] = remote . replace ( LOCALHOST , ipv4 ) ;
104- }
105- if (
106- typeof remote === 'object' &&
107- ! Array . isArray ( remote . external ) &&
108- remote . external . includes ( LOCALHOST )
109- ) {
110- remote . external = remote . external . replace ( LOCALHOST , ipv4 ) ;
111- }
112- } ) ;
113- } ;
114- if ( Array . isArray ( mfConfig . remotes ) ) {
115- mfConfig . remotes . forEach ( ( remoteObject ) => {
116- if ( typeof remoteObject === 'string' ) {
117- return ;
118- }
119- handleRemoteObject ( remoteObject ) ;
120- } ) ;
121- } else if ( typeof mfConfig . remotes !== 'string' ) {
122- handleRemoteObject ( mfConfig . remotes ) ;
123- }
124- } ;
125-
12682const patchDTSConfig = (
12783 mfConfig : moduleFederationPlugin . ModuleFederationPluginOptions ,
12884 isServer : boolean ,
@@ -163,10 +119,7 @@ const patchDTSConfig = (
163119export const patchMFConfig = (
164120 mfConfig : moduleFederationPlugin . ModuleFederationPluginOptions ,
165121 isServer : boolean ,
166- remoteIpStrategy ?: 'ipv4' | 'inherit' ,
167- enableSSR ?: boolean ,
168122) => {
169- replaceRemoteUrl ( mfConfig , remoteIpStrategy ) ;
170123 addDataFetchExposes ( mfConfig . exposes , isServer ) ;
171124
172125 if ( mfConfig . remoteType === undefined ) {
@@ -188,13 +141,6 @@ export const patchMFConfig = (
188141 runtimePlugins ,
189142 ) ;
190143
191- if ( enableSSR && isDev ( ) ) {
192- injectRuntimePlugins (
193- require . resolve ( '@module-federation/modern-js-v3/resolve-entry-ipv4' ) ,
194- runtimePlugins ,
195- ) ;
196- }
197-
198144 if ( isServer ) {
199145 injectRuntimePlugins (
200146 require . resolve ( '@module-federation/node/runtimePlugin' ) ,
@@ -414,12 +360,7 @@ export const moduleFederationConfigPlugin = (
414360 addMyTypes2Ignored ( chain , ! isWeb ? ssrConfig : csrConfig ) ;
415361
416362 const targetMFConfig = ! isWeb ? ssrConfig : csrConfig ;
417- patchMFConfig (
418- targetMFConfig ,
419- ! isWeb ,
420- userConfig . remoteIpStrategy || 'ipv4' ,
421- enableSSR ,
422- ) ;
363+ patchMFConfig ( targetMFConfig , ! isWeb ) ;
423364
424365 patchBundlerConfig ( {
425366 chain,
@@ -444,16 +385,6 @@ export const moduleFederationConfigPlugin = (
444385 }
445386 } ) ;
446387 api . config ( ( ) => {
447- const ipv4 = getIPV4 ( ) ;
448-
449- if ( userConfig . remoteIpStrategy === undefined ) {
450- if ( ! enableSSR ) {
451- userConfig . remoteIpStrategy = 'inherit' ;
452- } else {
453- userConfig . remoteIpStrategy = 'ipv4' ;
454- }
455- }
456-
457388 const devServerConfig = modernjsConfig . tools ?. devServer ;
458389 const corsWarnMsgs = [
459390 'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.' ,
@@ -485,12 +416,7 @@ export const moduleFederationConfigPlugin = (
485416 'Access-Control-Allow-Headers' : '*' ,
486417 }
487418 : undefined ;
488- const defineConfig = {
489- REMOTE_IP_STRATEGY : JSON . stringify ( userConfig . remoteIpStrategy ) ,
490- } ;
491- if ( enableSSR && isDev ( ) ) {
492- defineConfig [ 'FEDERATION_IPV4' ] = JSON . stringify ( ipv4 ) ;
493- }
419+
494420 return {
495421 tools : {
496422 devServer : {
@@ -506,7 +432,6 @@ export const moduleFederationConfigPlugin = (
506432 } ,
507433 } ,
508434 source : {
509- define : defineConfig ,
510435 enableAsyncEntry : modernjsConfig . source ?. enableAsyncEntry ?? true ,
511436 } ,
512437 dev : {
0 commit comments