diff --git a/react-packager/src/JSTransformer/index.js b/react-packager/src/JSTransformer/index.js index 30dc4d7b..d3a71677 100644 --- a/react-packager/src/JSTransformer/index.js +++ b/react-packager/src/JSTransformer/index.js @@ -8,6 +8,7 @@ */ 'use strict'; +const Logger = require('../Logger'); const Promise = require('promise'); const declareOpts = require('../lib/declareOpts'); @@ -115,6 +116,8 @@ class Transformer { return this ._transform(this._transformModulePath, fileName, code, options) .then(result => { + Logger.log(result.transformFileStartLogEntry); + Logger.log(result.transformFileEndLogEntry); debug('done transforming file', fileName); return result; }) diff --git a/react-packager/src/JSTransformer/worker/index.js b/react-packager/src/JSTransformer/worker/index.js index a767f999..61783609 100644 --- a/react-packager/src/JSTransformer/worker/index.js +++ b/react-packager/src/JSTransformer/worker/index.js @@ -24,6 +24,14 @@ function transformCode(transform, filename, sourceCode, options, callback) { const params = makeTransformParams(filename, sourceCode, options.transform); const isJson = filename.endsWith('.json'); + const transformFileStartLogEntry = { + action_name: 'Transforming file', + action_phase: 'start', + file_name: filename, + log_entry_label: 'Transforming file', + start_timestamp: process.hrtime(), + }; + transform(params, (error, transformed) => { if (error) { callback(error); @@ -52,8 +60,20 @@ function transformCode(transform, filename, sourceCode, options, callback) { ? {dependencies: [], dependencyOffsets: []} : extractDependencies(code); + const timeDelta = process.hrtime(transformFileStartLogEntry.start_timestamp); + const duration_ms = Math.round((timeDelta[0] * 1e9 + timeDelta[1]) / 1e6); + const transformFileEndLogEntry = { + action_name: 'Transforming file', + action_phase: 'end', + file_name: filename, + duration_ms: duration_ms, + log_entry_label: 'Transforming file', + }; + result.code = code; result.map = map; + result.transformFileStartLogEntry = transformFileStartLogEntry; + result.transformFileEndLogEntry = transformFileEndLogEntry; callback(null, result); });