Commit 60a157e
authored
fix(network-activity-plugin): avoid Metro optional dependency overlay for Nitro (callstackincubator#273)
## Summary
Move `react-native-nitro-fetch` resolution to module initialization so
the network activity plugin reads the optional dependency once before
React Native finishes initializing.
## Context
It's supposed to provide a workaround for Metro 0.82 bug, where optional
dependencies required at run-time, after react-native is initialized,
will show the error overlay. The changes done are moving the require
time to before react-native is fully initialized, just like we do
currently for `react-native-sse`, so the error overlay is never
displayed.
This keeps the existing fallback behavior for apps that do not install
`react-native-nitro-fetch`, but avoids re-running the optional require
from the nitro inspector enable path.
## Proposed Testing Scenario
1. Run an app that includes `@rozenite/network-activity-plugin` without
installing `react-native-nitro-fetch`.
2. Start and stop network recording multiple times after the app has
already initialized.
3. Confirm the app does not show the Metro error overlay for the missing
optional nitro dependency.
4. Run an app that does install `react-native-nitro-fetch` and verify
network recording still works for nitro-backed requests.1 parent ea2d273 commit 60a157e
2 files changed
Lines changed: 10 additions & 1 deletion
File tree
- .changeset
- packages/network-activity-plugin/src/react-native/nitro-fetch
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
0 commit comments