Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .nx/version-plans/version-plan-1772810670470.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
__default__: patch
---

Add a new host option to rn-harness.config for Metro bind host, replacing HARNESS_METRO_BIND_HOST.
6 changes: 6 additions & 0 deletions packages/bundler-metro/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ export const getMetroInstance = async (
.use('/status', getStatusMiddleware(projectRoot));

const ready = waitForBundler(reporter, abortSignal);
const metroBindHost = harnessConfig.host?.trim();
if (metroBindHost) {
logger.debug(`Binding Metro server to host ${metroBindHost}`);
}

const maybeServer = await Metro.runServer(config, {
waitForBundler: true,
unstable_extraMiddleware: [middleware],
...(metroBindHost ? { host: metroBindHost } : {}),
});

// Metro <0.83 returns the server directly, while 0.83+ returns an object with the server as a property.
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ConfigSchema = z
.min(1, 'App registry component name is required'),
runners: z.array(RunnerSchema).min(1, 'At least one runner is required'),
defaultRunner: z.string().optional(),
host: z.string().min(1, 'Host is required').optional(),
webSocketPort: z.number().optional().default(3001),
bridgeTimeout: z
.number()
Expand Down
1 change: 1 addition & 0 deletions website/src/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ For Expo projects, the `entryPoint` should be set to the path specified in the `
| `appRegistryComponentName` | **Required.** Name of the component registered with AppRegistry. |
| `runners` | **Required.** Array of test runners (at least one required). |
| `defaultRunner` | Default runner to use when none specified. |
| `host` | Hostname or IP address to bind the Metro server to (default: Metro default). |
| `bridgeTimeout` | Bridge timeout in milliseconds (default: `60000`). |
| `bundleStartTimeout` | Bundle start timeout in milliseconds (default: `15000`). |
| `maxAppRestarts` | Maximum number of app restarts when app fails to report ready (default: `2`). |
Expand Down