Skip to content

Commit

Permalink
Remove rAF fork (#12980)
Browse files Browse the repository at this point in the history
* Remove rAF fork

**what is the change?:**
Undid #12837

**why make this change?:**
We originally forked rAF because we needed to pull in a particular
version of rAF internally at Facebook, to avoid grabbing the default
polyfilled version.

The longer term solution, until we can get rid of the global polyfill
behavior, is to initialize 'schedule' before the polyfilling happens.

Now that we have landed and synced
#12900 successfully, we can
initialize 'schedule' before the polyfill runs.
So we can remove the rAF fork. Here is how it will work:

1. Land this PR on Github.
2. Flarnie will quickly run a sync getting this change into www.
3. We delete the internal forked version of
   'requestAnimationFrameForReact'.
4. We require 'schedule' in the polyfill file itself, before the
   polyfilling happens.

**test plan:**
Flarnie will manually try the above steps locally and verify that things
work.

**issue:**
Internal task T29442940

* fix nits

* fix tests, fix changes from rebasing

* fix lint
  • Loading branch information
flarnie authored Jun 13, 2018
1 parent e0c7834 commit 2a80859
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 70 deletions.
2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ describe('ReactDOM', () => {
global.requestAnimationFrame = undefined;
jest.resetModules();
expect(() => require('react-dom')).toWarnDev(
'React depends on requestAnimationFrame.',
"This browser doesn't support requestAnimationFrame.",
);
} finally {
global.requestAnimationFrame = previousRAF;
Expand Down
38 changes: 16 additions & 22 deletions packages/react-scheduler/src/ReactScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,24 @@ type CallbackConfigType = {|

export type CallbackIdType = CallbackConfigType;

import requestAnimationFrameForReact from 'shared/requestAnimationFrameForReact';
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';

if (__DEV__) {
if (
ExecutionEnvironment.canUseDOM &&
typeof requestAnimationFrame !== 'function'
) {
warning(
false,
// TODO: reword this when schedule is a stand-alone module
"This browser doesn't support requestAnimationFrame. " +
'Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
}
}

// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated.
// We want to be using a consistent implementation.
Expand Down Expand Up @@ -106,26 +119,7 @@ if (!ExecutionEnvironment.canUseDOM) {
localClearTimeout(timeoutId);
};
} else {
if (__DEV__) {
if (typeof requestAnimationFrameForReact !== 'function') {
warning(
false,
'React depends on requestAnimationFrame. Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
}
}

let localRequestAnimationFrame =
typeof requestAnimationFrameForReact === 'function'
? requestAnimationFrameForReact
: function(callback: Function) {
invariant(
false,
'React depends on requestAnimationFrame. Make sure that you load a ' +
'polyfill in older browsers. https://fb.me/react-polyfills',
);
};
const localRequestAnimationFrame = requestAnimationFrame;

let headOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
let tailOfPendingCallbacksLinkedList: CallbackConfigType | null = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/__tests__/ReactDOMFrameScheduling-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('ReactDOMFrameScheduling', () => {
global.requestAnimationFrame = undefined;
jest.resetModules();
expect(() => require('react-dom')).toWarnDev(
'React depends on requestAnimationFrame.',
"This browser doesn't support requestAnimationFrame.",
);
} finally {
global.requestAnimationFrame = previousRAF;
Expand Down
10 changes: 0 additions & 10 deletions packages/shared/forks/requestAnimationFrameForReact.www.js

This file was deleted.

24 changes: 0 additions & 24 deletions packages/shared/requestAnimationFrameForReact.js

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ const forks = Object.freeze({
return null;
},

// This logic is forked on www to use the 'acrossTransitions' version.
// This will be removed soon, see internal task T29442940
'shared/requestAnimationFrameForReact': (bundleType, entry) => {
switch (bundleType) {
case FB_WWW_DEV:
case FB_WWW_PROD:
return 'shared/forks/requestAnimationFrameForReact.www.js';
default:
return null;
}
},

'shared/ReactScheduler': (bundleType, entry) => {
switch (bundleType) {
case FB_WWW_DEV:
Expand Down

0 comments on commit 2a80859

Please sign in to comment.