Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fbjs dependency #13069

Merged
merged 9 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"eslint-plugin-no-for-of-loops": "^1.0.0",
"eslint-plugin-react": "^6.7.1",
"eslint-plugin-react-internal": "link:./scripts/eslint-rules/",
"fbjs": "^0.8.16",
"fbjs-scripts": "^0.6.0",
"filesize": "^3.5.6",
"flow-bin": "^0.72.0",
Expand Down
3 changes: 0 additions & 3 deletions packages/create-subscription/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"index.js",
"cjs/"
],
"dependencies": {
"fbjs": "^0.8.16"
},
"peerDependencies": {
"react": "^16.3.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create-subscription/src/createSubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import React from 'react';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import invariant from 'shared/invariant';
import warning from 'shared/warning';

type Unsubscribe = () => void;

Expand Down
2 changes: 1 addition & 1 deletion packages/events/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import ReactErrorUtils from 'shared/ReactErrorUtils';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

import {
injectEventPluginOrder,
Expand Down
2 changes: 1 addition & 1 deletion packages/events/EventPluginRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
PluginModule,
} from './PluginModuleType';

import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

type NamesToPlugins = {[key: PluginName]: PluginModule<AnyNativeEvent>};
type EventPluginOrder = null | Array<PluginName>;
Expand Down
4 changes: 2 additions & 2 deletions packages/events/EventPluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import ReactErrorUtils from 'shared/ReactErrorUtils';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import invariant from 'shared/invariant';
import warning from 'shared/warning';

export let getFiberCurrentPropsFromNode = null;
export let getInstanceFromNode = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/events/EventPropagators.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
traverseTwoPhase,
traverseEnterLeave,
} from 'shared/ReactTreeTraversal';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import {getListener} from './EventPluginHub';
import accumulateInto from './accumulateInto';
Expand Down
2 changes: 1 addition & 1 deletion packages/events/ReactControlledComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

