-
Notifications
You must be signed in to change notification settings - Fork 149
Remove react-native commands from cli when installed as 'react-native-macos' #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…en installed as `react-native-macos`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be:
const ios = require('@react-native-community/cli-platform-ios');
const android = require('@react-native-community/cli-platform-android');
// Remove commands so that react-native-macos can coexist with react-native in repos that depend on both.
const path = require("path");
const isReactNativeMacOS = path.basename(__dirname) === 'react-native-macos';
module.exports = isReactNativeMacOS ? {} : {
commands: [...ios.commands, ...android.commands],
platforms: {
ios: {
linkConfig: ios.linkConfig,
projectConfig: ios.projectConfig,
dependencyConfig: ios.dependencyConfig,
},
android: {
linkConfig: android.linkConfig,
projectConfig: android.projectConfig,
dependencyConfig: android.dependencyConfig,
},
},
/**
* Used when running RNTester (with React Native from source)
*/
reactNativePath: '.',
project: {
ios: {
project: './RNTester/RNTester.xcodeproj',
},
android: {
sourceDir: './RNTester',
},
},
};
Ya, that makes more sense. When we eventually have mac CLI it will have to be a non-empty object but will have nothing shared with ios or android. |
Actually, it doesn't work. If I have an empty exports for mac, then metro fails to bundle for mac. Its probably pointing out some other problem. The min that has to be present is
|
Doesn't totally surprise me. I suspect you are piggy backing on the ios stuff more than we should long term. |
Yes. For now I want to go with this fix as-is and detangle the iOS dependency separately. |
|
||
module.exports = { | ||
commands: [...ios.commands, ...android.commands], | ||
commands: [...iosCommands, ...androidCommands], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need a ...macCommands here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will, but mac commands don't exist yet. We have to create a @react-native-community/cli-platform-macos
package first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, the commands can be in this repo. No need to make that a separate repo. Windows implements its commands within react-native-windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason the android and ios ones are separate is so that the community can handle the PRs etc without waiting on facebook, since facebook doesn't use the cli.
Please select one of the following
When react-native-macos is installed alongside react-native in a repo, the react-native CLI scripts will discover both installations and run commands twice. The react-native.config.js file will eventually refer to macos commands once we have an implementation for them. In the meantime, and as long as react-native-macos is a fork of facebook/react-native, it is still useful to use the ios and android CLI locally for testing purposes. But when installed in another repo, such as any of the react-native-community repos along side facebook react-native, we cannot allow the CLI commands to execute twice for each installation.
In react-native.config.js, check the basename of __dirname and if it is 'react-native-macos' as it will be when installed in a 'node_modules' folder, then use empty command arrays for ios and android.
react-native-webview will be the first react-native-community repo that will need this fix in order to preserve
react-native run-ios
andreact-native run-android
functionality (see react-native-webview/react-native-webview#1164)Microsoft Reviewers: Open in CodeFlow