mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
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';
|
'use strict';
|
||||||
|
|
||||||
const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste');
|
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
|
||||||
|
const {createEntry, print} = require('../../../packager/react-packager/src/Logger');
|
||||||
|
const {getInverseDependencies} = require('../../../packager/react-packager/src/node-haste');
|
||||||
|
|
||||||
const blacklist = [
|
const blacklist = [
|
||||||
'Libraries/Utilities/HMRClient.js',
|
'Libraries/Utilities/HMRClient.js',
|
||||||
];
|
];
|
||||||
@ -112,9 +114,9 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
path: path,
|
path: path,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[Hot Module Replacement] Server listening on', path);
|
print(createEntry(`HMR Server listening on ${path}`));
|
||||||
wss.on('connection', ws => {
|
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);
|
const params = querystring.parse(url.parse(ws.upgradeReq.url).query);
|
||||||
|
|
||||||
getDependencies(params.platform, params.bundleEntry)
|
getDependencies(params.platform, params.bundleEntry)
|
||||||
@ -138,9 +140,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(
|
print(createEntry('HMR Server detected file change'));
|
||||||
`[Hot Module Replacement] File change detected (${time()})`
|
|
||||||
);
|
|
||||||
|
|
||||||
const blacklisted = blacklist.find(blacklistedPath =>
|
const blacklisted = blacklist.find(blacklistedPath =>
|
||||||
filename.indexOf(blacklistedPath) !== -1
|
filename.indexOf(blacklistedPath) !== -1
|
||||||
@ -297,10 +297,7 @@ function attachHMRServer({httpServer, path, packagerServer}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
print(createEntry('HMR Server sending update to client'));
|
||||||
'[Hot Module Replacement] Sending HMR update to client (' +
|
|
||||||
time() + ')'
|
|
||||||
);
|
|
||||||
client.ws.send(update);
|
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;
|
module.exports = attachHMRServer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user