import {
getInstanceFromNode,
Expand Down
4 changes: 2 additions & 2 deletions packages/events/ResponderTouchHistoryStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @flow
*/

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

import {isStartish, isMoveish, isEndish} from './ResponderTopLevelEventTypes';

Expand Down
4 changes: 2 additions & 2 deletions packages/events/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

/* eslint valid-typeof: 0 */

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

let didWarnForAddedNewProperty = false;
const EVENT_POOL_SIZE = 10;
Expand Down
2 changes: 1 addition & 1 deletion packages/events/accumulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

/**
* Accumulates items that must not be null or undefined.
Expand Down
2 changes: 1 addition & 1 deletion packages/events/accumulateInto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

/**
* Accumulates items that must not be null or undefined into the first one. This
Expand Down
1 change: 0 additions & 1 deletion packages/react-art/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"dependencies": {
"art": "^0.10.1",
"create-react-class": "^15.6.2",
"fbjs": "^0.8.16",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import * as ReactScheduler from 'shared/ReactScheduler';
import Transform from 'art/core/transform';
import Mode from 'art/modes/current';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

import {TYPES, EVENT_TYPES, childrenAsString} from './ReactARTInternals';

Expand Down
1 change: 0 additions & 1 deletion packages/react-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"homepage": "https://reactjs.org/",
"dependencies": {
"fbjs": "^0.8.16",
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
"prop-types": "^15.6.0"
Expand Down
52 changes: 42 additions & 10 deletions packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,50 @@ let ReactDOMServer;
let ReactCurrentOwner;
let ReactTestUtils;
let PropTypes;
let shallowEqual;
let shallowCompare;

describe('ReactCompositeComponent', () => {
const hasOwnProperty = Object.prototype.hasOwnProperty;

/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA: mixed, objB: mixed): boolean {
if (Object.is(objA, objB)) {
return true;
}
if (
typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null
) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
for (let i = 0; i < keysA.length; i++) {
if (
!hasOwnProperty.call(objB, keysA[i]) ||
!Object.is(objA[keysA[i]], objB[keysA[i]])
) {
return false;
}
}
return true;
}

function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
}

beforeEach(() => {
jest.resetModules();
React = require('react');
Expand All @@ -30,14 +70,6 @@ describe('ReactCompositeComponent', () => {
.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
ReactTestUtils = require('react-dom/test-utils');
PropTypes = require('prop-types');
shallowEqual = require('fbjs/lib/shallowEqual');

shallowCompare = function(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
};

MorphingComponent = class extends React.Component {
state = {activated: false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
let React;
let ReactDOM;
let ReactDOMSelection;
let invariant;

let getModernOffsetsFromPoints;

Expand All @@ -21,7 +20,6 @@ describe('ReactDOMSelection', () => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMSelection = require('../client/ReactDOMSelection');
invariant = require('fbjs/lib/invariant');

({getModernOffsetsFromPoints} = ReactDOMSelection);
});
Expand Down Expand Up @@ -68,10 +66,9 @@ describe('ReactDOMSelection', () => {
}
traverse(outerNode);

invariant(
start !== null && end !== null,
'Provided anchor/focus nodes were outside of root.',
);
if (start === null || end === null) {
throw new Error('Provided anchor/focus nodes were outside of root.');
}
return {start, end};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import * as ReactInstanceMap from 'shared/ReactInstanceMap';
import ReactVersion from 'shared/ReactVersion';
import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState';
import getComponentName from 'shared/getComponentName';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';
import lowPriorityWarning from 'shared/lowPriorityWarning';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import * as ReactDOMComponentTree from './ReactDOMComponentTree';
import * as ReactDOMFiberComponent from './ReactDOMFiberComponent';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import {HostComponent, HostText} from 'shared/ReactTypeOfWork';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

const randomKey = Math.random()
.toString(36)
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMFiberComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// TODO: direct imports like some-package/src/* are bad. Fix me.
import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber';
import {registrationNameModules} from 'events/EventPluginRegistry';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import * as DOMPropertyOperations from './DOMPropertyOperations';
import * as ReactDOMFiberInput from './ReactDOMFiberInput';
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/ReactDOMFiberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

// TODO: direct imports like some-package/src/* are bad. Fix me.
import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import invariant from 'shared/invariant';
import warning from 'shared/warning';

import * as DOMPropertyOperations from './DOMPropertyOperations';
import {getFiberCurrentPropsFromNode} from './ReactDOMComponentTree';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMFiberOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import React from 'react';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

let didWarnSelectedSetOnOption = false;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMFiberSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// TODO: direct imports like some-package/src/* are bad. Fix me.
import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import ReactControlledValuePropTypes from '../shared/ReactControlledValuePropTypes';

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/ReactDOMFiberTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @flow
*/

import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import invariant from 'shared/invariant';
import warning from 'shared/warning';
// TODO: direct imports like some-package/src/* are bad. Fix me.
import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/validateDOMNesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';
// TODO: direct imports like some-package/src/* are bad. Fix me.
import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {accumulateTwoPhaseDispatches} from 'events/EventPropagators';
import SyntheticEvent from 'events/SyntheticEvent';

import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import SyntheticAnimationEvent from './SyntheticAnimationEvent';
import SyntheticClipboardEvent from './SyntheticClipboardEvent';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactDOMServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import ReactVersion from 'shared/ReactVersion';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';

import {renderToString, renderToStaticMarkup} from './ReactDOMStringRenderer';

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import type {
} from 'shared/ReactTypes';

import React from 'react';
import invariant from 'fbjs/lib/invariant';
import invariant from 'shared/invariant';
import lowPriorityWarning from 'shared/lowPriorityWarning';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';
import checkPropTypes from 'prop-types/checkPropTypes';
import describeComponentFrame from 'shared/describeComponentFrame';
import {ReactDebugCurrentFrame} from 'shared/ReactGlobalSharedState';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

type PropertyType = 0 | 1 | 2 | 3 | 4 | 5 | 6;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';
import {ReactDebugCurrentFrame} from 'shared/ReactGlobalSharedState';

import {ATTRIBUTE_NAME_CHAR} from './DOMProperty';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import {ReactDebugCurrentFrame} from 'shared/ReactGlobalSharedState';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

let didWarnValueNull = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
possibleRegistrationNames,
} from 'events/EventPluginRegistry';
import {ReactDebugCurrentFrame} from 'shared/ReactGlobalSharedState';
import warning from 'fbjs/lib/warning';
import warning from 'shared/warning';

import {
ATTRIBUTE_NAME_CHAR,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/shared/assertValidProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

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

import voidElementTags from './voidElementTags';

Expand Down
Loading