RN: Logger for Hot Module Reloading Logs
Summary: Uses `Logger` for the HMR Server output so that we get timestamps for free and the packager server output does not look as crappy. Reviewed By: cpojer Differential Revision: D4210827 fbshipit-source-id: e1ae64c359150b98c33e7b074f1111d37a2bc39b
This commit is contained in:
parent
23331df5a4
commit
0ec0b9df8e
|
@ -8,10 +8,12 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste');
|
||||
const querystring = require('querystring');
|
||||
const url = require('url');
|
||||
|
||||
const {createEntry, print} = require('../../../packager/react-packager/src/Logger');
|
||||
const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste');
|
||||
|
||||
const blacklist = [
|
||||
'Libraries/Utilities/HMRClient.js',
|
||||
];
|
||||
|
@ -112,9 +114,9 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
path: path,
|
||||
});
|
||||
|
||||
console.log('[Hot Module Replacement] Server listening on', path);
|
||||
print(createEntry(`HMR Server listening on ${path}`));
|
||||
wss.on('connection', ws => {
|
||||
console.log('[Hot Module Replacement] Client connected');
|
||||
print(createEntry('HMR Client connected'));
|
||||
const params = querystring.parse(url.parse(ws.upgradeReq.url).query);
|
||||
|
||||
getDependencies(params.platform, params.bundleEntry)
|
||||
|
@ -138,9 +140,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
if (!client) {
|
||||
return;
|
||||
}
|
||||
console.log(
|
||||
`[Hot Module Replacement] File change detected (${time()})`
|
||||
);
|
||||
print(createEntry('HMR Server detected file change'));
|
||||
|
||||
const blacklisted = blacklist.find(blacklistedPath =>
|
||||
filename.indexOf(blacklistedPath) !== -1
|
||||
|
@ -297,10 +297,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[Hot Module Replacement] Sending HMR update to client (' +
|
||||
time() + ')'
|
||||
);
|
||||
print(createEntry('HMR Server sending update to client'));
|
||||
client.ws.send(update);
|
||||
});
|
||||
},
|
||||
|
@ -336,9 +333,4 @@ function arrayEquals(arrayA, arrayB) {
|
|||
);
|
||||
}
|
||||
|
||||
function time() {
|
||||
const date = new Date();
|
||||
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${date.getMilliseconds()}`;
|
||||
}
|
||||
|
||||
module.exports = attachHMRServer;
|
||||
|
|
Loading…
Reference in New Issue