Skip to content

Commit

Permalink
fix(cli): sync latest upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Sep 21, 2023
1 parent f752ad3 commit baca983
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-dryers-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/cli": patch
---

Synced latest changes from upstream: https://github.com/facebook/react-native/commit/982f6f99d43b21b3a81d3388591934d6f83afa63
1 change: 1 addition & 0 deletions packages/cli/src/serve/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type DevMiddlewareAPI = {

type DevMiddlewareOptions = {
projectRoot: string;
serverBaseUrl: string;
logger?: typeof logger;
unstable_browserLauncher?: unknown;
unstable_eventReporter?: unknown;
Expand Down
21 changes: 7 additions & 14 deletions packages/cli/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,18 @@ export async function rnxStart(
// create middleware -- a collection of plugins which handle incoming
// http(s) requests, routing them to static pages or JS functions.
const host = args.host?.length ? args.host : "localhost";
const devServerUrl = `${scheme}://${host}:${port}`;
const devServer = createDevServerMiddleware({ host, port, watchFolders });

const coreDevMiddleware = (() => {
try {
// https://github.com/facebook/react-native/blob/3e7a873f2d1c5170a7f4c88064897e74a149c5d5/packages/community-cli-plugin/src/commands/start/runServer.js#L115
// https://github.com/facebook/react-native/blob/7888338295476f4d4f00733309e54b8d22318e1e/packages/community-cli-plugin/src/commands/start/runServer.js#L115
const { createDevMiddleware } = requireExternal(
"@react-native/dev-middleware"
);
return createDevMiddleware({
projectRoot,
serverBaseUrl: devServerUrl,
logger,
unstable_experiments: {
// NOTE: Only affects the /open-debugger endpoint
Expand Down Expand Up @@ -157,19 +159,15 @@ export async function rnxStart(
reportEventDelegate = devServer.eventsSocketEndpoint.reportEvent;
}

const printHelp = makeHelp(terminal, {
hasDebugger: Boolean(coreDevMiddleware),
});
const help = makeHelp(terminal, { hasDebugger: Boolean(coreDevMiddleware) });

// @ts-expect-error We want to override `reporter`
metroConfig.reporter = {
update(event: ReportableEvent) {
terminalReporter.update(event);
if (reportEventDelegate) {
reportEventDelegate(event);
}
reportEventDelegate?.(event);
if (interactive && event.type === "dep_graph_loading") {
printHelp();
help();
}
},
};
Expand Down Expand Up @@ -222,11 +220,6 @@ export async function rnxStart(
// in interactive mode, listen for keyboard events from stdin and bind
// them to specific actions.
if (interactive) {
attachKeyHandlers({
devServerUrl: `${scheme}://${host}:${port}`,
help: printHelp,
messageSocketEndpoint,
terminal,
});
attachKeyHandlers({ devServerUrl, help, messageSocketEndpoint, terminal });
}
}

0 comments on commit baca983

Please sign in to comment.