Skip to content

Commit cc16664

Browse files
robhoganfacebook-github-bot
authored andcommitted
Re-export metro-config's resolveConfig from metro
Summary: `react-native-community/cli-plugin-metro` has a dependency on `mergeConfig`, `loadConfig` and `resolveConfig` from `metro-config`, here: https://github.com/react-native-community/cli/blob/v12.0.0-alpha.2/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#L3-L9 Otherwise, `cli-plugin-metro` only has build-time dependencies on `metro-config`. By exporting `resolveConfig` in addition to the other two (which we already re-export), we can remove the `metro-config` runtime dependency and use `metro` instead. That's a step closer to making `metro` a `peerDependency` of `cli-plugin-metro`, with version dictated by the host project's dependency, ultimately decoupling Metro from the CLI. Changelog: ``` * **[Feature]** Re-export `metro-config`'s `resolveConfig` from `metro`. ``` Reviewed By: hoxyq Differential Revision: D44870484 fbshipit-source-id: c38175cac5904b0b9540bab6b4c8e70d957d378e
1 parent d0b8ea5 commit cc16664

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/metro/src/index.flow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ const chalk = require('chalk');
3838
const fs = require('fs');
3939
const http = require('http');
4040
const https = require('https');
41-
const {getDefaultConfig, loadConfig, mergeConfig} = require('metro-config');
41+
const {
42+
getDefaultConfig,
43+
loadConfig,
44+
mergeConfig,
45+
resolveConfig,
46+
} = require('metro-config');
4247
const {InspectorProxy} = require('metro-inspector-proxy');
4348
const net = require('net');
4449
const {parse} = require('url');
@@ -174,6 +179,7 @@ async function runMetro(
174179
exports.runMetro = runMetro;
175180
exports.loadConfig = loadConfig;
176181
exports.mergeConfig = mergeConfig;
182+
exports.resolveConfig = resolveConfig;
177183

178184
const createConnectMiddleware = async function (
179185
config: ConfigT,

packages/metro/types/index.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type {Server as HttpsServer} from 'https';
1919
import type {
2020
ConfigT,
2121
InputConfigT,
22-
loadConfig,
2322
MetroConfig,
2423
Middleware,
2524
} from 'metro-config';
@@ -30,6 +29,8 @@ import Yargs = require('yargs');
3029
import type {default as MetroServer, ServerOptions} from './Server';
3130
import type {OutputOptions, RequestOptions} from './shared/types';
3231

32+
export {loadConfig, mergeConfig, resolveConfig} from 'metro-config';
33+
3334
export {HttpServer, HttpsServer};
3435

3536
interface MetroMiddleWare {
@@ -114,8 +115,6 @@ export function runMetro(
114115
options?: RunMetroOptions,
115116
): Promise<MetroServer>;
116117

117-
export {loadConfig};
118-
119118
export function createConnectMiddleWare(
120119
config: ConfigT,
121120
options?: RunMetroOptions,

0 commit comments

Comments
 (0)