11import type { Compiler } from '@rspack/core' ;
2- import { Federated } from '../../utils/federated.js' ;
32import { ModuleFederationPluginV1 } from '../ModuleFederationPluginV1.js' ;
43
54const mockPlugin = jest . fn ( ) . mockImplementation ( ( ) => ( {
@@ -129,8 +128,8 @@ describe('ModuleFederationPlugin', () => {
129128 new ModuleFederationPluginV1 ( {
130129 name : 'test' ,
131130 shared : {
132- react : Federated . SHARED_REACT ,
133- 'react-native' : Federated . SHARED_REACT_NATIVE ,
131+ react : { singleton : true , eager : true } ,
132+ 'react-native' : { singleton : true , eager : true } ,
134133 } ,
135134 } ) . apply ( mockCompiler ) ;
136135
@@ -144,8 +143,8 @@ describe('ModuleFederationPlugin', () => {
144143 name : 'test' ,
145144 reactNativeDeepImports : false ,
146145 shared : {
147- react : Federated . SHARED_REACT ,
148- 'react-native' : Federated . SHARED_REACT_NATIVE ,
146+ react : { singleton : true , eager : true } ,
147+ 'react-native' : { singleton : true , eager : true } ,
149148 } ,
150149 } ) . apply ( mockCompiler ) ;
151150
@@ -158,7 +157,7 @@ describe('ModuleFederationPlugin', () => {
158157 new ModuleFederationPluginV1 ( {
159158 name : 'test' ,
160159 shared : {
161- react : Federated . SHARED_REACT ,
160+ react : { singleton : true , eager : true } ,
162161 } ,
163162 } ) . apply ( mockCompiler ) ;
164163
@@ -182,8 +181,8 @@ describe('ModuleFederationPlugin', () => {
182181 new ModuleFederationPluginV1 ( {
183182 name : 'test' ,
184183 shared : {
185- react : Federated . SHARED_REACT ,
186- 'react-native' : Federated . SHARED_REACT_NATIVE ,
184+ react : { singleton : true , eager : true } ,
185+ 'react-native' : { singleton : true , eager : true } ,
187186 'react-native/' : { singleton : true , eager : true } ,
188187 } ,
189188 } ) . apply ( mockCompiler ) ;
@@ -213,6 +212,21 @@ describe('ModuleFederationPlugin', () => {
213212 expect ( config . shared [ '@react-native/' ] . eager ) . toBe ( false ) ;
214213 } ) ;
215214
215+ it ( 'should propagate import=false to deep react-native imports' , ( ) => {
216+ new ModuleFederationPluginV1 ( {
217+ name : 'test' ,
218+ shared : {
219+ 'react-native' : { singleton : true , eager : false , import : false } ,
220+ } ,
221+ } ) . apply ( mockCompiler ) ;
222+
223+ const config = mockPlugin . mock . calls [ 0 ] [ 0 ] ;
224+ expect ( config . shared ) . toHaveProperty ( 'react-native/' ) ;
225+ expect ( config . shared ) . toHaveProperty ( '@react-native/' ) ;
226+ expect ( config . shared [ 'react-native/' ] . import ) . toBe ( false ) ;
227+ expect ( config . shared [ '@react-native/' ] . import ) . toBe ( false ) ;
228+ } ) ;
229+
216230 it ( 'should set default federated entry filename' , ( ) => {
217231 new ModuleFederationPluginV1 ( {
218232 name : 'test' ,
0 commit comments