mirror of https://github.com/status-im/metro.git
Add logging for HMR changes
Reviewed By: davidaurelio Differential Revision: D5833673 fbshipit-source-id: 5cfc9e7de6b761130093f785f2f9b829093571d0
This commit is contained in:
parent
bfa19e9db0
commit
300cd924e0
|
@ -17,6 +17,12 @@ const getBundlingOptionsForHmr = require('./getBundlingOptionsForHmr');
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
|
||||||
|
const {
|
||||||
|
createActionStartEntry,
|
||||||
|
createActionEndEntry,
|
||||||
|
log,
|
||||||
|
} = require('../Logger');
|
||||||
|
|
||||||
import type DeltaTransformer from '../DeltaBundler/DeltaTransformer';
|
import type DeltaTransformer from '../DeltaBundler/DeltaTransformer';
|
||||||
import type PackagerServer from '../Server';
|
import type PackagerServer from '../Server';
|
||||||
import type {Reporter} from '../lib/reporting';
|
import type {Reporter} from '../lib/reporting';
|
||||||
|
@ -87,9 +93,22 @@ class HmrServer<TClient: Client> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _handleFileChange(client: Client) {
|
async _handleFileChange(client: Client) {
|
||||||
|
const processingHmrChange = log(
|
||||||
|
createActionStartEntry({action_name: 'Processing HMR change'}),
|
||||||
|
);
|
||||||
|
|
||||||
client.sendFn(JSON.stringify({type: 'update-start'}));
|
client.sendFn(JSON.stringify({type: 'update-start'}));
|
||||||
client.sendFn(JSON.stringify(await this._prepareResponse(client)));
|
const response = await this._prepareResponse(client);
|
||||||
|
|
||||||
|
client.sendFn(JSON.stringify(response));
|
||||||
client.sendFn(JSON.stringify({type: 'update-done'}));
|
client.sendFn(JSON.stringify({type: 'update-done'}));
|
||||||
|
|
||||||
|
log({
|
||||||
|
...createActionEndEntry(processingHmrChange),
|
||||||
|
outdated_modules: Array.isArray(response.body.modules)
|
||||||
|
? response.body.modules.length
|
||||||
|
: null,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async _prepareResponse(client: Client): Promise<{type: string, body: {}}> {
|
async _prepareResponse(client: Client): Promise<{type: string, body: {}}> {
|
||||||
|
|
Loading…
Reference in New Issue