Skip to content

Commit 1e6cd16

Browse files
authored
fix: pin emitting RN deep imports shared to RN shared (#1287)
1 parent 2598d36 commit 1e6cd16

File tree

8 files changed

+149
-66
lines changed

8 files changed

+149
-66
lines changed

.changeset/smart-dryers-doubt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@callstack/repack": patch
3+
---
4+
5+
Propagate `import:false` to RN deep imports

apps/tester-app/ios/Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- boost (1.84.0)
3-
- callstack-repack (5.1.3):
3+
- callstack-repack (5.2.0):
44
- boost
55
- DoubleConversion
66
- fast_float
@@ -2371,7 +2371,7 @@ PODS:
23712371
- ReactCommon/turbomodule/core
23722372
- SocketRocket
23732373
- Yoga
2374-
- ReactTestApp-DevSupport (4.4.6):
2374+
- ReactTestApp-DevSupport (4.4.7):
23752375
- React-Core
23762376
- React-jsi
23772377
- ReactTestApp-Resources (1.0.0-dev)
@@ -2749,7 +2749,7 @@ DEPENDENCIES:
27492749
- ReactAppDependencyProvider (from `build/generated/ios`)
27502750
- ReactCodegen (from `build/generated/ios`)
27512751
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
2752-
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host`)"
2752+
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host`)"
27532753
- ReactTestApp-DevSupport (from `../node_modules/react-native-test-app`)
27542754
- ReactTestApp-Resources (from `..`)
27552755
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
@@ -2912,7 +2912,7 @@ EXTERNAL SOURCES:
29122912
ReactCommon:
29132913
:path: "../node_modules/react-native/ReactCommon"
29142914
ReactNativeHost:
2915-
:path: "../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host"
2915+
:path: "../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host"
29162916
ReactTestApp-DevSupport:
29172917
:path: "../node_modules/react-native-test-app"
29182918
ReactTestApp-Resources:
@@ -2930,7 +2930,7 @@ EXTERNAL SOURCES:
29302930

29312931
SPEC CHECKSUMS:
29322932
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2933-
callstack-repack: 5adbb5908a4101ee58ecf9f67dc951bc203edc45
2933+
callstack-repack: 9c91d2c48b139e38919c656474f43ab0494b4c21
29342934
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
29352935
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
29362936
FBLazyVector: a867936a67af0d09c37935a1b900a1a3c795b6d1
@@ -3003,7 +3003,7 @@ SPEC CHECKSUMS:
30033003
ReactCodegen: 5ca1121763559a57a821b2d74a6bab524fa0a06c
30043004
ReactCommon: c235ebd26d63fde9a2dfa72cee9f8294b910fee1
30053005
ReactNativeHost: 6977837691a2084827c650fc23181eebc54ad9e1
3006-
ReactTestApp-DevSupport: 7f041d0226e551d19b818344272ffe901e1ac799
3006+
ReactTestApp-DevSupport: 6994b53b5b81139a8ce63e0776c726c95de079a1
30073007
ReactTestApp-Resources: 8d72c3deef156833760694a288ff334af4d427d7
30083008
RNCAsyncStorage: 302f2fac014fd450046c120567ca364632da682b
30093009
RNReanimated: 6ee65830115a6fb2b175432212cc9f19aab162bb

