diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index a8f01c5354c..09b960aa163 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -326,7 +326,7 @@ class TimingAnimation extends Animation { super.stop(); this.__active = false; clearTimeout(this._timeout); - window.cancelAnimationFrame(this._animationFrame); + global.cancelAnimationFrame(this._animationFrame); this.__debouncedOnEnd({finished: false}); } } @@ -396,7 +396,7 @@ class DecayAnimation extends Animation { stop(): void { super.stop(); this.__active = false; - window.cancelAnimationFrame(this._animationFrame); + global.cancelAnimationFrame(this._animationFrame); this.__debouncedOnEnd({finished: false}); } } @@ -611,7 +611,7 @@ class SpringAnimation extends Animation { stop(): void { super.stop(); this.__active = false; - window.cancelAnimationFrame(this._animationFrame); + global.cancelAnimationFrame(this._animationFrame); this.__debouncedOnEnd({finished: false}); } } diff --git a/Libraries/Animated/src/__tests__/Animated-test.js b/Libraries/Animated/src/__tests__/Animated-test.js index 37941f6cace..02cb505755d 100644 --- a/Libraries/Animated/src/__tests__/Animated-test.js +++ b/Libraries/Animated/src/__tests__/Animated-test.js @@ -100,8 +100,8 @@ describe('Animated', () => { it('stops animation when detached', () => { // jest environment doesn't have cancelAnimationFrame :( - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = jest.fn(); + if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = jest.fn(); } var anim = new Animated.Value(0); diff --git a/Libraries/Animated/src/__tests__/AnimatedNative-test.js b/Libraries/Animated/src/__tests__/AnimatedNative-test.js index 71c8d36e6dd..34175ef835e 100644 --- a/Libraries/Animated/src/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/src/__tests__/AnimatedNative-test.js @@ -35,8 +35,8 @@ describe('Animated', () => { nativeAnimatedModule.dropAnimatedNode = jest.fn(); // jest environment doesn't have cancelAnimationFrame :( - if (!window.cancelAnimationFrame) { - window.cancelAnimationFrame = jest.fn(); + if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = jest.fn(); } }); diff --git a/Libraries/BatchedBridge/BatchedBridge.js b/Libraries/BatchedBridge/BatchedBridge.js index 77dc9e6a5d5..f1450ed4b3c 100644 --- a/Libraries/BatchedBridge/BatchedBridge.js +++ b/Libraries/BatchedBridge/BatchedBridge.js @@ -38,6 +38,9 @@ if (__DEV__) { // would export it. A possible fix would be to trim the dependencies in // MessageQueue to its minimal features and embed that in the native runtime. -Object.defineProperty(global, '__fbBatchedBridge', { value: BatchedBridge }); +Object.defineProperty(global, '__fbBatchedBridge', { + configurable: true, + value: BatchedBridge, +}); module.exports = BatchedBridge; diff --git a/Libraries/Utilities/__tests__/MessageQueueTestConfig.js b/Libraries/Utilities/__mocks__/MessageQueueTestConfig.js similarity index 100% rename from Libraries/Utilities/__tests__/MessageQueueTestConfig.js rename to Libraries/Utilities/__mocks__/MessageQueueTestConfig.js diff --git a/Libraries/Utilities/__tests__/MessageQueueTestModule1.js b/Libraries/Utilities/__mocks__/MessageQueueTestModule1.js similarity index 100% rename from Libraries/Utilities/__tests__/MessageQueueTestModule1.js rename to Libraries/Utilities/__mocks__/MessageQueueTestModule1.js diff --git a/Libraries/Utilities/__tests__/MessageQueueTestModule2.js b/Libraries/Utilities/__mocks__/MessageQueueTestModule2.js similarity index 100% rename from Libraries/Utilities/__tests__/MessageQueueTestModule2.js rename to Libraries/Utilities/__mocks__/MessageQueueTestModule2.js diff --git a/Libraries/Utilities/__tests__/MessageQueue-test.js b/Libraries/Utilities/__tests__/MessageQueue-test.js index 32d53182fa9..7a69e8d7e5b 100644 --- a/Libraries/Utilities/__tests__/MessageQueue-test.js +++ b/Libraries/Utilities/__tests__/MessageQueue-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -const MessageQueueTestConfig = require('./MessageQueueTestConfig'); +const MessageQueueTestConfig = require('MessageQueueTestConfig'); jest.unmock('MessageQueue'); let MessageQueue; @@ -46,8 +46,8 @@ describe('MessageQueue', function() { beforeEach(function() { jest.resetModuleRegistry(); MessageQueue = require('MessageQueue'); - MessageQueueTestModule1 = require('./MessageQueueTestModule1'); - MessageQueueTestModule2 = require('./MessageQueueTestModule2'); + MessageQueueTestModule1 = require('MessageQueueTestModule1'); + MessageQueueTestModule2 = require('MessageQueueTestModule2'); queue = new MessageQueue( () => MessageQueueTestConfig ); diff --git a/packager/react-packager/src/Server/index.js b/packager/react-packager/src/Server/index.js index ef35844fd97..c7ab61bee11 100644 --- a/packager/react-packager/src/Server/index.js +++ b/packager/react-packager/src/Server/index.js @@ -16,11 +16,18 @@ const Bundler = require('../Bundler'); const Promise = require('promise'); const SourceMapConsumer = require('source-map').SourceMapConsumer; -const _ = require('lodash'); const declareOpts = require('../lib/declareOpts'); const path = require('path'); const url = require('url'); +function debounce(fn, delay) { + var timeout; + return () => { + clearTimeout(timeout); + timeout = setTimeout(fn, delay); + }; +} + const validateOpts = declareOpts({ projectRoots: { type: 'array', @@ -209,7 +216,7 @@ class Server { this._fileWatcher.on('all', this._onFileChange.bind(this)); - this._debouncedFileChangeHandler = _.debounce(filePath => { + this._debouncedFileChangeHandler = debounce(filePath => { this._clearBundles(); this._informChangeWatchers(); }, 50);