Skip to content

Commit 0f05d1e

Browse files
jbromaJesse Petermanzackarychappleclaude
authored
feat(metro-core): add Metro 0.83 compatibility layer (module-federation#4418)
Co-authored-by: Jesse Peterman <jessejp@amazon.com> Co-authored-by: Zack Chapple <2133184+zackarychapple@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 091e7e6 commit 0f05d1e

23 files changed

Lines changed: 234 additions & 119 deletions

File tree

.changeset/metro-083-compat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@module-federation/metro": patch
3+
---
4+
5+
Add Metro 0.83 compatibility layer. Metro 0.83 introduced a restrictive `exports` field that only allows `metro/private/*` paths instead of direct `metro/src/*` imports. This adds a `metro-compat` utility that dynamically resolves the correct import path, ensuring compatibility with both Metro 0.82 and 0.83+.

apps/metro-example-host/Gemfile.lock

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.7)
5-
base64
6-
nkf
7-
rexml
8-
activesupport (7.2.2.1)
4+
CFPropertyList (3.0.9)
5+
activesupport (7.1.6)
96
base64
107
benchmark (>= 0.3)
118
bigdecimal
12-
concurrent-ruby (~> 1.0, >= 1.3.1)
9+
concurrent-ruby (~> 1.0, >= 1.0.2)
1310
connection_pool (>= 2.2.5)
1411
drb
1512
i18n (>= 1.6, < 2)
1613
logger (>= 1.4.2)
1714
minitest (>= 5.1)
15+
mutex_m
1816
securerandom (>= 0.3)
19-
tzinfo (~> 2.0, >= 2.0.5)
20-
addressable (2.8.7)
21-
public_suffix (>= 2.0.2, < 7.0)
17+
tzinfo (~> 2.0)
18+
addressable (2.8.8)
19+
public_suffix (>= 2.0.2, < 8.0)
2220
algoliasearch (1.27.5)
2321
httpclient (~> 2.8, >= 2.8.3)
2422
json (>= 1.5.1)
2523
atomos (0.1.3)
26-
base64 (0.2.0)
27-
benchmark (0.4.0)
28-
bigdecimal (3.1.9)
24+
base64 (0.3.0)
25+
benchmark (0.5.0)
26+
bigdecimal (4.0.1)
2927
claide (1.1.0)
3028
cocoapods (1.15.2)
3129
addressable (~> 2.8)
@@ -66,34 +64,33 @@ GEM
6664
cocoapods-try (1.2.0)
6765
colored2 (3.1.2)
6866
concurrent-ruby (1.3.3)
69-
connection_pool (2.5.3)
70-
drb (2.2.1)
67+
connection_pool (2.5.5)
68+
drb (2.2.3)
7169
escape (0.0.4)
72-
ethon (0.16.0)
70+
ethon (0.15.0)
7371
ffi (>= 1.15.0)
74-
ffi (1.17.2)
72+
ffi (1.17.3)
7573
fourflusher (2.3.1)
7674
fuzzy_match (2.0.4)
7775
gh_inspector (1.1.3)
7876
httpclient (2.9.0)
7977
mutex_m
80-
i18n (1.14.7)
78+
i18n (1.14.8)
8179
concurrent-ruby (~> 1.0)
82-
json (2.11.3)
80+
json (2.18.1)
8381
logger (1.7.0)
84-
minitest (5.25.5)
82+
minitest (5.26.1)
8583
molinillo (0.8.0)
8684
mutex_m (0.3.0)
8785
nanaimo (0.3.0)
8886
nap (1.1.0)
8987
netrc (0.11.0)
90-
nkf (0.2.0)
9188
public_suffix (4.0.7)
92-
rexml (3.4.1)
89+
rexml (3.4.4)
9390
ruby-macho (2.5.1)
94-
securerandom (0.4.1)
95-
typhoeus (1.4.1)
96-
ethon (>= 0.9.0)
91+
securerandom (0.3.2)
92+
typhoeus (1.5.0)
93+
ethon (>= 0.9.0, < 0.16.0)
9794
tzinfo (2.0.6)
9895
concurrent-ruby (~> 1.0)
9996
xcodeproj (1.25.1)
@@ -118,7 +115,7 @@ DEPENDENCIES
118115
xcodeproj (< 1.26.0)
119116