apps/tester-federation-v2/ios/Podfile.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- boost (1.84.0)
3-
- callstack-repack (5.1.3):
3+
- callstack-repack (5.2.0):
44
- boost
55
- DoubleConversion
66
- fast_float
@@ -1750,7 +1750,7 @@ PODS:
17501750
- React-RCTFBReactNativeSpec
17511751
- ReactCommon/turbomodule/core
17521752
- SocketRocket
1753-
- react-native-safe-area-context (5.5.0):
1753+
- react-native-safe-area-context (5.6.1):
17541754
- boost
17551755
- DoubleConversion
17561756
- fast_float
@@ -1768,8 +1768,8 @@ PODS:
17681768
- React-graphics
17691769
- React-ImageManager
17701770
- React-jsi
1771-
- react-native-safe-area-context/common (= 5.5.0)
1772-
- react-native-safe-area-context/fabric (= 5.5.0)
1771+
- react-native-safe-area-context/common (= 5.6.1)
1772+
- react-native-safe-area-context/fabric (= 5.6.1)
17731773
- React-NativeModulesApple
17741774
- React-RCTFabric
17751775
- React-renderercss
@@ -1780,7 +1780,7 @@ PODS:
17801780
- ReactCommon/turbomodule/core
17811781
- SocketRocket
17821782
- Yoga
1783-
- react-native-safe-area-context/common (5.5.0):
1783+
- react-native-safe-area-context/common (5.6.1):
17841784
- boost
17851785
- DoubleConversion
17861786
- fast_float
@@ -1808,7 +1808,7 @@ PODS:
18081808
- ReactCommon/turbomodule/core
18091809
- SocketRocket
18101810
- Yoga
1811-
- react-native-safe-area-context/fabric (5.5.0):
1811+
- react-native-safe-area-context/fabric (5.6.1):
18121812
- boost
18131813
- DoubleConversion
18141814
- fast_float
@@ -2371,7 +2371,7 @@ PODS:
23712371
- ReactCommon/turbomodule/core
23722372
- SocketRocket
23732373
- Yoga
2374-
- ReactTestApp-DevSupport (4.4.6):
2374+
- ReactTestApp-DevSupport (4.4.7):
23752375
- React-Core
23762376
- React-jsi
23772377
- RNCAsyncStorage (2.2.0):
@@ -2402,7 +2402,7 @@ PODS:
24022402
- ReactCommon/turbomodule/core
24032403
- SocketRocket
24042404
- Yoga
2405-
- RNScreens (4.13.1):
2405+
- RNScreens (4.15.4):
24062406
- boost
24072407
- DoubleConversion
24082408
- fast_float
@@ -2429,10 +2429,10 @@ PODS:
24292429
- ReactCodegen
24302430
- ReactCommon/turbomodule/bridging
24312431
- ReactCommon/turbomodule/core
2432-
- RNScreens/common (= 4.13.1)
2432+
- RNScreens/common (= 4.15.4)
24332433
- SocketRocket
24342434
- Yoga
2435-
- RNScreens/common (4.13.1):
2435+
- RNScreens/common (4.15.4):
24362436
- boost
24372437
- DoubleConversion
24382438
- fast_float
@@ -2541,7 +2541,7 @@ DEPENDENCIES:
25412541
- ReactAppDependencyProvider (from `build/generated/ios`)
25422542
- ReactCodegen (from `build/generated/ios`)
25432543
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
2544-
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host`)"
2544+
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host`)"
25452545
- ReactTestApp-DevSupport (from `../node_modules/react-native-test-app`)
25462546
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
25472547
- RNScreens (from `../node_modules/react-native-screens`)
@@ -2701,7 +2701,7 @@ EXTERNAL SOURCES:
27012701
ReactCommon:
27022702
:path: "../node_modules/react-native/ReactCommon"
27032703
ReactNativeHost:
2704-
:path: "../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host"
2704+
:path: "../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host"
27052705
ReactTestApp-DevSupport:
27062706
:path: "../node_modules/react-native-test-app"
27072707
RNCAsyncStorage:
@@ -2713,7 +2713,7 @@ EXTERNAL SOURCES:
27132713

