Skip to content

Commit ddb9573

Browse files
authored
Merge branch 'main' into fix/correct-tree-shaking
2 parents a69c703 + 1177ec7 commit ddb9573

24 files changed

Lines changed: 369 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+.

.github/workflows/pkg-pr-new.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: pkg.pr.new Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
checks: write
11+
pull-requests: write
12+
issues: write
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
publish-preview:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 30
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v5
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v4
30+
31+
- name: Setup Node.js 20
32+
uses: actions/setup-node@v6
33+
with:
34+
node-version: '20'
35+
cache: 'pnpm'
36+
cache-dependency-path: '**/pnpm-lock.yaml'
37+
38+
- name: Cache Tool Downloads
39+
uses: actions/cache@v5
40+
with:
41+
path: ~/.cache
42+
key: ${{ runner.os }}-toolcache-${{ hashFiles('pnpm-lock.yaml') }}
43+
restore-keys: |
44+
${{ runner.os }}-toolcache-
45+
46+
- name: Remove cached node_modules
47+
run: rm -rf node_modules .nx
48+
49+
- name: Set Nx SHA
50+
uses: nrwl/nx-set-shas@v4
51+
52+
- name: Install dependencies
53+
run: pnpm install --frozen-lockfile
54+
55+
- name: Build package workspace targets
56+
run: |
57+
# Some package dts builds are intermittently flaky in CI; retry once.
58+
npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache || \
59+
(sleep 5 && npx nx run-many --targets=build --projects=tag:type:pkg --skip-nx-cache)
60+
61+
- name: Resolve synced Changesets package paths
62+
id: package_paths
63+
run: |
64+
paths_json=$(node -e '
65+
const fs = require("fs");
66+
const path = require("path");
67+
68+
const config = JSON.parse(fs.readFileSync(".changeset/config.json", "utf8"));
69+
const fixed = new Set((config.fixed || []).flat());
70+
const roots = ["packages", "apps"];
71+
const results = [];
72+
73+
function walk(dir) {
74+
if (!fs.existsSync(dir)) return;
75+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
76+
const fullPath = path.join(dir, entry.name);
77+
if (entry.isDirectory()) {
78+
walk(fullPath);
79+
continue;
80+
}
81+
if (entry.isFile() && entry.name === "package.json") {
82+
const pkgDir = path.dirname(fullPath);
83+
const pkg = JSON.parse(fs.readFileSync(fullPath, "utf8"));
84+
if (fixed.has(pkg.name) && pkg.private !== true) {
85+
results.push(pkgDir);
86+
}
87+
}
88+
}
89+
}
90+
91+
for (const root of roots) {
92+
walk(root);
93+
}
94+
95+
// Deduplicate and sort for stable output.
96+
const sorted = Array.from(new Set(results)).sort();
97+
process.stdout.write(JSON.stringify(sorted));
98+
')
99+
100+
echo "paths_json=$paths_json" >> "$GITHUB_OUTPUT"
101+
102+
- name: Publish pkg.pr.new previews
103+
env:
104+
PKG_PATHS_JSON: ${{ steps.package_paths.outputs.paths_json }}
105+
run: |
106+
# shellcheck disable=SC2016
107+
node -e '
108+
const { spawnSync } = require("child_process");
109+
const paths = JSON.parse(process.env.PKG_PATHS_JSON || "[]");
110+
if (!paths.length) {
111+
console.log("No synced Changesets packages found to publish.");
112+
process.exit(0);
113+
}
114+
const args = [
115+
"dlx",
116+
"pkg-pr-new",
117+
"publish",
118+
"--pnpm",
119+
"--packageManager=pnpm",
120+
"--comment=update",
121+
...paths,
122+
];
123+
const result = spawnSync("pnpm", args, { encoding: "utf8" });
124+
if (result.stdout) process.stdout.write(result.stdout);
125+
if (result.stderr) process.stderr.write(result.stderr);
126+
127+
if (result.status !== 0) {
128+
const combinedOutput = `${result.stdout || ""}\n${result.stderr || ""}`;
129+
if (combinedOutput.includes("https://github.com/apps/pkg-pr-new is not installed")) {
130+
console.log("pkg.pr.new app is not installed on this repository; skipping preview publish.");
131+
process.exit(0);
132+
}
133+
process.exit(result.status || 1);
134+
}
135+
'

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

0 commit comments

Comments
 (0)