Skip to content

Commit b26baae

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Move Community CLI discovery config into plugin package (1/2) (#58670)
Summary: Replaces #57352. Self-register commands from the `community-cli-plugin` package via `react-native.config.js` — meaning we can remove the redirect within `packages/react-native/react-native.config.js`. Progress towards removing `community-cli-plugin` as a direct dep of `react-native`, and paired with react-native-community/template#235. RNTester and HelloWorld list `react-native/community-cli-plugin` in `devDependencies`, as the template now does (react-native-community/template#235). Changelog: [General][Breaking] - `react-native/community-cli-plugin` will no longer be auto-detected from `react-native`. It must now be specified in `devDependencies`. Pull Request resolved: #58670 Test Plan: Compared `react-native config` output with `react-native-community/cli` 20.2.0. **RNTester** - ✅ Commands, platforms, and project config are unchanged from `main` - ✅ Removing the new `react-native/community-cli-plugin` devDependency drops `bundle`, `start`, `spm`, and `codegen`, so they are registered by plugin discovery **Template-shaped app** (plugin in `devDependencies`, no project `react-native.config.js`) - ✅ `bundle`, `start`, `spm`, and `codegen` are registered Reviewed By: christophpurrer, cortinico Differential Revision: D121634885 Pulled By: Abbondanzo fbshipit-source-id: e97c9f820d3c597233ef4a7ddaaf1b752f1f7688
1 parent 4b7f248 commit b26baae

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

‎packages/community-cli-plugin/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
}
2626
},
2727
"files": [
28-
"dist"
28+
"dist",
29+
"react-native.config.js"
2930
],
3031
"scripts": {
3132
"prepack": "node ../../scripts/build/prepack.js"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @noflow
9+
*/
10+
11+
const {
12+
bundleCommand,
13+
codegenCommand,
14+
spmCommand,
15+
startCommand,
16+
} = require('@react-native/community-cli-plugin');
17+
18+
module.exports = {
19+
commands: [bundleCommand, startCommand, spmCommand, codegenCommand],
20+
};

‎packages/react-native/react-native.config.js‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ import type {Command} from '@react-native-community/cli-types';
1717
// IMPORTANT: This is a routing file only. Do NOT add new command
1818
// definitions or implementations here.
1919
//
20-
// New CLI commands belong in @react-native/community-cli-plugin, and
21-
// may (temporarily) be imported and registered here.
20+
// CLI commands belong in @react-native/community-cli-plugin, which registers
21+
// them via its own react-native.config.js.
2222
//
2323
// Future state: The Community Template should directly depend on and inject:
2424
// - @react-native-community/cli-platform-android
2525
// - @react-native-community/cli-platform-ios
26-
// - @react-native/community-cli-plugin
2726

2827
const verbose = Boolean(process.env.DEBUG?.includes('react-native'));
2928

@@ -72,15 +71,6 @@ try {
7271

7372
const commands /*: Array<Command> */ = [];
7473

75-
const {
76-
bundleCommand,
77-
codegenCommand,
78-
spmCommand,
79-
startCommand,
80-
} = require('@react-native/community-cli-plugin');
81-
82-
commands.push(bundleCommand, startCommand, spmCommand, codegenCommand);
83-
8474
const config = {
8575
commands,
8676
platforms: {} /*:: as {[string]: Readonly<{

‎packages/rn-tester/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@react-native-community/cli": "20.2.0",
6363
"@react-native-community/cli-platform-android": "20.2.0",
6464
"@react-native-community/cli-platform-ios": "20.2.0",
65+
"@react-native/community-cli-plugin": "0.87.0-main",
6566
"@react-native/core-cli-utils": "*",
6667
"commander": "^12.0.0",
6768
"listr2": "^6.4.1",

‎private/helloworld/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@babel/preset-env": "^7.25.3",
2121
"@babel/runtime": "^7.25.0",
2222
"@react-native/babel-preset": "0.87.0-main",
23+
"@react-native/community-cli-plugin": "0.87.0-main",
2324
"@react-native/core-cli-utils": "*",
2425
"@react-native/eslint-config": "0.87.0-main",
2526
"@react-native/jest-preset": "0.87.0-main",

0 commit comments

Comments
 (0)