Commit Graph

128 Commits

Author SHA1 Message Date
Sam Zhou 4365c1c9f7 Cleanup codeless suppressions in xplat/js (#53573)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53573

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D81552699

fbshipit-source-id: 71b104174a8ad7fbf360cdd87109ce034f49ec70
2025-09-02 21:56:09 -07:00
Phil Pluckthun b054540092 Mark @react-native/metro-config as optional peer to fix warning (#53314)
Summary:
The `react-native/metro-config` peer was added in https://github.com/facebook/react-native/commit/fe2bcbf4ba7ce983fac0cd09727c165517b6337f / https://github.com/facebook/react-native/issues/51836 by robhogan

Side-note: It's pulled in via `react-native/community-cli-plugin` which is a direct dependency of `react-native` for the `scripts/bundle.js` script. While, for expo, we'd love to find a way to make this an optional dependency (to avoid excessive deps that `expo` replaces otherwise), for now, it's a direct dependency.

The problem here is that this isn't optional, which means:
- with auto-installing peer dependencies it is directly fulfilled (while `react-native-community/cli` is already marked as optional and skipped)
- with legacy/non-auto peer-dependencies it is flagged as missing, but in an Expo project it wouldn't make sense to install directly

This causes a **package manager regression in the form of either a peer dependency warning**, that shouldn't be fulfilled in an Expo project, or (in the best case scenario) pulls in dependencies [that a user does not need](https://npmgraph.js.org/?q=%40react-native%2Fmetro-config#zoom=w&select=exact%3A%40react-native%2Fmetro-config%400.81.0).

An error message is already in place to inform the user of this being missing when it's not installed, so marking it as optional seems appropriate.

## Changelog:

[INTERNAL] [FIXED] Mark added `react-native/metro-config` peer dependency as optional

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/53314

Test Plan:
Warnings like the following won't occur in fresh Expo (54/preview/`next`) projects
```
warning "workspace-aggregator-484d9ec3-587b-43cb-97de-4dcce3876578 > microfoam-mobile > react-native > react-native/community-cli-plugin@0.81.0" has unmet peer dependency "react-native/metro-config@*".
```

Reviewed By: cortinico

Differential Revision: D80450287

Pulled By: robhogan

fbshipit-source-id: c622fd4c24025676c0ec74de826f863f1e291669
2025-08-24 14:18:42 -07:00
Sam Zhou 0530ea3349 Migrate to suppression with error code in xplat: 1/n (#53439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53439

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D80809220

fbshipit-source-id: 6f432d8302934b9fee9780ac1d6ba6c87c0b3899
2025-08-22 10:35:39 -07:00
Sam Zhou cf664c65e2 Standardize subtyping error code into incompatible-type in react native and metro (#53312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53312

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D80400976

fbshipit-source-id: 196af69c0b9621b2a2675b232406639773e04933
2025-08-18 09:04:31 -07:00
Sam Zhou 35bee1a857 Add annotations to fix future natural inference errors in xplat/js
Summary: Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D80207164

fbshipit-source-id: e9a786c83f89a97db8b383812767978c47d9536c
2025-08-13 18:15:27 -07:00
Sam Zhou af1bcb6d44 Mass replace $FlowIgnore with $FlowFixMe in react-native (#53076)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53076

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D79672242

fbshipit-source-id: 560f057d8658ed602cf7241e584bade70d8f3a99
2025-08-05 15:44:41 -07:00
Marco Wang d041e8b7e0 Pre-suppression errors for functionT in xplat js (#52820)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52820

Reviewed By: SamChou19815

Differential Revision: D78941100

fbshipit-source-id: 66d462670471212d23e8682bd5bf1ebd79ef4582
2025-07-25 13:46:08 -07:00
Rob Hogan 840fd6c83f Bump Metro to ^0.83.1, lower minimum Node.js version to 20.19
Summary:
Metro release notes: https://github.com/facebook/metro/releases/tag/v0.83.1

The only public-facing change is a lowering of the minimum Node.js version from 22.14 to 20.19.

This will need picking to RN `0.81-stable`

Changelog: [General][Changed] Metro to ^0.83.1

Reviewed By: huntie

Differential Revision: D78895160

fbshipit-source-id: b9ccffe972249b73897f51c14873861e57a97161
2025-07-24 12:10:18 -07:00
Nicola Corti 9f0903780b Bump monorepo packages to 0.82.0-main (#52706)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52706

This just prepares the repo for the next branch cut.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D78558445

fbshipit-source-id: 2132d560dad447b3685874438387a519587f8554
2025-07-18 09:23:10 -07:00
Alex Hunt e247be793c Lower minimum Node.js version to 20.19.4 (#52678)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52678

From partner feedback, there's still appetite to support Node 20.x for the next <1y of life. Lower min version to `20.19.4` (Jul 2025) and widen test matrix in CI.

Changelog:
[General][Breaking] - Our new minimum Node version is Node.js 20 (Overrides #51840)

Reviewed By: cortinico

Differential Revision: D78494491

fbshipit-source-id: c8d9dc6250cb11f8a12ca7e761b65f4a8dae9265
2025-07-18 03:32:13 -07:00
Rob Hogan cf45aa9dbc Bump Metro to 0.83.0 (#52576)
Summary:
Bump Metro to 0.83.0.

This release contains some breaking changes for integrators, and a minimum Node.js version of 22.14.

Full release notes: https://github.com/facebook/metro/releases/tag/v0.83.0

Changelog: [General][Changed] Bump Metro to ^0.83.0

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

Rollback Plan:

Differential Revision: D78171925

Pulled By: robhogan

fbshipit-source-id: 7ea5e04d285632a14dd71ba00da872d60f283840
2025-07-13 15:39:46 -07:00
Rob Hogan bb3ef784e3 Remove HTTP keepAliveTimeout workaround not needed since Node.js 12 (#52561)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52561

The removed code comment is pretty clear that this workaround is in place for a specific bug, which was closed in a Node.js 8.x minor: https://github.com/nodejs/node/issues/13391

A related issue descibed a problem that still existed in Node 10:
https://github.com/nodejs/node/issues/27363

Subsequent comments reporting problems with newer Node.js versions all seem to relate to mismatched configuration with load balancers, not directly relevant to Metro.

Reproducers for the original bugs no longer repro on new Node.js (tested with 22.14), so I think it's safe to conclude this is fixed.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D78158427

fbshipit-source-id: 0be5dbc4334ac7b0bbccde44a840caac43deb4df
2025-07-11 11:03:29 -07:00
Alex Hunt fc5e33b582 Reorganise shared script utils (#52473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52473

Shared utils that were located in the root of `scripts/` are now colocated closer to their dependencies or moved to `scripts/shared/` — simplifying the root directory layout.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D77873875

fbshipit-source-id: e04dba41a1ef811d32793931033fdfa93afad0cd
2025-07-08 06:10:36 -07:00
Rob Hogan 083644647e Update to Metro ^0.82.5 (#52454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52454

Bump Metro minimum from 0.82.4 to 0.82.5

Release notes: https://github.com/facebook/metro/releases/tag/v0.82.5

Changelog: [General][Changed] Bump Metro to ^0.82.5

Reviewed By: huntie

Differential Revision: D77450102

fbshipit-source-id: 7b0fdcbeb63d8021996ca82f98773145179c8a50
2025-07-06 04:30:38 -07:00
Nicola Corti b578a70bd5 Bump packages for next release (#52359)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52359

This is needed ahead of the 81 branch cut.

Changelog:
[Internal] - Bump all packages to 0.81.0-main

Reviewed By: huntie

Differential Revision: D77602196

fbshipit-source-id: 1b52a7d1577783d72aba8d20f98032f29ffcc7df
2025-07-02 03:53:34 -07:00
Alex Hunt 62bf92c896 Replace chalk in packages (#51905)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51905

Replaces `chalk` with Node's `util.styleText` in `packages/`.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D76273412

fbshipit-source-id: edaea5896751be1252056e0858daae46e97acc46
2025-06-09 18:21:18 -07:00
Rob Hogan fe2bcbf4ba Community CLI: Don't clobber user config of Metro resolver/serializer, expose CLI config to user as defaults (#51836)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51836

Currently, `community-cli-plugin` loads the user config and then overrides parts of it - specifically `resolver.resolveRequest` and `serializer.getModulesRunBeforeMainModule`, making it impossible for a user to modify this config.

Instead, treat the CLI's resolver and serializer customisations as "Framework defaults", layered on top of `react-native/metro-config` defaults but beneath a user's `metro.config.js`.

This allows the user to obtain (via `react-native/metro-config`'s `getDefaultConfig`) and extend or override them, if they need to.

This is technically breaking because users who currently have a custom `resolveRequest` or `getModulesRunBeforeMainModule` in their `metro.config.js` will have that config respected from this change, whereas currently they won't have any effect.

Changelog:
[General][Breaking] Community CLI users: user-defined `resolver.resolveRequest` and `serializer.getModulesRunBeforeMainModule` Metro config now takes precedence over CLI defaults

Reviewed By: huntie

Differential Revision: D74811395

fbshipit-source-id: c250caf798fdaedb0822bea3d6e65c0c3ae4d691
2025-06-09 07:44:02 -07:00
Alex Hunt df39eadc03 Bump minimum Node.js version to 22.14.0 (#51840)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51840

Bumps the minimum version of Node.js in React Native to the current active LTS release (22.x, upgraded from 18.x which is now out of support).

- CI configurations are reduced from `[22, 20, 18]` to `[24, 22]`.

{F1978909878}

See https://nodejs.org/en/about/previous-releases.

Changelog:
[General][Breaking] - Our new minimum Node version is Node.js 22

Reviewed By: yungsters, cortinico

Differential Revision: D76037015

fbshipit-source-id: b6e4b3ee279a9a93d716a13297420bba73f45250
2025-06-06 05:21:39 -07:00
Tim Yung 3e6423fe65 RN: Flowify packages/rn-tester (#51788)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51788

Adds `flow` to the remaining files that are lacking it in the `packages/rn-tester` directory.

This also adds any necessary type annotations and fixes lint warnings.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75899307

fbshipit-source-id: 27a74ed0007b3b754446a45931c2c148312d5e3a
2025-06-04 12:03:52 -07:00
Tim Yung cc9074884a RN: Add @noflow to Node.js Scripts (#51779)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51779

Adds `noflow` to a bunch of Node.js script files.

In the future, these files could be migrated to use `flow strict-local` or `flow strict` using comment syntax for type annotations. But for now, adding `noflow` makes it explicit that these are known to not be typechecked.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D75883703

fbshipit-source-id: a8fed3aaa9c55ecda919a705940f8b34504cb07c
2025-06-04 12:03:52 -07:00
Rob Hogan 8ad43da3be Update Metro imports to use package root exports (#51261)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51261

Cleanup to use the new public type / API exports from `metro` landed in Metro 0.82.3, which is RN's minimum as of D74181990 / [PR](https://github.com/facebook/react-native/pull/51122), in preference to deep imports.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74141939

fbshipit-source-id: 9405f88a85e248abe8a92be1dd5a5f1ea6ceeb87
2025-05-26 04:54:26 -07:00
Rob Hogan a3447d6b8b community-cli-plugin: Refactor CLI build command to use Metro.runBuild (#51124)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51124

Metro 0.82.3's `runBuild` API now supports retrieving assets and passing through `unstable_transformProfile`, and fine control of output paths via `bundleOut`/`sourcemapOut`, so we can use it directly in the implementation of `community-cli-plugin`'s `bundle` command with no loss of function or API change.

This simplifies the implementation by re-using Metro's, and removes use of Metro internal APIs.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74151840

fbshipit-source-id: 3dcadaf8d38e7e77d21bacdf29e5d40467139d88
2025-05-26 03:45:58 -07:00
Rob Hogan fa79fd8f96 Bump Metro to 0.82.4 (#51567)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51567

Bump Metro minimum from 0.82.3 to 0.82.4

Release notes: https://github.com/facebook/metro/releases/tag/v0.82.4

Changelog: [General][Changed] Bump Metro to ^0.82.4

Reviewed By: vzaidman

Differential Revision: D75294674

fbshipit-source-id: 750e83db2fb5cd9a6bf4b1971cb701ac23dfa961
2025-05-23 10:53:17 -07:00
Tim Yung 84de8a075e RN: Delete @oncall Annotations (#51416)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51416

Deletes `oncall` annotations from the `facebook/react-native` repository.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D74902524

fbshipit-source-id: 32a6a5b2ff27281792d572f151e2b094d9a79029
2025-05-17 16:18:05 -07:00
Rob Hogan db0fa9200e Update Metro to ^0.82.3 (#51122)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51122

Update Metro to 0.82.2 => 0.82.3, containing important bug fixes for `package.json#exports` support.

Changelog: [General][Changed] Metro to ^0.82.3

Reviewed By: huntie

Differential Revision: D74181990

fbshipit-source-id: 8320a0cf4aa671d9e7f2976c36d260934807a179
2025-05-06 09:29:30 -07:00
Rob Hogan f4936894f0 Miscellaneous lint fixes (#51099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51099

Fix up some misc broken lints and add temporary suppressions to reduce noise in the subsequent stack.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74141669

fbshipit-source-id: dc19378e41f6d8d45fc7d2ecf18c1c01a1e501be
2025-05-05 09:48:46 -07:00
Rob Hogan 93f22e79d4 community-cli-plugin: Use TerminalReporter type from metro, replace deep imports (#51092)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51092

`TerminalReporter` is re-exported from `metro` (since [0.76.7](https://github.com/facebook/metro/releases/tag/v0.76.7)), so we can update these deep imports to use public exports.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D74141704

fbshipit-source-id: 22cd3209868ed9ab260e199f9099ef98335feaeb
2025-05-04 09:57:57 -07:00
Alex Hunt 46ddb604d9 Update Metro dependencies to 0.82.2 (#50977)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50977

Updates all `metro*` dependencies to the latest `^0.82.2`.

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D73841705

fbshipit-source-id: dc550abfecddce933ed148f094aaf8629ffe549b
2025-04-29 06:25:22 -07:00
Jakub Grzywacz 864833fca9 Generate keep.xml to prevent resource shrinking on Android (#50620)
Summary:
On Android, when resource shrinking is enabled, all resources added by Metro may be removed as react-native is accessing resources based on strings rather than references, so AGP can't see its usage.

Example output of `android/app/build/outputs/mapping/release/resources.txt `when `shrinkResources` is enabled.
```
raw/__node_modules_expo_vectoricons_build_vendor_reactnativevectoricons_fonts_materialcommunityicons : reachable=false
drawable/__common_assets_haptics_icon : reachable=false
```

It’s a coincidence that most of the resources are currently working, as many file names begin with strings that already exist in the String Pool. For example, `node_modules...` is flagged as used because 'node' is present in the String Pool, causing it to be whitelisted. However, this does not guarantee that the same will apply to all files - especially in a monorepo setup, where paths are significantly different. For example
* `__node_modules_expo_vectoricons_build_vendor_reactnativevectoricons_fonts_materialcommunityicons`
* `__common_assets_haptics_icon`

To prevent that behavior, metro during assets export should create `keep.xml` listing all resources generated by metro.
https://developer.android.com/build/shrink-code#keep-resources

We have already made a similar change in expo cli: https://github.com/expo/expo/pull/35465

## Changelog:

[ANDROID][ADDED] - Generate keep.xml to prevent resource shrinking

Pull Request resolved: https://github.com/facebook/react-native/pull/50620

Test Plan:
1. Enable resource shrinking in RNTester by adding this to `android.buildTypes.release` to `packages/rn-tester/android/app/build.gradle.kts`
```gradle
isMinifyEnabled = true
isShrinkResources = true
```
2. Use some resources in playground, for example:
```diff
 diff --git a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
index 9dbacb99701..9ac9c231f3f 100644
 --- a/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
+++ b/packages/rn-tester/js/examples/Playground/RNTesterPlayground.js
@@ -11,16 +11,14 @@

 import type {RNTesterModuleExample} from '../../types/RNTesterTypes';

-import RNTesterText from '../../components/RNTesterText';
 import * as React from 'react';
 import {StyleSheet, View} from 'react-native';
+import {Header} from "react-native/Libraries/NewAppScreen";

 function Playground() {
   return (
     <View style={styles.container}>
-      <RNTesterText>
-        Edit "RNTesterPlayground.js" to change this file
-      </RNTesterText>
+      <Header />
     </View>
   );
 }
```

3. Build app using `hermesRelease` variant
4. See Playground screen

| Before | After |
|---|---|
| <img width="488" alt="Zrzut ekranu 2025-04-10 o 12 17 53" src="https://github.com/user-attachments/assets/24fcaa7b-6ddb-4ba6-9fe5-65c27bcbc931" /> | <img width="488" alt="Zrzut ekranu 2025-04-10 o 12 15 58" src="https://github.com/user-attachments/assets/09a1ce77-be26-4571-a4b8-c466bf19e026" /> |

5. Inspect `packages/rn-tester/android/app/build/outputs/mapping/hermesRelease/resources.txt`

| Before | After |
|---|---|
| `drawable/_reactnative_libraries_newappscreen_components_logo : reachable=false` | `drawable/_reactnative_libraries_newappscreen_components_logo : reachable=true` |

Reviewed By: cortinico

Differential Revision: D72960028

Pulled By: huntie

fbshipit-source-id: df725fa2ea50150cd67687a97986976ffbbb5b40
2025-04-14 07:33:27 -07:00
Alex Hunt e70961e05c Bump packages for next release (#49972)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49972

Follows the recent `0.79-stable` branch cut.

Changelog: [Internal] - Bump all packages to `0.80.0-main`

Reviewed By: cortinico

Differential Revision: D70976555

fbshipit-source-id: e81e4c45c6a510e114d02853c5bb90a715b7df8b
2025-03-12 05:11:16 -07:00
Rob Hogan 0ad192003e Update Metro dependencies to 0.82.0 (#49885)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49885

Updates all `metro*` dependencies to the latest `^0.82.0`.

The breaking changes in this release apply only to frameworks and integrators.

This update brings `package.json#exports` resolution enabled by default, and lazy hashing for much faster Metro startup.

Release notes:
https://github.com/facebook/metro/releases/tag/v0.82.0

Changelog:
[General][Changed] Update Metro to ^0.82.0

Reviewed By: vzaidman

Differential Revision: D70778791

fbshipit-source-id: ffb55ed384d721205aa4d7f528c63c0b0a38abc5
2025-03-07 10:09:22 -08:00
Vitali Zaidman b30538d804 update and dedupe the npm package "debug" (#49816)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49816

Previously, we had different versions of "debug" installed in different packages, mostly because of messed up `yarn.lock` entries.

Also, updated the package, receiving some performance improvements (no relevant breaking changes).

Changelog:
[General][Internal] update and dedupe the npm package "debug"

Reviewed By: huntie

Differential Revision: D70402368

fbshipit-source-id: 5e21bc6d92e0cb45ac1d862f100ef6dc0f21dbc1
2025-03-05 20:52:30 -08:00
Rob Hogan 6606a1da84 Update Metro ^0.81.0 -> ^0.81.3 || ^0.82.0 (#49779)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49779

Changelog:
[General][Changed] Bump minimum Metro from 0.81.0 to ^0.81.3 || ^0.82.0

Reviewed By: hoxyq

Differential Revision: D70473389

fbshipit-source-id: aee3cb073fef420fd7bc1efedb0b48411b038c44
2025-03-03 07:58:20 -08:00
Phil Pluckthun 55acb42105 chore(community-cli-plugin): Remove extraneous @react-native/metro-babel-transformer (#49558)
Summary:
Opening this as a separate PR, since I'm not sure if I'm missing something, or if there's any intention behind this.

`react-native/metro-babel-transformer` is used by `react-native/metro-config` and is referenced in code there and as a dependency there. It's also sometimes mentioned as package for community CLI users to install directly. However, there's seemingly no reason `react-native/metro-babel-transformer` needs to depend on it, or any code that relies on it directly.

## Changelog:

[INTERNAL] [CHANGED] - Remove extraneous `react-native/metro-babel-transformer` dependency from community-cli-plugin

Pull Request resolved: https://github.com/facebook/react-native/pull/49558

Test Plan: - n/a

Reviewed By: robhogan

Differential Revision: D69926109

Pulled By: huntie

fbshipit-source-id: b89b54890248de4954e5c0ce4afe3a5cb5bfa2c1
2025-02-21 08:43:56 -08:00
Phil Pluckthun fd3b911533 chore(community-cli-plugin): Drop shadowed readline module (#49557)
Summary:
While `readline` is referenced in `packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js`, this references the `node:readline` module by default. The extra package seems to have been installed and included accidentally, as the `attachKeyHandlers` file uses an export from `node:readline` that's never been present in `npm:readline`.

Since the name matches but Node.js will always prefer built-in/code modules, this dependency is dangling and can never be reached, since it's name is shadowed (as also stated in their readme). This can be reproduced by comparing `require('readline')` and `require('../../node_modules/readline')` in `packages/community-cli-plugin`. The flow types also confirm this.

This overall seems highly safe to drop.

## Changelog:

[INTERNAL] [CHANGED] - Remove shadowed and unused readline npm package from community-cli-plugin

Pull Request resolved: https://github.com/facebook/react-native/pull/49557

Test Plan:
Prior to changes applied:

```sh
$ node -e 'console.log(require("readline") === require("node:readline"))'
true
```

Reviewed By: cipolleschi

Differential Revision: D69925999

Pulled By: huntie

fbshipit-source-id: 802fdaa396630b44d5aacefeb9c2473fb53d167e
2025-02-21 05:56:51 -08:00
Rob Hogan cdaa1aa9aa community-cli-plugin: resolve cli-server-api via peer dependency on cli (#49518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49518

`react-native/community-cli-plugin` depends on `createDevServerMiddleware` from `react-native-community/cli-server-api`.

`react-native/community-cli-plugin` currently [declares an optional peer dependency](https://github.com/facebook/react-native/blob/bae895500052bda2f55e1832b0c8a63a1b449de3/packages/community-cli-plugin/package.json#L39-L45) on `react-native-community/cli-server-api`, however because the latter isn't a dependency of `react-native` or the community template, the peer dependency is not available to package managers that enforce isolated node_modules - see https://github.com/facebook/react-native/issues/47309.

Rather than add an unnecessary dependency to the template (like [this](https://github.com/react-native-community/template/pull/105)), my proposal is to switch to a peer dependency on only `react-native-community/cli`, because that *is* a dependency of the community template and therefore will be resolvable.

Because `react-native-community/cli` doesn't re-export `createDevServerMiddleware` from its dependency on `cli-server-api`, we need to resolve the latter through the former. This can be cleaned up once a re-export lands - https://github.com/react-native-community/cli/pull/2605.

Changelog:
[GENERAL][FIXED] Fix registering of `start` and `bundle` commands with community CLI and isolated node_modules.

Reviewed By: huntie

Differential Revision: D69848688

fbshipit-source-id: 009b8ffd43b2ab2d84fcc71e9e48382eb8950bb1
2025-02-19 10:11:03 -08:00
Alex Hunt f940be1caa Remove index.js.flow shim from Node packages (#49461)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49461

Flow now supports Package Exports 🎉. This means we can delete the compatiblity pattern in each of our build-enabled Node.js packages.

This simplifies the internal package structure needed to support Flow while developing from source in the monorepo — no prod impact.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D69741143

fbshipit-source-id: 070715cb6beb00eb393186dbf95856ceb87fabef
2025-02-17 05:44:22 -08:00
Sam Zhou a1eb6de691 Pre-suppress errors ahead of 0.261.1 release in xplat
Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D69610953

fbshipit-source-id: 3eec28d72e26c2f48542523dd610590e298eba69
2025-02-13 13:04:53 -08:00
Panos Vekris 413730ecb3 Back out "Deploy 0.261.0 to xplat"
Summary:
Original commit changeset: cf5953b1afc2

Original Phabricator Diff: D69562137

Reviewed By: SamChou19815

Differential Revision: D69570236

fbshipit-source-id: 7cfa9cf51aa3662d4339e020f8ae5065c8f5c358
2025-02-12 19:14:21 -08:00
Sam Zhou 9a401c8103 Deploy 0.261.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D69562137

fbshipit-source-id: cf5953b1afc242bf2571ad7c4362ef9485d8e846
2025-02-12 18:12:54 -08:00
Alex Hunt 0d66c524cf Restore Metro log streaming via CLI flag (#49353)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49353

This change adds an opt-in to restore JavaScript log streaming via the Metro dev server, [removed from React Native core in 0.77](https://reactnative.dev/blog/2025/01/21/version-0.77#removal-of-consolelog-streaming-in-metro).

Users can opt into this legacy behaviour by adding the `--client-logs` flag to `npx react-native-community/cli start`.

- The default experience remains without streamed JS logs.
- The existing "JavaScript logs have moved! ..." notice is printed in all cases, and we do not advertise the new flag for new users.
- Under non-Community CLI dev servers (i.e. Expo), log streaming is restored implicitly.

We will clean up this functionality again when we eventually remove JS log streaming over `HMRClient`, tasked in T214991636.

**Implementation notes**

- Logs are always sent over `HMRClient` (previous status quo), even with log streaming off in the dev server. This is a necessary evil to be able to flag this functionality in a user-accessible place, and to move fast for 0.78.
- Necessarily, emitting `fusebox_console_notice` moves to the dev server itself, on first device (Fusebox) connection.

Changelog:
[General][Added] - Add opt in for legacy Metro log streaming via `--client-logs` flag

Reviewed By: robhogan

Differential Revision: D69469039

fbshipit-source-id: be99d02a3b1c977a59bf7d2726f0e6cf2e60b28a
2025-02-12 07:17:15 -08:00
Alex Hunt 1cfc53bb70 Improve error log for failed open-debugger fetch (#49295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49295

Motivated by https://github.com/facebook/react-native/issues/49287.

This improves on the less useful output of "fetch failed" currently. We expect failing to make a request to the dev server (made from the dev server!) to be a rare edge case, in which case we want to log as much info as possible.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D69395983

fbshipit-source-id: ee96d72ade5a887d190397c3b798a5b545152587
2025-02-10 06:01:48 -08:00
Alex Hunt e1575857dd Relocate babel-register script (#49102)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49102

Moves this script one level up. In the next diff, will be used to support execution of scripts themselves, as well as `packages/`.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D68960279

fbshipit-source-id: 7b62420c269dc1c1366ac9a827db078d34cb86c5
2025-02-03 03:49:23 -08:00
Alex Hunt bb1e3cdb04 Update cli-server-api middleware imports (#48997)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48997

Follows https://github.com/react-native-community/cli/pull/2584.

- Also add FIXME comment flagging potential core APIs gap without CLI.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68766565

fbshipit-source-id: 60747715f76c4323e306c39ab0613fb4818b4914
2025-01-28 07:11:13 -08:00
Riccardo Cipolleschi e77fe5c471 Bump React Native monorepo packages (#48975)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48975

After cutting 0.78-stable, we need to bump the monorepo packages to `0.79.0-main`

## Changelog:
[Internal] - Bump monorepo packages to `0.79.0-main`

Reviewed By: cortinico, huntie

Differential Revision: D68715005

fbshipit-source-id: cb5abbf05e8638683687be8d61d66b3037111572
2025-01-27 11:01:34 -08:00
Jakub Romanczyk 881d8a720f refactor(community-cli-plugin): use node builtin fetch (#47397)
Summary:
Removed `node-fetch` in favour of node builtin fetch to get rid of the deprecated `punycode` warning when using Node 22.

`react-native/community-cli-plugin` already requires Node >= 18 where it was made available by default (without `--experimental-fetch` flag).

This change is similar to the one made in https://github.com/facebook/react-native/pull/45227

## Changelog:

[GENERAL] [CHANGED] - Drop node-fetch in favor of Node's built-in fetch from undici in `react-native/community-cli-plugin`

Pull Request resolved: https://github.com/facebook/react-native/pull/47397

Test Plan: tests pass

Reviewed By: blakef

Differential Revision: D66512595

Pulled By: NickGerleman

fbshipit-source-id: c4e01baf388f9fae8cea7b4bfe25034bff28b461
2024-11-27 10:39:39 -08:00
Blake Friedman e0be2efe4e fix/cli start (#47450)
Summary:
When decoupling the community-cli-plugin from the react-native-community/cli-server-api (https://github.com/facebook/react-native/issues/45311), a middleware stub was created to allow a runtime stub to be used in this case. This middleware should be used so as not to break when the optional cli-server-api dependency isn't present.

Changelog:
[General][Fixed] - Fix npm react-native start when cli-server-api isn't installed

Pull Request resolved: https://github.com/facebook/react-native/pull/47450

Test Plan:
Forced a runtime exception simulating the package not being dependent and was able to build rn-tester.

![CleanShot 2024-11-06 at 10 49 58@2x](https://github.com/user-attachments/assets/c040ec5b-7000-43bd-ba54-52a672ff3675)

Reviewed By: cipolleschi

Differential Revision: D65532486

Pulled By: blakef

fbshipit-source-id: 2b380607de63ac2da906ef0cb1e48b9ef263cb68
2024-11-06 07:26:30 -08:00
Rob Hogan 0902b0af75 Update Metro to 0.81.0 (#47012)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47012

Update Metro from `0.81.0-alpha.2` to `0.81.0`.

This is also intended to be the final, stable release for RN 0.76.

Changelog:
[General][Changed]: Update Metro to 0.81.0

Reviewed By: blakef

Differential Revision: D64329574

fbshipit-source-id: e12bed356b46e4ed68c75b397b7f9e2228c377be
2024-10-14 10:08:36 -07:00
Alex Hunt 2f07130bb3 Align logIfUpdateAvailable to use resolved RN version from CLI (#46777)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46777

Simplifies this internal logic plus ensures there is one source of truth for `reactNativeVersion` in our CLI plugin. Also, renames the `ctx` variable to `cliConfig`, to more clearly signal that this is an integration point with the Community CLI.

Completes this wave of `community-cli-plugin` simplifications.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D63534247

fbshipit-source-id: bf5779fcf971dee1e0caf58b071df360636c53e9
2024-10-07 05:53:37 -07:00
Alex Hunt 19b971ff94 Remove run on iOS/Android key handlers (#46781)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46781

Implements https://github.com/react-native-community/discussions-and-proposals/discussions/821.

Changelog:
[General][Removed] - Remove "run on iOS" and "run on Android" from the dev server key commands

Reviewed By: cortinico

Differential Revision: D63534248

fbshipit-source-id: 003d4c639bbf9128f921936508a62de2caadac5e
2024-10-03 03:39:04 -07:00