Skip to content

[DX] Replace Metro with Re.Pack + a Rust transform pipeline for native builds #100202

Closed

Description

@melvin-bot

Background

Native iOS/Android bundles are built by Metro, which transforms in JavaScript and minifies with single-threaded terser. We ship ~38MB of minified JS. Every engineer bundles several times a day, and CI bundles on every build.

Problem

When an engineer or CI builds the app for iOS/Android, they wait 88-94s for a cold bundle, 11s for every warm rebuild, and 63s for a cold dev server — several times a day, for every engineer.

Solution

Adopt Re.Pack (Rspack-based). We keep the babel path only for the ~23 packages that require it (Flow-typed RN core, native-component registration) and run everything else through fast Rust tools (OXC/SWC) in parallel. Native and web then share the same React Compiler pipeline.

This also reconsolidates us onto the Rust React Compiler. Today we use the babel React Compiler on iOS/Android and the Rust React Compiler on web, and the two have logical differences. After this change, native runs the same OXC loader web already uses.

Results

Same machine, same day, identical code:

  • Prod bundle, cold: 88-94s → 54s (~1.7x faster)
  • Prod bundle, warm: 11s → 2s (~5.5x faster)
  • Dev server, cold: 63s → 47s (25% faster)
  • Dev server, warm: 8s → 4s (2x faster)
  • Minified JS: 38.1MB → 35.7MB (6.3% smaller)
  • Hermes bytecode: 45.1MB → 46.7MB (3.5% larger; known cause with a contained fix to try, and staging ManualAppStartup telemetry will show whether it matters)

Verified

Clean boots on iOS simulator, Android emulator, and HybridApp. RN DevTools fully functional. Fast Refresh and dev menu at Metro parity.

Trade-offs

  • Re.Pack is a separate bundler, not a fork of Metro, so Metro fixes do not flow into it. When a new RN version ships, things either work as-is or the Re.Pack team adds support. Tracking RN releases is what that team does at Callstack.
  • We could miss a future Metro improvement, though the items people actually ask about (tree shaking, code splitting, faster builds, caching) are already in Re.Pack.
  • Metro is the default, so libraries get tested against it first and we may hit an edge case. Config takes more work. After a brand-new RN release we may wait for a compatible Re.Pack version.
  • Metro stays in the repo and one flag switches back. Our web build already runs on the same engine, so this reduces the number of build systems rather than adding one.

Non-blocking follow-ups

  • Switch the babel step to standard @babel/parser, the parser Metro uses. No perf change expected; it removes a slow-parser edge case for good.
  • File upstream issues: hermes-parser slowness (repro in hand) and Flow support in OXC.
  • Add a small CI check for the babel allowlist. Today, a dependency update that adds a package needing the babel step fails at app launch instead of at build; the check catches it in the PR.

Prior art

A previous attempt at this was tracked in #58311, closed as not planned while blocked on callstack/repack#1153.

Reported in Slack.

