Commit b86c948
committed
Bootstrap Metro from InitializeCore until setup-env is graph-reachable
Summary:
Fresh projects redbox on launch (e.g. "Failed to call into JavaScript module
method RCTDeviceEventEmitter.emit() / HMRClient.setup(). Module has not been
registered as callable. Registered callable JavaScript modules (n = 1):
AppRegistry."). Core initialization never runs.
Metro's `getModulesRunBeforeMainModule` (metro/src/lib/getAppendScripts.js)
only emits the run-before `__r()` call for a module that is *already present
in the bundle graph*, and silently skips it otherwise.
#57475 switched the run-before target from `Libraries/Core/InitializeCore` to
`src/setup-env.js`. `InitializeCore` is reachable in the graph (imported by
`Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js`); `src/setup-env.js`
is imported by nothing, so Metro skips it and core init never runs. The two
modules are functionally identical (both call
`setUpDefaultReactNativeEnvironment().default()`).
Evidence (bundle tail):
- setup-env target: `__r(0);` (broken)
- InitializeCore target: `__r(<InitializeCore>); __r(0);` (fixed)
This is an INTERIM stopgap. It only changes the internal Metro bootstrap
target back to `InitializeCore`; the public `react-native/setup-env` entry
point and its deprecation of InitializeCore are unchanged. The durable fix is
to make `setup-env` graph-reachable (or make Metro treat
`getModulesRunBeforeMainModule` entries as graph roots), which will then allow
InitializeCore to be removed.
Changelog:
[General][Fixed] - Fix apps failing to boot ("... not registered as callable")
caused by core init not running.
Test Plan:
- `yarn test-release-local -t RNTestProject -p iOS`: app boots without redbox.
- Bundle tail contains `__r(<InitializeCore>); __r(0);` instead of just `__r(0);`.1 parent ef54f74 commit b86c948
2 files changed
Lines changed: 4 additions & 4 deletions
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments