Use node's perf_hooks
Summary: I tried switching Flipper to use the node.js module: https://nodejs.org/api/perf_hooks.html instead of electrons window.performance. But the module couldn't be found. So instead, I'm just replacing it in the pure node tests. This means tests without node can work without issues. Reviewed By: danielbuechele Differential Revision: D10302114 fbshipit-source-id: b3b8aa5fb350a8246fcdfc2a80cc72daec2448d7
This commit is contained in:
committed by
Facebook Github Bot
parent
87830ff106
commit
76d40e7ddf
@@ -11,6 +11,7 @@ var fs = require('fs');
|
||||
var electronStubs = babylon.parseExpression(
|
||||
fs.readFileSync('static/electron-stubs.notjs').toString(),
|
||||
);
|
||||
var perfHooks = babylon.parseExpression("require('perf_hooks').performance");
|
||||
|
||||
module.exports = function(babel) {
|
||||
return {
|
||||
@@ -27,6 +28,17 @@ module.exports = function(babel) {
|
||||
path.replaceWith(electronStubs);
|
||||
}
|
||||
}
|
||||
if (
|
||||
path.node.type === 'CallExpression' &&
|
||||
path.node.callee.type === 'MemberExpression' &&
|
||||
path.node.callee.object.name === 'performance'
|
||||
) {
|
||||
// 'perf_hooks' was added in Node 8.5.0 but doesn't appear to be
|
||||
// present in electron. We can remove this and switch to using
|
||||
// interval when it is. Until then, continue using browser.performance
|
||||
// for real and swap in node's perf_hooks when we dont have electron.
|
||||
path.node.callee.object = perfHooks;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user