Skip to content

Commit

Permalink
Deprecate server.enhanceMiddleware option
Browse files Browse the repository at this point in the history
Summary:
Marks the `server.enhanceMiddleware` config option as deprecated.

This follows a review of this option's design:
- **Usage pitfall**: Extending Metro's builtin middleware by using the `metroMiddleware` arg is unclear/unergonomic (though now documented in D46228146).
- **Wrong location for this capability**: More importantly, the need to attach custom `connect` middleware at the level of Metro's config feels incorrect. This is an option for dev servers which use Metro, and can instead be configured — with more precision — when these consumers access Metro via its `runMetro` API.

Changelog: **[Deprecation]** Deprecate `server.enhanceMiddleware` option

Reviewed By: motiz88

Differential Revision: D46356577

fbshipit-source-id: 5486546390c0f750767353d8ac7408be624261e1
  • Loading branch information
huntie authored and facebook-github-bot committed Jun 2, 2023
1 parent d20d7c8 commit 22e85fd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Type: `boolean`
Whether we should enable CMD+R hotkey for refreshing the bundle.
#### `enhanceMiddleware`
#### `enhanceMiddleware` <div class="label deprecated">Deprecated</div>
Type: `(Middleware, MetroServer) => Middleware`
Expand Down
1 change: 1 addition & 0 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type MetalConfigT = {
};

type ServerConfigT = {
/** @deprecated */
enhanceMiddleware: (Middleware, MetroServer) => Middleware | Server,
port: number,
rewriteRequestUrl: string => string,
Expand Down
1 change: 1 addition & 0 deletions packages/metro-config/types/configTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export interface MetalConfigT {
}

export interface ServerConfigT {
/** @deprecated */
enhanceMiddleware: (
metroMiddleware: Middleware,
metroServer: MetroServer,
Expand Down

0 comments on commit 22e85fd

Please sign in to comment.