Skip to content

Commit

Permalink
Remove runInspectorProxy option
Browse files Browse the repository at this point in the history
Summary:
In preparation to relocate `metro-inspector-proxy` into the React Native repo, this PR removes the `runInspectorProxy` option from Metro's server, as a config option, and as a dependency of the `metro` package. This is a breaking change, where we now intend for dev servers that wrap Metro to mount this WebSocket middleware externally.

The `runInspectorProxy` option is unused today by RN CLI, Expo CLI, `rnx-kit`.

Changelog: **[Breaking]** Remove `runInspectorProxy` option from server

Reviewed By: motiz88

Differential Revision: D48066221

fbshipit-source-id: ce12ddbc1420bab9ddf47b1232433c1bc671c590
  • Loading branch information
huntie authored and facebook-github-bot committed Aug 4, 2023
1 parent fbdd295 commit 2b0b15d
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 41 deletions.
6 changes: 0 additions & 6 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,6 @@ Type: `string => string`
A function that will be called every time Metro processes a URL, after normalization of non-standard query-string delimiters using [`jsc-safe-url`](https://www.npmjs.com/package/jsc-safe-url). Metro will use the return value of this function as if it were the original URL provided by the client. This applies to all incoming HTTP requests (after any custom middleware), as well as bundle URLs in `/symbolicate` request payloads and within the hot reloading protocol.
#### `runInspectorProxy`
Type: `boolean` (default: `true`)
Run Inspector Proxy server inside Metro to be able to inspect React Native code.
---
### Watcher Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ Object {
"enhanceMiddleware": [Function],
"port": 8081,
"rewriteRequestUrl": [Function],
"runInspectorProxy": true,
"unstable_serverRoot": null,
"useGlobalHotkey": true,
"verifyConnections": false,
Expand Down Expand Up @@ -279,7 +278,6 @@ Object {
"enhanceMiddleware": [Function],
"port": 8081,
"rewriteRequestUrl": [Function],
"runInspectorProxy": true,
"unstable_serverRoot": null,
"useGlobalHotkey": true,
"verifyConnections": false,
Expand Down Expand Up @@ -457,7 +455,6 @@ Object {
"enhanceMiddleware": [Function],
"port": 8081,
"rewriteRequestUrl": [Function],
"runInspectorProxy": true,
"unstable_serverRoot": null,
"useGlobalHotkey": true,
"verifyConnections": false,
Expand Down Expand Up @@ -635,7 +632,6 @@ Object {
"enhanceMiddleware": [Function],
"port": 8081,
"rewriteRequestUrl": [Function],
"runInspectorProxy": true,
"unstable_serverRoot": null,
"useGlobalHotkey": true,
"verifyConnections": false,
Expand Down
2 changes: 0 additions & 2 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ type ServerConfigT = {
enhanceMiddleware: (Middleware, MetroServer) => Middleware | Server,
port: number,
rewriteRequestUrl: string => string,
runInspectorProxy: boolean,
unstable_serverRoot: ?string,
useGlobalHotkey: boolean,
verifyConnections: boolean,
Expand Down Expand Up @@ -262,7 +261,6 @@ export type YargArguments = $ReadOnly<{
transformer?: string,
'reset-cache'?: boolean,
resetCache?: boolean,
runInspectorProxy?: boolean,
verbose?: boolean,
...
}>;
1 change: 0 additions & 1 deletion packages/metro-config/src/defaults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const getDefaultValues = (projectRoot: ?string): ConfigT => ({
enhanceMiddleware: (middleware, _) => middleware,
port: 8081,
rewriteRequestUrl: url => url,
runInspectorProxy: true,
unstable_serverRoot: null,
useGlobalHotkey: true,
verifyConnections: false,
Expand Down
6 changes: 0 additions & 6 deletions packages/metro-config/src/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ function overrideConfigWithArguments(
output.server.port = Number(argv.port);
}

if (argv.runInspectorProxy != null) {
// $FlowFixMe[incompatible-use]
// $FlowFixMe[cannot-write]
output.server.runInspectorProxy = Boolean(argv.runInspectorProxy);
}

if (argv.projectRoot != null) {
output.projectRoot = argv.projectRoot;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/metro-config/types/configTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export interface ServerConfigT {
) => Middleware | Server;
port: number;
rewriteRequestUrl: (url: string) => string;
runInspectorProxy: boolean;
unstable_serverRoot: string | null;
useGlobalHotkey: boolean;
verifyConnections: boolean;
Expand Down Expand Up @@ -251,6 +250,5 @@ export interface YargArguments {
transformer?: string;
'reset-cache'?: boolean;
resetCache?: boolean;
runInspectorProxy?: boolean;
verbose?: boolean;
}
1 change: 0 additions & 1 deletion packages/metro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"metro-config": "0.77.0",
"metro-core": "0.77.0",
"metro-file-map": "0.77.0",
"metro-inspector-proxy": "0.77.0",
"metro-minify-terser": "0.77.0",
"metro-resolver": "0.77.0",
"metro-runtime": "0.77.0",
Expand Down
18 changes: 0 additions & 18 deletions packages/metro/src/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const {
resolveConfig,
} = require('metro-config');
const {Terminal} = require('metro-core');
const {InspectorProxy} = require('metro-inspector-proxy');
const net = require('net');
const {parse} = require('url');

Expand All @@ -68,7 +67,6 @@ export type RunServerOptions = $ReadOnly<{
host?: string,
onError?: (Error & {code?: string}) => void,
onReady?: (server: HttpServer | HttpsServer) => void,
runInspectorProxy?: boolean,
secureServerOptions?: Object,
secure?: boolean, // deprecated
secureCert?: string, // deprecated
Expand Down Expand Up @@ -281,11 +279,6 @@ exports.runServer = async (
serverApp.use(handler);
}

let inspectorProxy: ?InspectorProxy = null;
if (config.server.runInspectorProxy) {
inspectorProxy = new InspectorProxy(config.projectRoot);
}

let httpServer;

if (secure || secureServerOptions != null) {
Expand Down Expand Up @@ -322,9 +315,6 @@ exports.runServer = async (

websocketEndpoints = {
...websocketEndpoints,
...(inspectorProxy
? {...inspectorProxy.createWebSocketListeners(httpServer)}
: {}),
'/hot': createWebsocketServer({
websocketServer: new MetroHmrServer(
metroServer.getBundler(),
Expand All @@ -350,14 +340,6 @@ exports.runServer = async (
}
});

if (inspectorProxy) {
// TODO(hypuk): Refactor inspectorProxy.processRequest into separate request handlers
// so that we could provide routes (/json/list and /json/version) here.
// Currently this causes Metro to give warning about T31407894.
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
serverApp.use(inspectorProxy.processRequest.bind(inspectorProxy));
}

resolve(httpServer);
});

Expand Down
1 change: 0 additions & 1 deletion packages/metro/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface RunServerOptions {
host?: string;
onError?: (error: Error & {code?: string}) => void;
onReady?: (server: HttpServer | HttpsServer) => void;
runInspectorProxy?: boolean;
secureServerOptions?: Record<string, unknown>;

/** @deprecated since version 0.61 */
Expand Down

0 comments on commit 2b0b15d

Please sign in to comment.