Get rid of perf_hooks package in Flipper UI
Summary: perf_hooks is no longer needed as these APIs are widely available in both browser and electron. Still needed in unit tests, as they run from Node Reviewed By: lblasa, aigoncharov Differential Revision: D32648253 fbshipit-source-id: 5718ea99b57f96f6858311fd0815ad18c476c99e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9c913151bc
commit
2bf8ae2364
@@ -34,7 +34,6 @@ const BUILTINS = [
|
|||||||
'assert',
|
'assert',
|
||||||
'util',
|
'util',
|
||||||
'path',
|
'path',
|
||||||
'perf_hooks',
|
|
||||||
'punycode',
|
'punycode',
|
||||||
'querystring',
|
'querystring',
|
||||||
'cluster',
|
'cluster',
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {PluginDefinition} from './plugin';
|
|||||||
import BaseDevice from './devices/BaseDevice';
|
import BaseDevice from './devices/BaseDevice';
|
||||||
import {Logger} from 'flipper-common';
|
import {Logger} from 'flipper-common';
|
||||||
import {Store} from './reducers/index';
|
import {Store} from './reducers/index';
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import {
|
import {
|
||||||
reportPluginFailures,
|
reportPluginFailures,
|
||||||
NoLongerConnectedToClientError,
|
NoLongerConnectedToClientError,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
import {FlexColumn, Button, styled, Text, FlexRow, Spacer} from '../ui';
|
import {FlexColumn, Button, styled, Text, FlexRow, Spacer} from '../ui';
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {reportPlatformFailures} from 'flipper-common';
|
import {reportPlatformFailures} from 'flipper-common';
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import {Logger} from 'flipper-common';
|
import {Logger} from 'flipper-common';
|
||||||
import {IdlerImpl} from '../utils/Idler';
|
import {IdlerImpl} from '../utils/Idler';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
} from '../utils/exportData';
|
} from '../utils/exportData';
|
||||||
import ShareSheetErrorList from './ShareSheetErrorList';
|
import ShareSheetErrorList from './ShareSheetErrorList';
|
||||||
import {reportPlatformFailures} from 'flipper-common';
|
import {reportPlatformFailures} from 'flipper-common';
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
import ShareSheetPendingDialog from './ShareSheetPendingDialog';
|
||||||
import {getLogger} from 'flipper-common';
|
import {getLogger} from 'flipper-common';
|
||||||
import {resetSupportFormV2State} from '../reducers/supportForm';
|
import {resetSupportFormV2State} from '../reducers/supportForm';
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
|
|
||||||
import {State, Store} from '../reducers/index';
|
import {State, Store} from '../reducers/index';
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import type {
|
|||||||
Logger,
|
Logger,
|
||||||
FlipperServer,
|
FlipperServer,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import type {Actions} from '.';
|
import type {Actions} from '.';
|
||||||
import {WelcomeScreenStaticView} from '../sandy-chrome/WelcomeScreen';
|
import {WelcomeScreenStaticView} from '../sandy-chrome/WelcomeScreen';
|
||||||
import {isDevicePluginDefinition} from '../utils/pluginUtils';
|
import {isDevicePluginDefinition} from '../utils/pluginUtils';
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import {
|
|||||||
SupportFormRequestDetailsState,
|
SupportFormRequestDetailsState,
|
||||||
} from '../reducers/supportForm';
|
} from '../reducers/supportForm';
|
||||||
import {deconstructClientId} from 'flipper-common';
|
import {deconstructClientId} from 'flipper-common';
|
||||||
import {performance} from 'perf_hooks';
|
|
||||||
import {processMessageQueue} from './messageQueue';
|
import {processMessageQueue} from './messageQueue';
|
||||||
import {getPluginTitle} from './pluginUtils';
|
import {getPluginTitle} from './pluginUtils';
|
||||||
import {capture} from './screenshot';
|
import {capture} from './screenshot';
|
||||||
|
|||||||
@@ -39,6 +39,23 @@ console.debug = function () {
|
|||||||
// Intentional noop, we don't want debug statements in Jest runs
|
// Intentional noop, we don't want debug statements in Jest runs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// make perf tools available in Node (it is available in Browser / Electron just fine)
|
||||||
|
const {PerformanceObserver, performance} = require('perf_hooks');
|
||||||
|
Object.freeze(performance);
|
||||||
|
Object.freeze(Object.getPrototypeOf(performance));
|
||||||
|
// Something in our unit tests is messing with the performance global
|
||||||
|
// This fixes that.....
|
||||||
|
Object.defineProperty(global, 'performance', {
|
||||||
|
get() {
|
||||||
|
return performance;
|
||||||
|
},
|
||||||
|
set() {
|
||||||
|
throw new Error('Attempt to overwrite global.performance');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
global.PerformanceObserver = PerformanceObserver;
|
||||||
|
|
||||||
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
||||||
Object.defineProperty(window, 'matchMedia', {
|
Object.defineProperty(window, 'matchMedia', {
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user