mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 11:57:46 +08:00
Make Hot Loading work on OSS
Summary: public - Tweak OSS server to enable the HMR connection - Remove client gating code. - Resolve internal transforms plugins After this diff, Hot Loading should work on OSS. Reviewed By: javache Differential Revision: D2803620 fb-gh-sync-id: b678180c884d2bfaf454edf9e7abe6b3b3b32ebe
This commit is contained in:
committed by
facebook-github-bot-9
parent
0185df57bd
commit
bba35f0415
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const attachHMRServer = require('./util/attachHMRServer');
|
||||
const connect = require('connect');
|
||||
const cpuProfilerMiddleware = require('./middleware/cpuProfilerMiddleware');
|
||||
const getDevToolsMiddleware = require('./middleware/getDevToolsMiddleware');
|
||||
@@ -23,6 +24,7 @@ const webSocketProxy = require('./util/webSocketProxy.js');
|
||||
|
||||
function runServer(args, config, readyCallback) {
|
||||
var wsProxy = null;
|
||||
const packagerServer = getPackagerServer(args, config);
|
||||
const app = connect()
|
||||
.use(loadRawBodyMiddleware)
|
||||
.use(connect.compress())
|
||||
@@ -33,7 +35,7 @@ function runServer(args, config, readyCallback) {
|
||||
.use(cpuProfilerMiddleware)
|
||||
// Temporarily disable flow check until it's more stable
|
||||
//.use(getFlowTypeCheckMiddleware(args))
|
||||
.use(getAppMiddleware(args, config));
|
||||
.use(packagerServer.processRequest.bind(packagerServer));
|
||||
|
||||
args.projectRoots.forEach(root => app.use(connect.static(root)));
|
||||
|
||||
@@ -44,6 +46,12 @@ function runServer(args, config, readyCallback) {
|
||||
args.port,
|
||||
'::',
|
||||
function() {
|
||||
attachHMRServer({
|
||||
httpServer: serverInstance,
|
||||
path: '/hot',
|
||||
packagerServer,
|
||||
});
|
||||
|
||||
wsProxy = webSocketProxy.attachToServer(serverInstance, '/debugger-proxy');
|
||||
webSocketProxy.attachToServer(serverInstance, '/devtools');
|
||||
readyCallback();
|
||||
@@ -55,13 +63,13 @@ function runServer(args, config, readyCallback) {
|
||||
serverInstance.timeout = 0;
|
||||
}
|
||||
|
||||
function getAppMiddleware(args, config) {
|
||||
function getPackagerServer(args, config) {
|
||||
let transformerPath = args.transformer;
|
||||
if (!isAbsolutePath(transformerPath)) {
|
||||
transformerPath = path.resolve(process.cwd(), transformerPath);
|
||||
}
|
||||
|
||||
return ReactPackager.middleware({
|
||||
return ReactPackager.createServer({
|
||||
nonPersistent: args.nonPersistent,
|
||||
projectRoots: args.projectRoots,
|
||||
blacklistRE: config.getBlacklistRE(),
|
||||
|
||||
Reference in New Issue
Block a user