diff --git a/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js b/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js index cce7ff8a..ac660b5e 100644 --- a/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js +++ b/packages/metro-bundler/src/ModuleGraph/ModuleGraph.js @@ -97,6 +97,6 @@ function* concat(...iterables: Array>): Iterable { function prelude(optimize) { return virtualModule( `var __DEV__=${String(!optimize)},` + - '__BUNDLE_START_TIME__=global.nativePerformanceNow?global.nativePerformanceNow():Date.now();' + '__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now();' ); } diff --git a/packages/metro-bundler/src/ModuleGraph/__tests__/ModuleGraph-test.js b/packages/metro-bundler/src/ModuleGraph/__tests__/ModuleGraph-test.js index d9a9108a..bc91a412 100644 --- a/packages/metro-bundler/src/ModuleGraph/__tests__/ModuleGraph-test.js +++ b/packages/metro-bundler/src/ModuleGraph/__tests__/ModuleGraph-test.js @@ -29,7 +29,7 @@ describe('build setup', () => { dependencies: [], file: { code: 'var __DEV__=true,__BUNDLE_START_TIME__=' + - 'global.nativePerformanceNow?global.nativePerformanceNow():Date.now();', + 'this.nativePerformanceNow?nativePerformanceNow():Date.now();', path: '', type: 'script', }, @@ -43,7 +43,7 @@ describe('build setup', () => { const [prelude] = result.modules; expect(prelude.file.code) .toEqual('var __DEV__=false,__BUNDLE_START_TIME__=' + - 'global.nativePerformanceNow?global.nativePerformanceNow():Date.now();'); + 'this.nativePerformanceNow?nativePerformanceNow():Date.now();'); done(); }); });