Skip to content

Commit

Permalink
Expose MetroConfig type in metro package
Browse files Browse the repository at this point in the history
Summary:
Pairs with D44416426. Slightly simplifies user setup when we decide to use this.

```diff
- /** type {import('metro-config').MetroConfig} */
+ /** type {import('metro').MetroConfig} */
  const config = { ... };
```

Changelog: **[Types]** Expose `MetroConfig` type in `metro` package

Reviewed By: motiz88

Differential Revision: D44540077

fbshipit-source-id: 03fa91ffcdc054cb898a7739680366d7d0b31217
  • Loading branch information
huntie authored and facebook-github-bot committed Mar 30, 2023
1 parent 07732e7 commit d2f3664
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/metro/src/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {Server as HttpsServer} from 'https';
import type {
ConfigT,
InputConfigT,
MetroConfig,
Middleware,
} from 'metro-config/src/configTypes.flow';
import type {CustomTransformOptions} from 'metro-transform-worker';
Expand Down Expand Up @@ -120,6 +121,8 @@ export type RunBuildOptions = {
type BuildCommandOptions = {} | null;
type ServeCommandOptions = {} | null;

export type {MetroConfig};

async function getConfig(config: InputConfigT): Promise<ConfigT> {
const defaultConfig = await getDefaultConfig(config.projectRoot);
return mergeConfig(defaultConfig, config);
Expand Down
10 changes: 9 additions & 1 deletion packages/metro/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export * from './lib/reporting';

import type {Server as HttpServer} from 'http';
import type {Server as HttpsServer} from 'https';
import type {ConfigT, InputConfigT, loadConfig, Middleware} from 'metro-config';
import type {
ConfigT,
InputConfigT,
loadConfig,
MetroConfig,
Middleware,
} from 'metro-config';
import type {CustomTransformOptions} from 'metro-babel-transformer';
import type {ReadOnlyGraph} from './DeltaBundler/types';
import type {Server} from 'ws';
Expand Down Expand Up @@ -101,6 +107,8 @@ interface BuildGraphOptions {
type?: 'module' | 'script';
}

export {MetroConfig};

export function runMetro(
config: InputConfigT,
options?: RunMetroOptions,
Expand Down

0 comments on commit d2f3664

Please sign in to comment.