-
Notifications
You must be signed in to change notification settings - Fork 904
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
feat: add a programmatic dev server API #1118
Conversation
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.
Lovely, no Metro deps in server API!
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.
@Esemesek mind taking a look?
At @thymikee's suggestion, I've split this PR up so it only includes the new |
Published as a part of v4.8.0 |
Summary:
I work on Expo CLI, which uses React Native CLI to start the development server. Previously, we've done this by starting RN CLI as a subprocess. This has had some challenges, including slower boot-up time because we need to start another Node process, possibility to end up with a killed or zombie processes if there's an unhandled error, and having to parse all logs from JSON in stdout.
This PR refactors the
react-native start
command and introduces a new package@react-native-community/dev-server-api
, which includes a programmatic interface for starting the dev server middleware and WebSocket servers used by React Native. This allows tools like Expo CLI to interface with Metro directly and then attach the additional features provided by React Native CLI to the Metro HTTP server. (expo/expo-cli#1845 will make use of this package).Test Plan:
I have followed the Testing your changes instructions in
CONTRIBUTING.md
and started the dev server withnpx react-native start --watchFolders /Users/ville/Projects/react-native-cli/ --resetCache
. After starting the server, I've verified the following features work:r