Skip to content

Commit

Permalink
Remove @react-native-community/cli direct dependencies (facebook#45927)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#45927

This was attempted earlier in the year, and was unsuccessful because HelloWorld had a hidden dependency on this.

Changelog: [General][Breaking] Projects that intend to use the community CLI will now have to declare that dependency instead of transitively having the react-native package handle this.

Differential Revision: D60898346
  • Loading branch information
blakef authored and facebook-github-bot committed Aug 12, 2024
1 parent 175943f commit 7e41832
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 174 deletions.
3 changes: 0 additions & 3 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
"@react-native-community/cli": "14.0.0",
"@react-native-community/cli-platform-android": "14.0.0",
"@react-native-community/cli-platform-ios": "14.0.0",
"@react-native/assets-registry": "0.76.0-main",
"@react-native/codegen": "0.76.0-main",
"@react-native/community-cli-plugin": "0.76.0-main",
Expand Down
31 changes: 26 additions & 5 deletions packages/react-native/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,29 @@ try {
}
}

const {
bundleCommand,
startCommand,
} = require('@react-native/community-cli-plugin');
const commands = [];

try {
const {
bundleCommand,
startCommand,
} = require('@react-native/community-cli-plugin');
commands.push(bundleCommand, startCommand);
} catch (e) {
const known =
e.code === 'MODULE_NOT_FOUND' &&
e.message.includes('@react-native-community/cli-server-api');

if (!known) {
throw e;
}

if (verbose) {
console.warn(
'@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
);
}
}

const codegenCommand = {
name: 'codegen',
Expand Down Expand Up @@ -74,8 +93,10 @@ const codegenCommand = {
),
};

commands.push(codegenCommand);

const config = {
commands: [bundleCommand, startCommand, codegenCommand],
commands,
platforms: {},
};

Expand Down
10 changes: 7 additions & 3 deletions packages/rn-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"clean-ios": "rm -rf build/generated/ios Pods Podfile.lock"
},
"dependencies": {
"@react-native/oss-library-example": "0.76.0-main",
"@react-native/popup-menu-android": "0.76.0-main",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
"nullthrows": "^1.1.1",
"@react-native/oss-library-example": "0.76.0-main",
"@react-native/popup-menu-android": "0.76.0-main"
"nullthrows": "^1.1.1"
},
"peerDependencies": {
"react": "19.0.0-rc-fb9a90fa48-20240614",
Expand All @@ -40,5 +40,9 @@
"android": {
"javaPackageName": "com.facebook.fbreact.specs"
}
},
"devDependencies": {
"@react-native-community/cli-platform-android": "^14.0.0",
"@react-native-community/cli-platform-ios": "^14.0.0"
}
}
Loading

0 comments on commit 7e41832

Please sign in to comment.