120117
RUBY VERSION
121-
ruby 3.1.0p0
118+
ruby 2.7.6p219
122119

123120
BUNDLED WITH
124-
2.6.1
121+
2.1.4

apps/metro-example-host/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,11 +2422,11 @@ SPEC CHECKSUMS:
24222422
React-timing: a275a1c2e6112dba17f8f7dd496d439213bbea0d
24232423
React-utils: 449a6e1fd53886510e284e80bdbb1b1c6db29452
24242424
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
2425-
ReactCodegen: a1a6d7288d6a5fc86f109e46149c35d707932702
2425+
ReactCodegen: d308d08c58717331dcf82d0129efa8b73e28a64c
24262426
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
24272427
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2428-
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
2428+
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e
24292429

2430-
PODFILE CHECKSUM: a8134080201cda3c42e54a89f48d0930861e3c58
2430+
PODFILE CHECKSUM: d7ddd7fd39d49e0dd5d1205cb5dc83483092e5fb
24312431

2432-
COCOAPODS: 1.15.2
2432+
COCOAPODS: 1.15.2

apps/metro-example-host/metro.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ const {withModuleFederation} = require('@module-federation/metro');
1111
*/
1212

1313
const config = {
14-
resolver: {useWatchman: false},
14+
resolver: {
15+
extraNodeModules: {
16+
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
17+
},
18+
useWatchman: false,
19+
},
1520
watchFolders: [
1621
path.resolve(__dirname, '../../node_modules'),
17-
path.resolve(__dirname, '../../packages/core'),
22+
path.resolve(__dirname, '../../packages'),
1823
],
1924
};
2025

apps/metro-example-mini/Gemfile.lock

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.7)
5-
base64
6-
nkf
7-
rexml
8-
activesupport (7.2.2.1)
4+
CFPropertyList (3.0.9)
5+
activesupport (7.1.6)
96
base64
107
benchmark (>= 0.3)
118
bigdecimal
12-
concurrent-ruby (~> 1.0, >= 1.3.1)
9+
concurrent-ruby (~> 1.0, >= 1.0.2)
1310
connection_pool (>= 2.2.5)
1411
drb
1512
i18n (>= 1.6, < 2)
1613
logger (>= 1.4.2)
1714
minitest (>= 5.1)
15+
mutex_m
1816
securerandom (>= 0.3)
19-
tzinfo (~> 2.0, >= 2.0.5)
20-
addressable (2.8.7)
21-
public_suffix (>= 2.0.2, < 7.0)
17+
tzinfo (~> 2.0)
18+
addressable (2.8.8)
19+
public_suffix (>= 2.0.2, < 8.0)
2220
algoliasearch (1.27.5)
2321
httpclient (~> 2.8, >= 2.8.3)
2422
json (>= 1.5.1)
2523
atomos (0.1.3)
2624
base64 (0.3.0)
27-
benchmark (0.4.1)
28-
bigdecimal (3.2.2)
25+
benchmark (0.5.0)
26+
bigdecimal (4.0.1)
2927
claide (1.1.0)
3028
cocoapods (1.15.2)
3129
addressable (~> 2.8)
@@ -66,34 +64,33 @@ GEM
6664
cocoapods-try (1.2.0)
6765
colored2 (3.1.2)
6866
concurrent-ruby (1.3.3)
69-
connection_pool (2.5.3)
67+
connection_pool (2.5.5)
7068
drb (2.2.3)
7169
escape (0.0.4)
72-
ethon (0.16.0)
70+
ethon (0.15.0)
7371
ffi (>= 1.15.0)
74-
ffi (1.17.2)
72+
ffi (1.17.3)
7573
fourflusher (2.3.1)
7674
fuzzy_match (2.0.4)
7775
gh_inspector (1.1.3)
7876
httpclient (2.9.0)
7977
mutex_m
80-
i18n (1.14.7)
78+
i18n (1.14.8)
8179
concurrent-ruby (~> 1.0)
82-
json (2.12.2)
80+
json (2.18.1)
8381
logger (1.7.0)
84-
minitest (5.25.5)
82+
minitest (5.26.1)
8583
molinillo (0.8.0)
8684
mutex_m (0.3.0)
8785
nanaimo (0.3.0)
8886
nap (1.1.0)
8987
netrc (0.11.0)
90-
nkf (0.2.0)
9188
public_suffix (4.0.7)
92-
rexml (3.4.2)
89+
rexml (3.4.4)
9390
ruby-macho (2.5.1)
94-
securerandom (0.4.1)
95-
typhoeus (1.4.1)
96-
ethon (>= 0.9.0)
91+
securerandom (0.3.2)
92+
typhoeus (1.5.0)
93+
ethon (>= 0.9.0, < 0.16.0)
9794
tzinfo (2.0.6)
9895
concurrent-ruby (~> 1.0)
9996
xcodeproj (1.25.1)
@@ -118,7 +115,7 @@ DEPENDENCIES
118115
xcodeproj (< 1.26.0)
119116