27142714
SPEC CHECKSUMS:
27152715
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2716-
callstack-repack: 5adbb5908a4101ee58ecf9f67dc951bc203edc45
2716+
callstack-repack: 9c91d2c48b139e38919c656474f43ab0494b4c21
27172717
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
27182718
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
27192719
FBLazyVector: a867936a67af0d09c37935a1b900a1a3c795b6d1
@@ -2754,7 +2754,7 @@ SPEC CHECKSUMS:
27542754
React-logger: 839abfd18a3fbdf88132824de584b226d0c5cbce
27552755
React-Mapbuffer: bd5b1120c9bbaac6203eb288735e239f04e03009
27562756
React-microtasksnativemodule: 10892b00e612d79436022a11e5bc8bdf468a284f
2757-
react-native-safe-area-context: 0ba06165160a8ff54ff0f20eca9bc6717d4df79e
2757+
react-native-safe-area-context: 6d8a7b750e496e37bda47c938320bf2c734d441f
27582758
React-NativeModulesApple: 3f9e97a4a90eeec1ceade511f973b277632650bb
27592759
React-oscompat: 34f3d3c06cadcbc470bc4509c717fb9b919eaa8b
27602760
React-perflogger: 95dff8cc9901777360716cbdcb2998849f133a4f
@@ -2786,12 +2786,12 @@ SPEC CHECKSUMS:
27862786
ReactCodegen: 5ca1121763559a57a821b2d74a6bab524fa0a06c
27872787
ReactCommon: c235ebd26d63fde9a2dfa72cee9f8294b910fee1
27882788
ReactNativeHost: 6977837691a2084827c650fc23181eebc54ad9e1
2789-
ReactTestApp-DevSupport: 7f041d0226e551d19b818344272ffe901e1ac799
2789+
ReactTestApp-DevSupport: 6994b53b5b81139a8ce63e0776c726c95de079a1
27902790
RNCAsyncStorage: 302f2fac014fd450046c120567ca364632da682b
2791-
RNScreens: 02516de412dd908659fdb5a3ed599719238a7502
2791+
RNScreens: 5c7f22b19ee2e900e5de2c578471aeb153d1e502
27922792
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
27932793
SwiftyRSA: 8c6dd1ea7db1b8dc4fb517a202f88bb1354bc2c6
2794-
Yoga: 00013dd9cde63a2d98e8002fcc4f5ddb66c10782
2794+
Yoga: b01392348aeea02064c21a2762a42893d82b60a7
27952795

27962796
PODFILE CHECKSUM: 3d5c18eefbf70d38fbbfe81a262195cadac1f5dd
27972797

