Skip to content

Commit

Permalink
Add systrace markers to module require
Browse files Browse the repository at this point in the history
Summary: public

Show modules' dependencies and time to load.

Reviewed By: davidaurelio

Differential Revision: D2603245

fb-gh-sync-id: a1d5067a8522b908b87fdfdd51ff4c4fdbc2edfc
  • Loading branch information
tadeuzagallo authored and facebook-github-bot-0 committed Nov 21, 2015
1 parent f02d6c1 commit 97f0432
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions react-packager/src/Resolver/polyfills/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@
// require cycles inside the factory from causing an infinite require loop.
mod.isInitialized = true;

__DEV__ && BridgeProfiling().profile(id);

// keep args in sync with with defineModuleCode in
// packager/react-packager/src/Resolver/index.js
mod.factory.call(global, global, require, mod.module, mod.module.exports);

__DEV__ && BridgeProfiling().profileEnd();
} catch (e) {
mod.hasError = true;
mod.isInitialized = false;
Expand All @@ -66,6 +70,16 @@
return mod.module.exports;
}

const BridgeProfiling = __DEV__ && (() => {
var _BridgeProfiling;
try {
_BridgeProfiling = require('BridgeProfiling');
} catch(e) {}

return _BridgeProfiling && _BridgeProfiling.profile ?
_BridgeProfiling : { profile: () => {}, profileEnd: () => {} };
});

global.__d = define;
global.require = require;
})(this);

0 comments on commit 97f0432

Please sign in to comment.