Skip to content

feat: support Re.Pack dev server prepare#1145

Merged
thymikee merged 1 commit into
mainfrom
agent/repack-dev-server
Jul 8, 2026
Merged

feat: support Re.Pack dev server prepare#1145
thymikee merged 1 commit into
mainfrom
agent/repack-dev-server

Conversation

@thymikee

@thymikee thymikee commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Support Re.Pack as a first-class metro prepare runtime kind for React Native dev-server workflows.

Share the existing Metro prepare/reload protocol with Re.Pack, including /status, /reload, bundle URL hints, doctor output, remote config, and CLI help. Re.Pack startup now selects react-native rspack-start when rspack.config.* exists and react-native webpack-start when webpack.config.* exists.

Closes #1031

Validation

  • pnpm format
  • pnpm check:quick
  • pnpm exec vitest run src/__tests__/client-metro.test.ts src/__tests__/client-metro-startup-cleanup.test.ts src/commands/metro/index.test.ts src/cli/parser/__tests__ src/utils/__tests__/command-schema-guards.test.ts src/daemon/handlers/__tests__/session-doctor-metro.test.ts
  • pnpm build
  • pnpm test:smoke
  • super-app-showcase/packages/host fake-launch check selected react-native rspack-start
  • pnpm check:unit was attempted; the concurrent run hit unrelated Android emulator/iOS status-bar timing failures, and the failed files passed when rerun in isolation with pnpm exec vitest run src/platforms/android/__tests__/devices.test.ts src/platforms/apple/core/__tests__/index.test.ts

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.6 MB 1.6 MB +1.9 kB
JS gzip 502.9 kB 503.6 kB +691 B
npm tarball 601.5 kB 601.3 kB -150 B
npm unpacked 2.1 MB 2.1 MB -5.1 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.5 ms 27.5 ms -0.1 ms
CLI --help 54.3 ms 54.0 ms -0.3 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/cli-help.js +832 B +307 B
dist/src/client.js +688 B +231 B
dist/src/registry.js +150 B +72 B
dist/src/cli.js -139 B -29 B
dist/src/session.js +100 B +28 B

@thymikee

thymikee commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Review: Re.Pack dev-server prepare support

Nicely scoped — the shared /status + /reload + bundle-URL protocol reuse is the right call, and the terminology sweep from "Metro" → "React Native dev server" is thorough and consistent. The metro prepare path itself (buildMetroCommand, detectRepackBundler, config-file → dependency → rspack fallback) reads correctly and is well tested. One blocking gap and a few minor notes below.

🔴 Blocking: repack is rejected on the deferred/remote-config prepare path

The PR extends the metroKind surface everywhere except one validator. There are two parallel kind validators:

  • src/commands/metro/index.tsreadMetroPrepareKind — ✅ updated to accept repack
  • src/cli/commands/connection-runtime.ts:590readDeferredMetroKind — ❌ still whitelists auto|react-native|expo and throws for repack

This second one is the consumer of exactly the "remote config" support the PR advertises. The flow:

remote-config-schema.ts (metroKind?: MetroPrepareKind, now includes repack) → profile.metroKindconnection.ts:636flags.metroKind = 'repack'connection-runtime.ts:426 readDeferredMetroKind('repack')throws INVALID_ARGS: metro prepare --kind must be auto, react-native, or expo.

Concrete repros, both of which the PR otherwise looks like it enables:

  1. A remote config with metroKind: 'repack' (accepted by the schema; asserted parseable by this PR's own remote-config-public.test.ts) fails the deferred prepare during open.
  2. agent-device open ... --metro-kind repackcli-flags.ts now accepts the enum value, so parsing succeeds, then readDeferredMetroKind throws.

Note the type-level lie: remote-config-schema.ts:13 already types the field as MetroPrepareKind (which now includes repack), so TS believes repack is valid here while the runtime guard rejects it.

Fix: update readDeferredMetroKind to mirror readMetroPrepareKind (add repack + matching message). Better still, have both call a single shared readMetroPrepareKind so this pair can't drift again — that drift is the root cause here. The remote-config-public.test.ts change validates parse/merge only; add a case that exercises the deferred prepare path (or a direct readDeferredMetroKind('repack') assertion) so this stays covered.

Minor

  • resolveMetroPrepareSettings — redundant readPackageJson (client-metro.ts): the else branch reads packageJson when kind === 'repack', then the following if (kind === 'repack') { packageJson ??= readPackageJson(...) } reads it again via ??=. The else-branch read is dead — for non-repack forced kinds packageJson stays null and the ??= block handles repack. Can drop the inner if in the else branch entirely.

  • Shared detector reorder is a two-consumer change (project-runtime.ts): moving the @callstack/repack check before expo also affects the doctor via detectProjectRuntimeKindreadDoctorOptions. An Expo-project-that-also-uses-Re.Pack now reports kind: 'repack' in doctor, not expo. That's probably intended (Re.Pack is the bundler), and shouldProbeMetro still returns true for it, so the probe isn't lost — just calling it out since it's a shared helper with a second caller not visible in this diff.

  • Test coverage for detectRepackBundler: only the config-file branch is covered. The dependency-based branch (@rspack/core / webpack) and the rspack fallback-when-nothing-matches are untested — a table row each would lock in the precedence.

  • Forced --kind repack now requires package.json: readPackageJson throws INVALID_ARGS: package.json not found when absent, whereas forced --kind expo|react-native short-circuit before reading. Fine in practice (Re.Pack needs @callstack/repack in package.json anyway), but the error is generic rather than repack-specific — acceptable, just noting the asymmetry.

Overall: solid feature, ship once readDeferredMetroKind accepts repack (ideally unified with readMetroPrepareKind).

@thymikee thymikee force-pushed the agent/repack-dev-server branch from 1df2ea5 to 32a6c38 Compare July 8, 2026 08:52
@thymikee

thymikee commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Addressed the blocking deferred prepare path issue.

Changes:

  • shared the metro prepare --kind parser between immediate metro prepare and deferred remote/connection prepare
  • added repack coverage on the deferred materialization path
  • removed the redundant readPackageJson branch in Re.Pack prepare settings

Validation:

  • pnpm format
  • pnpm exec vitest run src/__tests__/remote-connection.test.ts src/commands/metro/index.test.ts src/utils/__tests__/command-schema-guards.test.ts src/__tests__/remote-config-public.test.ts
  • pnpm check:quick

@thymikee

thymikee commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Review pass after 32a6c38: no actionable blockers found. Verified the linked #1031 path: repack is accepted in CLI/remote config, deferred remote materialization now uses the shared prepare-kind parser, auto-detection recognizes @callstack/repack, startup selects react-native rspack-start or webpack-start from project config, and the Re.Pack coverage includes local prepare plus deferred remote prepare. CI is green across 21 checks on this head.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 8, 2026
@thymikee thymikee merged commit b0c70ad into main Jul 8, 2026
21 checks passed
@thymikee thymikee deleted the agent/repack-dev-server branch July 8, 2026 09:14
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-08 09:15 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: first-class support for Re.Pack (Rspack) dev server & Module Federation super-apps

1 participant