mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 03:56:03 +00:00
f05943de0a
Summary: This fixes some regressions with local-cli introduced in c4a66a89a28152cd4b81e2b0f80ab3aac34d6872. - We didn't pass `assetRegistryPath` which caused the following error when loading the bundle: ``` error: bundling failed: Error: Unable to resolve module `missing-asset-registry-path` from `/Users/janic/Developer/react-native/RNTester/js/uie_thumb_normal@2x.png`: Module `missing-asset-registry-path` does not exist in the Haste module map ``` - The middlewares were not added to the metro server. This causes some packager server features to fail. The one I noticed is that the /status endpoint didn't exist anymore which causes CI to fail and also Android to not load the bundle from the packager initially. The remote debugging feature was also broken. Pull Request resolved: https://github.com/facebook/react-native/pull/20162 Differential Revision: D8867610 Pulled By: hramos fbshipit-source-id: 8a08b7f3175692ab6ee73c0a7c25075091ae4792
70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
/**
|
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @strict
|
|
* @flow
|
|
*/
|
|
|
|
const compression = require('compression');
|
|
const connect = require('connect');
|
|
const errorhandler = require('errorhandler');
|
|
const path = require('path');
|
|
const serveStatic = require('serve-static');
|
|
const WebSocketServer = require('ws').Server;
|
|
|
|
const indexPageMiddleware = require('./indexPage');
|
|
const copyToClipBoardMiddleware = require('./copyToClipBoardMiddleware');
|
|
const loadRawBodyMiddleware = require('./loadRawBodyMiddleware');
|
|
const openStackFrameInEditorMiddleware = require('./openStackFrameInEditorMiddleware');
|
|
const statusPageMiddleware = require('./statusPageMiddleware');
|
|
const systraceProfileMiddleware = require('./systraceProfileMiddleware');
|
|
const getDevToolsMiddleware = require('./getDevToolsMiddleware');
|
|
|
|
type Options = {
|
|
+watchFolders: $ReadOnlyArray<string>,
|
|
+host?: string,
|
|
}
|
|
|
|
type WebSocketProxy = {
|
|
server: WebSocketServer,
|
|
isChromeConnected: () => boolean,
|
|
};
|
|
|
|
type Connect = $Call<connect>;
|
|
|
|
module.exports = class MiddlewareManager {
|
|
app: Connect;
|
|
options: Options;
|
|
|
|
constructor(options: Options) {
|
|
const debuggerUIFolder = path.join(__dirname, '..', 'util', 'debugger-ui');
|
|
|
|
this.options = options;
|
|
this.app = connect()
|
|
.use(loadRawBodyMiddleware)
|
|
.use(compression())
|
|
.use('/debugger-ui', serveStatic(debuggerUIFolder))
|
|
.use(openStackFrameInEditorMiddleware(this.options))
|
|
.use(copyToClipBoardMiddleware)
|
|
.use(statusPageMiddleware)
|
|
.use(systraceProfileMiddleware)
|
|
.use(indexPageMiddleware)
|
|
.use(errorhandler());
|
|
}
|
|
|
|
serveStatic = (folder: string) => {
|
|
this.app.use(serveStatic(folder));
|
|
};
|
|
|
|
getConnectInstance = () => this.app;
|
|
|
|
attachDevToolsSocket = (socket: WebSocketProxy) => {
|
|
this.app.use(
|
|
getDevToolsMiddleware(this.options, () => socket.isChromeConnected()),
|
|
);
|
|
};
|
|
};
|