From c6827dbdfb349862b0168111c27f5b90746d0f57 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 26 Jun 2026 12:10:40 -0700 Subject: [PATCH 1/2] Move Community CLI discovery config into plugin package --- packages/community-cli-plugin/package.json | 3 ++- .../react-native.config.js | 20 +++++++++++++++++++ packages/react-native/react-native.config.js | 14 ++----------- packages/rn-tester/package.json | 1 + private/helloworld/package.json | 1 + 5 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 packages/community-cli-plugin/react-native.config.js diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json index c780f698a964..b320c0db5b88 100644 --- a/packages/community-cli-plugin/package.json +++ b/packages/community-cli-plugin/package.json @@ -25,7 +25,8 @@ } }, "files": [ - "dist" + "dist", + "react-native.config.js" ], "scripts": { "prepack": "node ../../scripts/build/prepack.js" diff --git a/packages/community-cli-plugin/react-native.config.js b/packages/community-cli-plugin/react-native.config.js new file mode 100644 index 000000000000..4bb3ce15d721 --- /dev/null +++ b/packages/community-cli-plugin/react-native.config.js @@ -0,0 +1,20 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @noflow + */ + +const { + bundleCommand, + codegenCommand, + spmCommand, + startCommand, +} = require('@react-native/community-cli-plugin'); + +module.exports = { + commands: [bundleCommand, startCommand, spmCommand, codegenCommand], +}; diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js index 36cc09508d4a..9683c019136c 100644 --- a/packages/react-native/react-native.config.js +++ b/packages/react-native/react-native.config.js @@ -17,13 +17,12 @@ import type {Command} from '@react-native-community/cli-types'; // IMPORTANT: This is a routing file only. Do NOT add new command // definitions or implementations here. // -// New CLI commands belong in @react-native/community-cli-plugin, and -// may (temporarily) be imported and registered here. +// CLI commands belong in @react-native/community-cli-plugin, which registers +// them via its own react-native.config.js. // // Future state: The Community Template should directly depend on and inject: // - @react-native-community/cli-platform-android // - @react-native-community/cli-platform-ios -// - @react-native/community-cli-plugin const verbose = Boolean(process.env.DEBUG?.includes('react-native')); @@ -72,15 +71,6 @@ try { const commands /*: Array */ = []; -const { - bundleCommand, - codegenCommand, - spmCommand, - startCommand, -} = require('@react-native/community-cli-plugin'); - -commands.push(bundleCommand, startCommand, spmCommand, codegenCommand); - const config = { commands, platforms: {} /*:: as {[string]: Readonly<{ diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json index 0f4a2b6e888e..a5580e8ecd0b 100644 --- a/packages/rn-tester/package.json +++ b/packages/rn-tester/package.json @@ -62,6 +62,7 @@ "@react-native-community/cli": "20.2.0", "@react-native-community/cli-platform-android": "20.2.0", "@react-native-community/cli-platform-ios": "20.2.0", + "@react-native/community-cli-plugin": "0.87.0-main", "@react-native/core-cli-utils": "*", "commander": "^12.0.0", "listr2": "^6.4.1", diff --git a/private/helloworld/package.json b/private/helloworld/package.json index 60a9176d6104..f8a9791217c5 100644 --- a/private/helloworld/package.json +++ b/private/helloworld/package.json @@ -20,6 +20,7 @@ "@babel/preset-env": "^7.25.3", "@babel/runtime": "^7.25.0", "@react-native/babel-preset": "0.87.0-main", + "@react-native/community-cli-plugin": "0.87.0-main", "@react-native/core-cli-utils": "*", "@react-native/eslint-config": "0.87.0-main", "@react-native/jest-preset": "0.87.0-main", From c98e0c36df42da8aad56e8c5cef108e0b4ba6a54 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 26 Jun 2026 12:10:40 -0700 Subject: [PATCH 2/2] Remove Community CLI platform config (upstreamed) --- packages/react-native/package.json | 1 - packages/react-native/react-native.config.js | 98 -------------------- packages/rn-tester/react-native.config.js | 5 - 3 files changed, 104 deletions(-) delete mode 100644 packages/react-native/react-native.config.js diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 2242dfb096b7..f4586b0340c8 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -78,7 +78,6 @@ "LICENSE", "React-Core.podspec", "React-Core-prebuilt.podspec", - "react-native.config.js", "React.podspec", "React", "!React/Fabric/RCTThirdPartyFabricComponentsProvider.*", diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js deleted file mode 100644 index 9683c019136c..000000000000 --- a/packages/react-native/react-native.config.js +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict-local - * @format - */ - -'use strict'; - -/*:: -import type {Command} from '@react-native-community/cli-types'; - */ - -// IMPORTANT: This is a routing file only. Do NOT add new command -// definitions or implementations here. -// -// CLI commands belong in @react-native/community-cli-plugin, which registers -// them via its own react-native.config.js. -// -// Future state: The Community Template should directly depend on and inject: -// - @react-native-community/cli-platform-android -// - @react-native-community/cli-platform-ios - -const verbose = Boolean(process.env.DEBUG?.includes('react-native')); - -function findCommunityPlatformPackage( - spec /*: string */, - startDir /*: string */ = process.cwd(), -) { - // In monorepos, we cannot make any assumptions on where - // `@react-native-community/*` gets installed. The safest way to find it - // (barring adding an optional peer dependency) is to start from the project - // root. - // - // Note that we're assuming that the current working directory is the project - // root. This is also what `@react-native-community/cli` assumes (see - // https://github.com/react-native-community/cli/blob/14.x/packages/cli-tools/src/findProjectRoot.ts). - const main = require.resolve(spec, {paths: [startDir]}); - // $FlowFixMe[unsupported-syntax] - return require(main); -} - -let android; -try { - android = findCommunityPlatformPackage( - '@react-native-community/cli-platform-android', - ); -} catch { - if (verbose) { - console.warn( - '@react-native-community/cli-platform-android not found, the react-native.config.js may be unusable.', - ); - } -} - -let ios; -try { - ios = findCommunityPlatformPackage( - '@react-native-community/cli-platform-ios', - ); -} catch { - if (verbose) { - console.warn( - '@react-native-community/cli-platform-ios not found, the react-native.config.js may be unusable.', - ); - } -} - -const commands /*: Array */ = []; - -const config = { - commands, - platforms: {} /*:: as {[string]: Readonly<{ - projectConfig: unknown, - dependencyConfig: unknown, - }>} */, -}; - -if (ios != null) { - config.commands.push(...ios.commands); - config.platforms.ios = { - projectConfig: ios.projectConfig, - dependencyConfig: ios.dependencyConfig, - }; -} - -if (android != null) { - config.commands.push(...android.commands); - config.platforms.android = { - projectConfig: android.projectConfig, - dependencyConfig: android.dependencyConfig, - }; -} - -module.exports = config; diff --git a/packages/rn-tester/react-native.config.js b/packages/rn-tester/react-native.config.js index 7b54b0d7d5cc..e9f01951ac09 100644 --- a/packages/rn-tester/react-native.config.js +++ b/packages/rn-tester/react-native.config.js @@ -10,12 +10,7 @@ 'use strict'; -// Inside the React Native monorepo, we need to explicitly extend the base -// CLI config as the adjacent package will not be conventionally discovered. -const config = require('../react-native/react-native.config.js'); - module.exports = { - ...config, reactNativePath: '../react-native', project: { ios: {