fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors#5958
Merged
lucas-zimerman merged 5 commits intomainfrom Apr 7, 2026
Merged
fix(core): Lazy-load Metro internal modules to prevent Expo 55 import errors#5958lucas-zimerman merged 5 commits intomainfrom
lucas-zimerman merged 5 commits intomainfrom
Conversation
… errors Defer requiring Metro internals (baseJSBundle, sourceMapString, bundleToString) until they're actually needed during serialization, rather than at module import time. This prevents "Cannot find module 'metro/src/DeltaBundler/Serializers/baseJSBundle'" errors when Metro is only a transitive dependency through Expo. The fix moves Metro module requires from module-level to inside createDefaultMetroSerializer(), ensuring the config can be imported successfully even when Metro internals aren't immediately available. Fixes #5957 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Sentry Build Distribution
|
Contributor
Android (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 442.02 ms | 456.52 ms | 14.50 ms |
| 3817909+dirty | 406.67 ms | 416.58 ms | 9.91 ms |
| df5d108+dirty | 527.06 ms | 603.58 ms | 76.52 ms |
| a50b33d+dirty | 500.81 ms | 532.11 ms | 31.30 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
| 3817909+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
| df5d108+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
| a50b33d+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
Contributor
iOS (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 1212.06 ms | 1214.83 ms | 2.77 ms |
| df5d108+dirty | 1225.90 ms | 1220.14 ms | -5.76 ms |
| a50b33d+dirty | 1197.74 ms | 1197.17 ms | -0.57 ms |
| 3817909+dirty | 1183.90 ms | 1187.50 ms | 3.60 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| df5d108+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| a50b33d+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| 3817909+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
antonis
reviewed
Apr 7, 2026
antonis
approved these changes
Apr 7, 2026
Contributor
antonis
left a comment
There was a problem hiding this comment.
LGTM 🚀
Great fix Lucas. Just left a comment on a stray comment :)
Contributor
iOS (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 1217.41 ms | 1223.53 ms | 6.12 ms |
| df5d108+dirty | 1207.34 ms | 1210.50 ms | 3.16 ms |
| a50b33d+dirty | 1207.11 ms | 1212.10 ms | 5.00 ms |
| 3817909+dirty | 1210.76 ms | 1215.64 ms | 4.89 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| df5d108+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| a50b33d+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
| 3817909+dirty | 3.38 MiB | 4.73 MiB | 1.35 MiB |
Contributor
Android (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 398.80 ms | 431.81 ms | 33.01 ms |
| 3817909+dirty | 357.52 ms | 391.52 ms | 34.00 ms |
| df5d108+dirty | 434.82 ms | 447.39 ms | 12.57 ms |
| a50b33d+dirty | 353.21 ms | 398.48 ms | 45.27 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 4953e94+dirty | 43.94 MiB | 48.94 MiB | 5.00 MiB |
| 3817909+dirty | 43.94 MiB | 48.94 MiB | 5.00 MiB |
| df5d108+dirty | 43.94 MiB | 48.94 MiB | 5.00 MiB |
| a50b33d+dirty | 43.94 MiB | 48.94 MiB | 5.00 MiB |
Co-authored-by: Antonis Lilis <antonis.lilis@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
Defer requiring Metro internals (baseJSBundle, sourceMapString, bundleToString) until they're actually needed during serialization, rather than at module import time. This prevents "Cannot find module 'metro/src/DeltaBundler/Serializers/baseJSBundle'" errors when Metro is only a transitive dependency through Expo.
The fix moves Metro module requires from module-level to inside createDefaultMetroSerializer(), ensuring the config can be imported successfully even when Metro internals aren't immediately available.
💡 Motivation and Context
Fixes #5957
💚 How did you test it?
Expo sample app
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps