Add logging for HMR changes

Reviewed By: davidaurelio

Differential Revision: D5833673

fbshipit-source-id: 5cfc9e7de6b761130093f785f2f9b829093571d0
This commit is contained in:
Rafael Oleza 2017-09-14 16:36:16 -07:00 committed by Facebook Github Bot
parent bfa19e9db0
commit 300cd924e0
1 changed files with 20 additions and 1 deletions

View File

@ -17,6 +17,12 @@ const getBundlingOptionsForHmr = require('./getBundlingOptionsForHmr');
const querystring = require('querystring');
const url = require('url');
const {
createActionStartEntry,
createActionEndEntry,
log,
} = require('../Logger');
import type DeltaTransformer from '../DeltaBundler/DeltaTransformer';
import type PackagerServer from '../Server';
import type {Reporter} from '../lib/reporting';
@ -87,9 +93,22 @@ class HmrServer<TClient: 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(await this._prepareResponse(client)));
const response = await this._prepareResponse(client);
client.sendFn(JSON.stringify(response));
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: {}}> {