120117
RUBY VERSION
121-
ruby 3.1.0p0
118+
ruby 2.7.6p219
122119

123120
BUNDLED WITH
124-
2.6.1
121+
2.1.4

apps/metro-example-mini/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,10 +2422,10 @@ SPEC CHECKSUMS:
24222422
React-timing: a275a1c2e6112dba17f8f7dd496d439213bbea0d
24232423
React-utils: 449a6e1fd53886510e284e80bdbb1b1c6db29452
24242424
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
2425-
ReactCodegen: a1a6d7288d6a5fc86f109e46149c35d707932702
2425+
ReactCodegen: d308d08c58717331dcf82d0129efa8b73e28a64c
24262426
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
24272427
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2428-
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
2428+
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e
24292429

24302430
PODFILE CHECKSUM: a8134080201cda3c42e54a89f48d0930861e3c58
24312431

apps/metro-example-mini/metro.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ const {withModuleFederation} = require('@module-federation/metro');
1010
* @type {import('@react-native/metro-config').MetroConfig}
1111
*/
1212
const config = {
13-
resolver: {useWatchman: false},
13+
resolver: {
14+
extraNodeModules: {
15+
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
16+
},
17+
useWatchman: false,
18+
},
1419
watchFolders: [
1520
path.resolve(__dirname, '../../node_modules'),
16-
path.resolve(__dirname, '../../packages/core'),
21+
path.resolve(__dirname, '../../packages'),
1722
],
1823
};
1924

