Repository navigation
fix: compose Hermes source maps for every chunk - #1516
Conversation
|
Someone is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 6eb39e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dannyhw
left a comment
There was a problem hiding this comment.
Thanks for this! I can confirm the race, on Rspack too. On the super-app-showcase trading app, the current plugin composed source maps for only 36/66 chunks, and this PR composes all 66 (4.53 MB → 3.98 MB).
Nit (non-blocking): compilation.getAssets() also returns assets that weren't written in this compilation. When rebuilding in the same process (e.g. bundle --watch with caching enabled), unchanged chunks are skipped and are still bytecode on disk, so hermesc fails on them. Normal release builds aren't affected. Recording files in assetEmitted and transforming them in afterEmit keeps the old "only files written this build" behaviour:
let emittedAssets = new Map<string, string>();
compiler.hooks.assetEmitted.tap('RepackHermesBytecodePlugin', (file, { outputPath }) => {
emittedAssets.set(file, outputPath);
});
compiler.hooks.afterEmit.tapPromise(
{ name: 'RepackHermesBytecodePlugin', stage: -100 },
async () => {
const assets = emittedAssets;
emittedAssets = new Map();
await Promise.all(
Array.from(assets, async ([file, outputPath]) => {
// …same body as now
})
);
}
);(Rspack doesn't expose webpack's compilation.emittedAssets, hence the Map.) Happy to push this if you'd like.
Sure! I'll take a look at it next Monday if it's ok. |
|
Hi @dannyhw I have pushed a new commit with your suggestions. I used a I have tried changing our patch with these changes and it works correctly, tests pass and also rebuilds work. |
|
looks good thanks! |
Re.Pack 5.4.3-canary-20261104085523 picks up callstack/repack#1516 (HermesBytecodePlugin composes source maps for every chunk). Dependency refresh: - react-native and @react-native/* 0.88.0 -> 0.88.1 - @rspack/core 2.2.9 -> 2.3.1 - @module-federation/enhanced and error-codes 2.9.2 -> 2.9.3 - react-native-safe-area-context 5.10.1 -> 5.11.1 - react-native-screens 4.30.0 -> 4.30.1 - react-native-skia 2.15.1 -> 2.15.2 (victory-native 43 still caps it below 3.0) - react-native-worklets 0.13.0 -> 0.13.1 - react-native-paper 5.15.3 -> 5.15.4 (patch renamed, applies unchanged) - @legendapp/list 3.6.0 -> 3.7.1 - react-native-bootsplash 7.3.4 -> 7.3.5 - @typescript-eslint/* ^8.72.0 -> ^8.72.1 Podfile.lock and REACT_NATIVE_PATH regenerated for 0.88.1.
## What Upgrades the showcase to **React Native 0.88.1** and **Re.Pack 5.4.3**, renames Skia to the new `react-native-skia` package, moves to **victory-native 43**, and drops `react-native-edge-to-edge` now that RN owns edge-to-edge. Everything was verified end to end on the iOS Simulator and an Android emulator (details below). ## Core | | | | --- | --- | | React Native | 0.87.1 → **0.88.1** | | React | 19.2.8 → **19.3.1** | | `@react-native/*` | 0.87.1 → **0.88.1** | | Re.Pack + repack-plugin-reanimated | 5.4.2 → **5.4.3** | | `@rspack/core` | 2.2.6 → **2.3.1** | | `@module-federation/enhanced` / `error-codes` | 2.9.1 → **2.9.3** | | `react-native-safe-area-context` | 5.10.0 → **5.11.1** | | `react-native-screens` | 4.28.0 → **4.30.1** | | `react-native-worklets` | 0.13.0 → **0.13.1** | | `react-native-paper` | 5.15.3 → **5.15.4** (patch renamed, applies unchanged) | | `@legendapp/list` | 3.4.0 → **3.7.1** | | `react-native-bootsplash` | 7.3.3 → **7.3.5** | | `@typescript-eslint/*` | ^8.70.1 → **^8.72.1** | ### Re.Pack 5.4.3 Re.Pack 5.4.3 was validated through its canaries; the published 5.4.3 packages are identical to `5.4.3-canary-20261104085523` apart from version strings, so the results below apply to the release. It includes everything in callstack/repack#1485, including the Fastify **FSTDEP023** fix (#1513): no deprecation warning on any of the four dev servers, while normal logs still stream. It also includes **callstack/repack#1516**: `HermesBytecodePlugin` now runs `hermesc` after every asset has been written, so every chunk's source map gets composed. Comparing every published package against the previous canary, this is the only code change. This app doesn't enable the plugin, so it was tested with a temporary config on the trading mini app (66 lazy chunks), 3 builds per platform before and after: | | Chunks with a composed source map | Bytecode size | | --- | --- | --- | | Before (`…20261103170520`) | 28–39 of 66, varies per run | 4.58–4.79 MB | | After (`…20261104085523`) | **66 of 66, every run, iOS and Android** | **4.02 MB** | Looking up bytecode positions the way a crash reporter would: with the new maps, 2,024 of 2,024 app-code positions resolve to the correct line in the correct source file. With the old maps, 7 did, 1,827 pointed at the wrong file or line, and 190 had no mapping. ## Skia rename + charts - `@shopify/react-native-skia` → **`react-native-skia`**. Same code, new package name (pod name changes too, so `Podfile.lock` is refreshed). - **Skia stays on 2.x (2.15.2), not 3.x**: victory-native 43 declares `react-native-skia >=2.15.1 <3.0.0`, so 3.x (3.9.1 is current) is still unsupported by the charting layer. Worth revisiting when victory-native ships Skia 3 support. - **victory-native 42.0.1 → 43.0.1**. 43 builds paths with `Skia.PathBuilder`, which lets us delete the `SkPath.addPath()` deprecation-warning shim that 41/42 needed. ## Edge-to-edge `react-native-edge-to-edge` is removed and `AppTheme` goes back to `Theme.AppCompat.DayNight.NoActionBar` (the RN 0.88 template value, and the same base as `Theme.BootSplash`). `edgeToEdgeEnabled=true` stays in `gradle.properties` — RN core handles the insets, and content draws behind both bars on device. ## Fix: invisible chart labels on Android Found while testing this branch: the price chart drew fine on Android but its y-axis labels were missing (they rendered on iOS). Root cause is in app code, not the bump — `matchFont()` defaults to the family `"System"`, which Skia's Android font manager does not expose (`listFontFamilies()` returns `sans-serif`, `arial`, …), so it resolves a glyph-less typeface (`measureText('$82.1k').width === 0`) and victory-native measures a zero-height label and skips it. `packages/trading/src/screens/AssetDetailsScreen.tsx:130` now asks for `sans-serif` on Android and keeps `System` elsewhere. The old `@shopify/react-native-skia@2.14` `matchFont` JS is byte-identical, so this was a latent bug rather than a regression. ## Smaller changes - Deleted `patches/react-native-bottom-tabs@1.4.0.patch` — obsolete against RN 0.88. - Deleted the `@babel/plugin-syntax-typescript` catalog entry; Re.Pack 5.4.3 declares it as a dependency now. - Added `@react-native/metro-config` to the catalog and packages — without it align-deps pulls a second `react-native` peer copy and instantiates it twice. - Aliased `expo-font` to `false` in `packages/auth/rspack.config.ts`, matching the host: vector-icons 14 probes it behind a `try/catch` on web only, and the native font is always bundled. - `allowBuilds` updated for the renamed Skia package. The `minimumReleaseAgeExclude` list is removed: every pinned version is now past pnpm's default release-age window. ## Deliberately not updated - **Reanimated 4.7.1 is already the newest stable**; only nightly builds are newer. - Babel stays on 7.x (`@react-native/babel-preset` peers `^7`), Jest on ^29, ESLint on ^9.39.5, TypeScript on ^6.0.3 (typescript-eslint caps at `<6.1`). ## Verification `pnpm install`, `pnpm peers check` (clean), `pnpm -r typecheck`, `pnpm -r lint`, `pnpm -r test`, `pnpm format:check`, `pnpm check-deps` all pass. Production rspack bundles build for host + trading + wallet + auth on **both** iOS and Android. `bundle exec pod install` is clean, `xcodebuild` Debug builds, and `./gradlew assembleDebug` succeeds including the renamed `:react-native-skia` module. Runtime, on an iPhone 17 simulator and a Pixel emulator, through the full demo: auth sign-in → live Markets prices → asset details (Skia chart with axis labels on **both** platforms) → trade bottom sheet → wallet holdings → account → sign out → sign back in. All four dev servers (host 8081, trading 9001, wallet 9002, auth 9003) served `/{platform}/mf-manifest.json` for both platforms, the host dev bundle built to ~11.6 MB for iOS and Android, and every container reported `Compiled ios`/`Compiled android`. Dev-loop check on the Re.Pack 5.4.3 canary: editing a screen in the `auth` container triggered a watch rebuild in 0.6s/0.7s, the rebuilt `__federation_expose_*.chunk.bundle` served the new code, and the running app picked it up. HMR sockets stayed connected to the host, auth and trading servers concurrently, and `SIGINT` shuts each server down in ~100ms. ### Re-verified on 0.88.1 + Re.Pack 5.4.3 Lint, typecheck, tests, format check and `check-deps` pass, and production bundles build for all four apps on both platforms. A fresh `pod install` → `xcodebuild` Debug build works **without** the `.last_build_configuration` workaround described below, and `./gradlew assembleDebug` succeeds. On the iPhone 17 simulator: Markets with live prices → Skia chart → trade sheet → wallet → account → sign out → sign in, with no JS errors; hot reload of the `auth` remote applies in 0.2–0.3s; dev servers exit in under 100ms on `SIGINT`. Re-run on the published 5.4.3: the same checks and bundles pass, `pod install` and an incremental Debug build succeed, and the full flow, hot reload, and sub-100ms shutdown were repeated on the iPhone 17 simulator and on an Android 15 emulator (Pixel; `assembleDebug` APK). On Android the Skia chart draws with its axis labels, the trade sheet opens, wallet updates live, and sign out / sign in works. No JS errors on either platform. **Release builds** on Re.Pack 5.4.3: an iOS `Release` simulator build and an Android `assembleRelease` APK (R8 minification on), each with a Hermes bytecode main bundle and no dev server running. The auth, trading and wallet remotes were production bundles (`react-native bundle --dev false`) served from a static file server on their usual ports. On both platforms the full flow works (sign in → live Markets → Skia chart with axis labels → trade sheet → wallet → account → sign out → sign in), every remote request returned 200, and there were no crashes or JS errors. For the local Android run the release manifest temporarily allowed cleartext HTTP to reach `http://localhost`; that change isn't part of this PR. ## Known upstream noise (pre-existing, unchanged by this PR) - `@gorhom/bottom-sheet` passes a deps array to `useAnimatedStyle`, so Reanimated logs `Dependencies should only be used on the web…` repeatedly while the sheet is mounted. - Re.Pack 5.4.3 adds a plugin check, so the auth dev server logs a `ReanimatedPlugin` advisory because auth lists `react-native-reanimated` in `dependencies` (trading/wallet use `peerDependencies`, which is why only auth warns). Auth has no animations, so it is harmless, and auth never configured the plugin on `main` either — not a regression. Tidying that dep is out of scope here. - `Could not find generated setter for class com.reactnative.skia.Skia*ViewManager` on Android — benign, from the new package id. - On shutdown, `@rspack/core`'s Node bindings print `ObjectRef is not unref, it considered as a memory leak` — cosmetic, does not delay exit. - **RN 0.88.0 prebuilt-core pitfall (Re.Pack-unrelated, hit locally; did not reproduce on 0.88.1):** after a fresh `pod install`, a Debug build fails to link with `Undefined symbols: facebook::react::Sealable::Sealable()`, and if an stale bundle is reused the app then dies at launch with `Symbol not found: ...hermes::cdp::CDPDebugAPI::addConsoleMessage...`. `pod install` stages the *Release* `React.xcframework` and `hermesvm`, but `replace-rncore-version.js` / `replace_hermes_version.js` skip their swap when `Pods/<pod>/.last_build_configuration` is absent, because they assume the staged artifact is Debug. Workaround: write `Release` into `Pods/React-Core-prebuilt/.last_build_configuration` and `Pods/hermes-engine/.last_build_configuration`, then rebuild — both print `Replacing …` / `Done replacing hermes-engine` and the build succeeds. Worth reporting upstream. - `pod install` intermittently dies with CocoaPods `ArgumentError - pathname contains null byte` (known pnpm-monorepo flake, [cocoapods#12866](CocoaPods/CocoaPods#12866)); re-running succeeds. - **`HermesBytecodePlugin` can't find hermesc under pnpm on RN 0.82+ (not used by this app, unchanged since 5.4.2):** the default lookup joins `<context>/node_modules/react-native/../hermes-compiler` without resolving the pnpm symlink, then falls back to `sdks/hermesc`, which RN 0.88 no longer ships. Passing `reactNativePath: fs.realpathSync(...)` works around it. When hermesc fails, `react-native bundle` still exits 0 and leaves the chunks as plain JS.
Summary
HermesBytecodePluginrunshermescin theassetEmittedhooks and checks whether the chunk's.mapexists. A chunk's.mapmay not have been written yet at that moment, sohermescruns without source maps:.bundle), making the chunk biggercomposeSourceMapsis skipped, so stack traces for that chunk can't be symbolicated back to the original sourceThis change calls the
hermescfrom theafterEmithook instead, once all assets are guaranteed to be written.Our app has many lazy chunks, and most of them hit the race. With this fix, the debug info is moved from the chunks into the source maps:
Lazy chunks now ship with a composed source map, and frames resolve to the correct source file and line. The main bundle is not affected, since React Native compiles it with its own
hermescstep.Test plan