9
9
* @oncall react_native
10
10
*/
11
11
12
- import type { NextHandleFunction , Server } from 'connect' ;
12
+ import type { Server } from 'connect' ;
13
13
import type { TerminalReportableEvent } from 'metro/src/lib/TerminalReporter' ;
14
14
15
15
const debug = require ( 'debug' ) ( 'ReactNative:CommunityCliPlugin' ) ;
@@ -30,10 +30,6 @@ type MiddlewareReturn = {
30
30
...
31
31
} ;
32
32
33
- const noopNextHandle : NextHandleFunction = ( req , res , next ) => {
34
- next ( ) ;
35
- } ;
36
-
37
33
// $FlowFixMe
38
34
const unusedStubWSServer : ws$WebSocketServer = { } ;
39
35
// $FlowFixMe
@@ -45,6 +41,12 @@ const communityMiddlewareFallback = {
45
41
port : number ,
46
42
watchFolders : $ReadOnlyArray < string > ,
47
43
} ) : MiddlewareReturn => ( {
44
+ // FIXME: Several features will break without community middleware and
45
+ // should be migrated into core.
46
+ // e.g. used by Libraries/Core/Devtools:
47
+ // - /open-stack-frame
48
+ // - /open-url
49
+ // - /symbolicate
48
50
middleware : unusedMiddlewareStub ,
49
51
websocketEndpoints : { } ,
50
52
messageSocketEndpoint : {
@@ -59,15 +61,12 @@ const communityMiddlewareFallback = {
59
61
reportEvent : ( event : TerminalReportableEvent ) => { } ,
60
62
} ,
61
63
} ) ,
62
- indexPageMiddleware : noopNextHandle ,
63
64
} ;
64
65
65
66
// Attempt to use the community middleware if it exists, but fallback to
66
67
// the stubs if it doesn't.
67
68
try {
68
69
const community = require ( '@react-native-community/cli-server-api' ) ;
69
- communityMiddlewareFallback . indexPageMiddleware =
70
- community . indexPageMiddleware ;
71
70
communityMiddlewareFallback . createDevServerMiddleware =
72
71
community . createDevServerMiddleware ;
73
72
} catch {
@@ -77,5 +76,3 @@ Starting the server without the community middleware.`);
77
76
78
77
export const createDevServerMiddleware =
79
78
communityMiddlewareFallback . createDevServerMiddleware ;
80
- export const indexPageMiddleware =
81
- communityMiddlewareFallback . indexPageMiddleware ;
0 commit comments