apps/tester-federation/ios/Podfile.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- boost (1.84.0)
3-
- callstack-repack (5.1.3):
3+
- callstack-repack (5.2.0):
44
- boost
55
- DoubleConversion
66
- fast_float
@@ -1750,7 +1750,7 @@ PODS:
17501750
- React-RCTFBReactNativeSpec
17511751
- ReactCommon/turbomodule/core
17521752
- SocketRocket
1753-
- react-native-safe-area-context (5.5.0):
1753+
- react-native-safe-area-context (5.6.1):
17541754
- boost
17551755
- DoubleConversion
17561756
- fast_float
@@ -1768,8 +1768,8 @@ PODS:
17681768
- React-graphics
17691769
- React-ImageManager
17701770
- React-jsi
1771-
- react-native-safe-area-context/common (= 5.5.0)
1772-
- react-native-safe-area-context/fabric (= 5.5.0)
1771+
- react-native-safe-area-context/common (= 5.6.1)
1772+
- react-native-safe-area-context/fabric (= 5.6.1)
17731773
- React-NativeModulesApple
17741774
- React-RCTFabric
17751775
- React-renderercss
@@ -1780,7 +1780,7 @@ PODS:
17801780
- ReactCommon/turbomodule/core
17811781
- SocketRocket
17821782
- Yoga
1783-
- react-native-safe-area-context/common (5.5.0):
1783+
- react-native-safe-area-context/common (5.6.1):
17841784
- boost
17851785
- DoubleConversion
17861786
- fast_float
@@ -1808,7 +1808,7 @@ PODS:
18081808
- ReactCommon/turbomodule/core
18091809
- SocketRocket
18101810
- Yoga
1811-
- react-native-safe-area-context/fabric (5.5.0):
1811+
- react-native-safe-area-context/fabric (5.6.1):
18121812
- boost
18131813
- DoubleConversion
18141814
- fast_float
@@ -2371,7 +2371,7 @@ PODS:
23712371
- ReactCommon/turbomodule/core
23722372
- SocketRocket
23732373
- Yoga
2374-
- ReactTestApp-DevSupport (4.4.6):
2374+
- ReactTestApp-DevSupport (4.4.7):
23752375
- React-Core
23762376
- React-jsi
23772377
- RNCAsyncStorage (2.2.0):
@@ -2402,7 +2402,7 @@ PODS:
24022402
- ReactCommon/turbomodule/core
24032403
- SocketRocket
24042404
- Yoga
2405-
- RNScreens (4.13.1):
2405+
- RNScreens (4.15.4):
24062406
- boost
24072407
- DoubleConversion
24082408
- fast_float
@@ -2429,10 +2429,10 @@ PODS:
24292429
- ReactCodegen
24302430
- ReactCommon/turbomodule/bridging
24312431
- ReactCommon/turbomodule/core
2432-
- RNScreens/common (= 4.13.1)
2432+
- RNScreens/common (= 4.15.4)
24332433
- SocketRocket
24342434
- Yoga
2435-
- RNScreens/common (4.13.1):
2435+
- RNScreens/common (4.15.4):
24362436
- boost
24372437
- DoubleConversion
24382438
- fast_float
@@ -2541,7 +2541,7 @@ DEPENDENCIES:
25412541
- ReactAppDependencyProvider (from `build/generated/ios`)
25422542
- ReactCodegen (from `build/generated/ios`)
25432543
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
2544-
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host`)"
2544+
- "ReactNativeHost (from `../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host`)"
25452545
- ReactTestApp-DevSupport (from `../node_modules/react-native-test-app`)
25462546
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
25472547
- RNScreens (from `../node_modules/react-native-screens`)
@@ -2701,7 +2701,7 @@ EXTERNAL SOURCES:
27012701
ReactCommon:
27022702
:path: "../node_modules/react-native/ReactCommon"
27032703
ReactNativeHost:
2704-
:path: "../../../node_modules/.pnpm/[email protected].6_react[email protected]_@[email protected]_@react-native-community+cl_65gbnwg2irc35guz44pwmvvvyy/node_modules/@rnx-kit/react-native-host"
2704+
:path: "../../../node_modules/.pnpm/[email protected].7_react[email protected]_@[email protected]_@react-native-community+cl_rjr6int3jxckduwjexw7sqihnq/node_modules/@rnx-kit/react-native-host"
27052705
ReactTestApp-DevSupport:
27062706
:path: "../node_modules/react-native-test-app"
27072707
RNCAsyncStorage:
@@ -2713,7 +2713,7 @@ EXTERNAL SOURCES:
27132713

27142714
SPEC CHECKSUMS:
27152715
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2716-
callstack-repack: 5adbb5908a4101ee58ecf9f67dc951bc203edc45
2716+
callstack-repack: 9c91d2c48b139e38919c656474f43ab0494b4c21
27172717
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
27182718
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
27192719
FBLazyVector: a867936a67af0d09c37935a1b900a1a3c795b6d1
@@ -2754,7 +2754,7 @@ SPEC CHECKSUMS:
27542754
React-logger: 839abfd18a3fbdf88132824de584b226d0c5cbce
27552755
React-Mapbuffer: bd5b1120c9bbaac6203eb288735e239f04e03009
27562756
React-microtasksnativemodule: 10892b00e612d79436022a11e5bc8bdf468a284f
2757-
react-native-safe-area-context: 0ba06165160a8ff54ff0f20eca9bc6717d4df79e
2757+
react-native-safe-area-context: 6d8a7b750e496e37bda47c938320bf2c734d441f
27582758
React-NativeModulesApple: 3f9e97a4a90eeec1ceade511f973b277632650bb
27592759
React-oscompat: 34f3d3c06cadcbc470bc4509c717fb9b919eaa8b
27602760
React-perflogger: 95dff8cc9901777360716cbdcb2998849f133a4f
@@ -2786,9 +2786,9 @@ SPEC CHECKSUMS:
27862786
ReactCodegen: 5ca1121763559a57a821b2d74a6bab524fa0a06c
27872787
ReactCommon: c235ebd26d63fde9a2dfa72cee9f8294b910fee1
27882788
ReactNativeHost: 6977837691a2084827c650fc23181eebc54ad9e1
2789-
ReactTestApp-DevSupport: 7f041d0226e551d19b818344272ffe901e1ac799
2789+
ReactTestApp-DevSupport: 6994b53b5b81139a8ce63e0776c726c95de079a1
27902790
RNCAsyncStorage: 302f2fac014fd450046c120567ca364632da682b
2791-
RNScreens: 02516de412dd908659fdb5a3ed599719238a7502
2791+
RNScreens: 5c7f22b19ee2e900e5de2c578471aeb153d1e502
27922792
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
27932793
SwiftyRSA: 8c6dd1ea7db1b8dc4fb517a202f88bb1354bc2c6
27942794
Yoga: 00013dd9cde63a2d98e8002fcc4f5ddb66c10782

packages/repack/src/plugins/ModuleFederationPluginV1.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,22 @@ export class ModuleFederationPluginV1 {
183183
shared: SharedDependencies
184184
): SharedDependencies {
185185
const sharedDependencyConfig = (
186-
eager?: boolean,
187-
version?: string | false
188-
) => ({
189-
singleton: true,
190-
eager: eager ?? true,
191-
version: version || '*',
192-
requiredVersion: version || '*',
193-
});
186+
eager: boolean | undefined,
187+
importValue: string | false | undefined,
188+
version: string | false | undefined
189+
) => {
190+
const config: SharedConfig = {
191+
singleton: true,
192+
eager: eager ?? true,
193+
version: version || '*',
194+
requiredVersion: version || '*',
195+
};
196+
// set import to false if it's explicitly set to false
197+
if (importValue === false) {
198+
config.import = false;
199+
}
200+
return config;
201+
};
194202

195203
const findSharedDependency = (
196204
name: string,
@@ -213,6 +221,10 @@ export class ModuleFederationPluginV1 {
213221
typeof sharedReactNative === 'object'
214222
? sharedReactNative.requiredVersion || sharedReactNative.version
215223
: undefined;
224+
const reactNativeImport =
225+
typeof sharedReactNative === 'object'
226+
? sharedReactNative.import
227+
: undefined;
216228

217229
if (!this.deepImports || !sharedReactNative) {
218230
return shared;
@@ -224,6 +236,7 @@ export class ModuleFederationPluginV1 {
224236
adjustedSharedDependencies.push({
225237
'react-native/': sharedDependencyConfig(
226238
reactNativeEager,
239+
reactNativeImport,
227240
reactNativeVersion
228241
),
229242
});
@@ -232,6 +245,7 @@ export class ModuleFederationPluginV1 {
232245
adjustedSharedDependencies.push({
233246
'@react-native/': sharedDependencyConfig(
234247
reactNativeEager,
248+
reactNativeImport,
235249
reactNativeVersion
236250
),
237251
});
@@ -241,12 +255,20 @@ export class ModuleFederationPluginV1 {
241255
const adjustedSharedDependencies = { ...shared };
242256
if (!findSharedDependency('react-native/', shared)) {
243257
Object.assign(adjustedSharedDependencies, {
244-
'react-native/': sharedDependencyConfig(reactNativeEager),
258+
'react-native/': sharedDependencyConfig(
259+
reactNativeEager,
260+
reactNativeImport,
261+
reactNativeVersion
262+
),
245263
});
246264
}
247265
if (!findSharedDependency('@react-native/', shared)) {
248266
Object.assign(adjustedSharedDependencies, {
249-
'@react-native/': sharedDependencyConfig(reactNativeEager),
267+
'@react-native/': sharedDependencyConfig(
268+
reactNativeEager,
269+
reactNativeImport,
270+
reactNativeVersion
271+
),
250272
});
251273
}
252274
return adjustedSharedDependencies;

0 commit comments

Comments
 (0)