Skip to content

Commit

Permalink
Re-export metro-core's Terminal from metro
Browse files Browse the repository at this point in the history
Summary:
Following D44870484 with the goal of decoupling RN CLI from an exact Metro version - `react-native-community/cli` wraps `Terminal` for its `reporter` implementation when starting Metro server, here:

https://github.com/react-native-community/cli/blob/v12.0.0-alpha.2/packages/cli-plugin-metro/src/commands/start/runServer.ts#L45-L47

This is the only dependency `cli-plugin-metro` has on `metro-core` - by re-exporting it from `metro` we can [remove a dependency](https://github.com/react-native-community/cli/blob/v12.0.0-alpha.2/packages/cli-plugin-metro/package.json#L16) from the CLI.

Changelog:
```
* **[Feature]** Re-export `metro-config`'s `resolveConfig` from `metro`.
```

Reviewed By: hoxyq

Differential Revision: D44870838

fbshipit-source-id: 94baf444f495439e45ff77340601afd6900bbc3f
  • Loading branch information
robhogan authored and facebook-github-bot committed Apr 11, 2023
1 parent cc16664 commit 86e3f93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/metro/src/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const {
mergeConfig,
resolveConfig,
} = require('metro-config');
const {Terminal} = require('metro-core');
const {InspectorProxy} = require('metro-inspector-proxy');
const net = require('net');
const {parse} = require('url');
Expand Down Expand Up @@ -126,6 +127,8 @@ export type RunBuildOptions = {
type BuildCommandOptions = {} | null;
type ServeCommandOptions = {} | null;

exports.Terminal = Terminal;

export type {MetroConfig};

async function getConfig(config: InputConfigT): Promise<ConfigT> {
Expand Down
1 change: 1 addition & 0 deletions packages/metro/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type {default as MetroServer, ServerOptions} from './Server';
import type {OutputOptions, RequestOptions} from './shared/types';

export {loadConfig, mergeConfig, resolveConfig} from 'metro-config';
export {Terminal} from 'metro-core';

export {HttpServer, HttpsServer};

Expand Down

0 comments on commit 86e3f93

Please sign in to comment.