react-native
react-native copied to clipboard
refactor(dev-middleware): drop `node-fetch` in favor of Node built-in fetch
Summary:
Node 22 doesn't work well with node-fetch@2, as one of their polyfills is using the deprecated punycode module. This causes unnecessary warnings like:
Instead of upgrading to the much larger node-fetch@3, this change drops node-fetch in favor of Node's own built-in fetch implementation (using undici).
Note,
@react-native/dev-middlewarealready has theengines.node >= 18(which is required for fetch).
Changelog:
[GENERAL] [CHANGED] - Drop node-fetch in favor of Node's built-in fetch from undici in @react-native/dev-middleware
Test Plan:
See CI for passing tests
Why would it fail on globalThis, it's the spec-guaranteed global 🙈
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 20,366,100 | -4 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 23,562,903 | -5 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: c7988c9c82793b6b41d4c9190a28ce1202410fa0 Branch: main
@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@byCedric if we use this with Node 18, or Node 20, do we get experimental API warnings?
@byCedric if we use this with Node 18, or Node 20, do we get experimental API warnings?
@NickGerleman No, there should not be any experimental warnings around fetch in the Node 18 or 20 (except versions older than Node 18.13.0 - released on Jan 6th, 2023):
| Node 18.0.0 | Node 18.20.3 | Node 20.0.0 |
|---|---|---|
That warning was removed in Node 18.13.0, through PR 45287
@robhogan merged this pull request in facebook/react-native@30a3e6e8dfcfc9597873578b8332ec027ccf1b84.
This pull request was successfully merged by @byCedric in 30a3e6e8dfcfc9597873578b8332ec027ccf1b84.
When will my fix make it into a release? | How to file a pick request?