apps/metro-example-nested-mini/Gemfile.lock

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.7)
5-
base64
6-
nkf
7-
rexml
8-
activesupport (7.2.2.1)
4+
CFPropertyList (3.0.9)
5+
activesupport (7.1.6)
96
base64
107
benchmark (>= 0.3)
118
bigdecimal
12-
concurrent-ruby (~> 1.0, >= 1.3.1)
9+
concurrent-ruby (~> 1.0, >= 1.0.2)
1310
connection_pool (>= 2.2.5)
1411
drb
1512
i18n (>= 1.6, < 2)
1613
logger (>= 1.4.2)
1714
minitest (>= 5.1)
15+
mutex_m
1816
securerandom (>= 0.3)
19-
tzinfo (~> 2.0, >= 2.0.5)
20-
addressable (2.8.7)
21-
public_suffix (>= 2.0.2, < 7.0)
17+
tzinfo (~> 2.0)
18+
addressable (2.8.8)
19+
public_suffix (>= 2.0.2, < 8.0)
2220
algoliasearch (1.27.5)
2321
httpclient (~> 2.8, >= 2.8.3)
2422
json (>= 1.5.1)
2523
atomos (0.1.3)
2624
base64 (0.3.0)
27-
benchmark (0.4.1)
28-
bigdecimal (3.2.2)
25+
benchmark (0.5.0)
26+
bigdecimal (4.0.1)
2927
claide (1.1.0)
3028
cocoapods (1.15.2)
3129
addressable (~> 2.8)
@@ -66,34 +64,33 @@ GEM
6664
cocoapods-try (1.2.0)
6765
colored2 (3.1.2)
6866
concurrent-ruby (1.3.3)
69-
connection_pool (2.5.3)
67+
connection_pool (2.5.5)
7068
drb (2.2.3)
7169
escape (0.0.4)
72-
ethon (0.16.0)
70+
ethon (0.15.0)
7371
ffi (>= 1.15.0)
74-
ffi (1.17.2)
72+
ffi (1.17.3)
7573
fourflusher (2.3.1)
7674
fuzzy_match (2.0.4)
7775
gh_inspector (1.1.3)
7876
httpclient (2.9.0)
7977
mutex_m
80-
i18n (1.14.7)
78+
i18n (1.14.8)
8179
concurrent-ruby (~> 1.0)
82-
json (2.12.2)
80+
json (2.18.1)
8381
logger (1.7.0)
84-
minitest (5.25.5)
82+
minitest (5.26.1)
8583
molinillo (0.8.0)
8684
mutex_m (0.3.0)
8785
nanaimo (0.3.0)
8886
nap (1.1.0)
8987
netrc (0.11.0)
90-
nkf (0.2.0)
9188
public_suffix (4.0.7)
92-
rexml (3.4.1)
89+
rexml (3.4.4)
9390
ruby-macho (2.5.1)
94-
securerandom (0.4.1)
95-
typhoeus (1.4.1)
96-
ethon (>= 0.9.0)
91+
securerandom (0.3.2)
92+
typhoeus (1.5.0)
93+
ethon (>= 0.9.0, < 0.16.0)
9794
tzinfo (2.0.6)
9895
concurrent-ruby (~> 1.0)
9996
xcodeproj (1.25.1)
@@ -118,7 +115,7 @@ DEPENDENCIES
118115
xcodeproj (< 1.26.0)
119116

120117
RUBY VERSION
121-
ruby 3.1.0p0
118+
ruby 2.7.6p219
122119

123120
BUNDLED WITH
124-
2.6.1
121+
2.1.4

apps/metro-example-nested-mini/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,10 +2422,10 @@ SPEC CHECKSUMS:
24222422
React-timing: a275a1c2e6112dba17f8f7dd496d439213bbea0d
24232423
React-utils: 449a6e1fd53886510e284e80bdbb1b1c6db29452
24242424
ReactAppDependencyProvider: 3267432b637c9b38e86961b287f784ee1b08dde0
2425-
ReactCodegen: a1a6d7288d6a5fc86f109e46149c35d707932702
2425+
ReactCodegen: d308d08c58717331dcf82d0129efa8b73e28a64c
24262426
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
24272427
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2428-
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
2428+
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e
24292429

24302430
PODFILE CHECKSUM: a8134080201cda3c42e54a89f48d0930861e3c58
24312431

apps/metro-example-nested-mini/metro.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ const {withModuleFederation} = require('@module-federation/metro');
1010
* @type {import('@react-native/metro-config').MetroConfig}
1111
*/
1212
const config = {
13-
resolver: {useWatchman: false},
13+
resolver: {
14+
extraNodeModules: {
15+
'@babel/runtime': path.resolve(__dirname, 'node_modules/@babel/runtime'),
16+
},
17+
useWatchman: false,
18+
},
1419
watchFolders: [
1520
path.resolve(__dirname, '../../node_modules'),
16-
path.resolve(__dirname, '../../packages/core'),
21+
path.resolve(__dirname, '../../packages'),
1722
],
1823
};
1924

0 commit comments

Comments
 (0)