Activity

  1. added
    Reviewing
    on Sep 3, 2026
  2. elirangoshen commented on Sep 7, 2026

    @elirangoshen
    Contributor

    Hi, I will be in vacation from tomorrow (08.09) until 15.09
    I will find someone from my team to continue to work on this issue while I'm away

  3. kacper-mikolajczak commented on Sep 8, 2026

    @kacper-mikolajczak
    Contributor

    Hi 👋 I will be filling in for @elirangoshen here. I am resolving merge conflicts and staying in touch with C+. Let me know if you need anything

  4. elirangoshen commented on Sep 21, 2026

    @elirangoshen
    Contributor

    Hi, I also wanted to add another follow up which I mention in the pr as well
    What is your thoughts about it ?

  5. roryabraham commented on Sep 21, 2026

    @roryabraham
    Contributor

    happy to create another follow-up, but frankly the problem described in that comment isn't clear to me.

  6. collectioneur commented on Sep 22, 2026

    @collectioneur
    Contributor

    Hey! On an iOS dev build, opening Create expense via the FAB throws View config not found for component RNCViewPager and shows "page not found". It's a gap in the Re.Pack BABEL_PACKAGES allowlist: packages outside it skip babel codegen, so codegenNativeComponent() runs at runtime and falls back to the legacy path, which has no view config in bridgeless mode.

    Four packages with codegen specs are missing:

    react-native-pager-view
    react-native-gesture-handler
    @rnmapbox/maps
    @ua/react-native-airship
    I scanned the iOS and Android bundles from the dev server: these four have surviving codegenNativeComponent( after adding them the count is zero).

    Anything bundled by Re.Pack is likely affected, so dev builds (npm run ios / npm run android, standalone and HybridApp) and standalone release bundles. HybridApp release still uses Metro, so production should be fine

    Screen.Recording.2026-09-22.at.13.22.09.mov
  7. elirangoshen commented on Sep 22, 2026

    @elirangoshen
    Contributor

    Hey! On an iOS dev build, opening Create expense via the FAB throws View config not found for component RNCViewPager and shows "page not found". It's a gap in the Re.Pack BABEL_PACKAGES allowlist: packages outside it skip babel codegen, so codegenNativeComponent() runs at runtime and falls back to the legacy path, which has no view config in bridgeless mode.

    Four packages with codegen specs are missing:

    react-native-pager-view react-native-gesture-handler @rnmapbox/maps @ua/react-native-airship I scanned the iOS and Android bundles from the dev server: these four have surviving codegenNativeComponent( after adding them the count is zero).

    Anything bundled by Re.Pack is likely affected, so dev builds (npm run ios / npm run android, standalone and HybridApp) and standalone release bundles. HybridApp release still uses Metro, so production should be fine

    Screen.Recording.2026-09-22.at.13.22.09.mov

    Im working on a pr to fix it

  8. elirangoshen commented on Sep 22, 2026

    @elirangoshen
    Contributor

    Hey! On an iOS dev build, opening Create expense via the FAB throws View config not found for component RNCViewPager and shows "page not found". It's a gap in the Re.Pack BABEL_PACKAGES allowlist: packages outside it skip babel codegen, so codegenNativeComponent() runs at runtime and falls back to the legacy path, which has no view config in bridgeless mode.

    Four packages with codegen specs are missing:

    react-native-pager-view react-native-gesture-handler @rnmapbox/maps @ua/react-native-airship I scanned the iOS and Android bundles from the dev server: these four have surviving codegenNativeComponent( after adding them the count is zero).

    Anything bundled by Re.Pack is likely affected, so dev builds (npm run ios / npm run android, standalone and HybridApp) and standalone release bundles. HybridApp release still uses Metro, so production should be fine

    Screen.Recording.2026-09-22.at.13.22.09.mov

    #101878

  9. 65 remaining items

  10. MelvinBot commented on Oct 27, 2026

    @MelvinBot
    Contributor

    Status: The OXC React Compiler consolidation merged today, so native and web now share one React Compiler. The HybridApp release switch to Re.Pack is still the main open item. Removing Metro from standalone builds is still a draft.

    Since the last update (Oct 20)

    Next steps

    1. elirangoshen: land the reopened HybridApp Re.Pack switch PR, then watch staging for Android/iOS blockers. I can't see that PR, so I can't confirm its status.
    2. elirangoshen: move [DX] Remove Metro from standalone native builds out of draft. It hasn't changed since Oct 15. A second PR will remove Metro from HybridApp builds.
    3. elirangoshen: close or update the OXC compiler tracking issue now that its PR has merged.
    4. Unassigned: the three follow-ups in the issue body are still open. They are: switch to @babel/parser, file upstream issues, and add a CI check for the babel allowlist.

    view run

  11. elirangoshen commented on Oct 28, 2026

    @elirangoshen
    Contributor

    Ill prepare the draft or of removing metro next

  12. shubham1206agra commented on Oct 28, 2026

    @shubham1206agra
    Contributor

    @elirangoshen Something weird is going on with Re.pack. When I try to terminate the process with Ctrl+C, it does not work for some reason. I am not sure what is the issue there.

  13. elirangoshen commented on Oct 30, 2026

    @elirangoshen
    Contributor

    Update: the consolidate pr has been merged , and also the remove metro from standalone builds.
    There's an issue that in some scenarios its not possible to stop the repack terminal in ctrl + c - an issue has been filled to upstream and I will check if we should patch it until it will be solved.

    next task is to open pr for remove the metro leftovers from the submodule.

  14. melvin-bot commented on Nov 2, 2026

    @melvin-bot
    Author

    @elirangoshen, @roryabraham, @shubham1206agra, @kacper-mikolajczak Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. roryabraham commented on Nov 3, 2026

    @roryabraham
    Contributor

    Awaiting PR to remove Metro leftovers from Mobile-Expensify

  16. melvin-bot commented on Nov 3, 2026

    @melvin-bot
    Author

    @elirangoshen, @roryabraham, @shubham1206agra, @kacper-mikolajczak Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  17. elirangoshen commented on Nov 3, 2026

    @elirangoshen
    Contributor

    26. Awaiting PR to remove Metro leftovers from Mobile-Expensify

    The pr has been merged https://github.com/Expensify/Mobile-Expensify/pull/14213#issuecomment-6584926494

  18. roryabraham commented on Nov 3, 2026

    @roryabraham
    Contributor

    @MelvinBot status update

  19. MelvinBot commented on Nov 3, 2026

    @MelvinBot
    Contributor

    Status: The migration’s implementation appears complete; rollout confirmation remains.

    Next: Confirm the Mobile-Expensify changes reached staging/production, complete regression checks, and settle the C+ checklist/payment before closing. The issue-body follow-ups remain unchecked but explicitly non-blocking.

  20. roryabraham commented on Nov 3, 2026

    @roryabraham
    Contributor

    @MelvinBot create an updated payment summary

  21. MelvinBot commented on Nov 3, 2026

    @MelvinBot
    Contributor

    Updated Payment Summary

    • Contributor+: shubham1206agra — $175 via NewDot, unchanged from the confirmed summary.
    • Contributors: elirangoshen and kacper-mikolajczak — no separate payment required (contractors).
    • Total recorded: $175. No payment confirmation or additional approved amounts appear in this thread.

    Resolving PRs: Native Re.Pack pipeline, codegen allowlist, and Android release assets.

    Payment owner: mallenexpensify; confirm eligibility and any existing payout before processing to avoid duplicate payment.

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

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions