diff --git a/package.json b/package.json index 939375b0a02fa..78e89495da128 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/create-subscription/package.json b/packages/create-subscription/package.json index a9e306e4b9776..ccfcb5dfe8227 100644 --- a/packages/create-subscription/package.json +++ b/packages/create-subscription/package.json @@ -9,9 +9,6 @@ "index.js", "cjs/" ], - "dependencies": { - "fbjs": "^0.8.16" - }, "peerDependencies": { "react": "^16.3.0" }, diff --git a/packages/create-subscription/src/createSubscription.js b/packages/create-subscription/src/createSubscription.js index df18f8b3c752b..dec0cc57cefe7 100644 --- a/packages/create-subscription/src/createSubscription.js +++ b/packages/create-subscription/src/createSubscription.js @@ -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; diff --git a/packages/events/EventPluginHub.js b/packages/events/EventPluginHub.js index 27840402efe82..a4849d98c9a76 100644 --- a/packages/events/EventPluginHub.js +++ b/packages/events/EventPluginHub.js @@ -7,7 +7,7 @@ */ import ReactErrorUtils from 'shared/ReactErrorUtils'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import { injectEventPluginOrder, diff --git a/packages/events/EventPluginRegistry.js b/packages/events/EventPluginRegistry.js index efebd984e84fa..77cf4429b8cb9 100644 --- a/packages/events/EventPluginRegistry.js +++ b/packages/events/EventPluginRegistry.js @@ -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}; type EventPluginOrder = null | Array; diff --git a/packages/events/EventPluginUtils.js b/packages/events/EventPluginUtils.js index 19a89e30de825..28f8c7f89bea7 100644 --- a/packages/events/EventPluginUtils.js +++ b/packages/events/EventPluginUtils.js @@ -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; diff --git a/packages/events/EventPropagators.js b/packages/events/EventPropagators.js index 451d18b852e3d..12acf93606f5e 100644 --- a/packages/events/EventPropagators.js +++ b/packages/events/EventPropagators.js @@ -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'; diff --git a/packages/events/ReactControlledComponent.js b/packages/events/ReactControlledComponent.js index 499fb0492791d..378125181f5db 100644 --- a/packages/events/ReactControlledComponent.js +++ b/packages/events/ReactControlledComponent.js @@ -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, diff --git a/packages/events/ResponderTouchHistoryStore.js b/packages/events/ResponderTouchHistoryStore.js index 807a5a08d9912..a7bee3acd2698 100644 --- a/packages/events/ResponderTouchHistoryStore.js +++ b/packages/events/ResponderTouchHistoryStore.js @@ -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'; diff --git a/packages/events/SyntheticEvent.js b/packages/events/SyntheticEvent.js index b8693d8d37df7..cdb1382e179f8 100644 --- a/packages/events/SyntheticEvent.js +++ b/packages/events/SyntheticEvent.js @@ -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; diff --git a/packages/events/accumulate.js b/packages/events/accumulate.js index 134e9333a3dca..c59f7abec8371 100644 --- a/packages/events/accumulate.js +++ b/packages/events/accumulate.js @@ -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. diff --git a/packages/events/accumulateInto.js b/packages/events/accumulateInto.js index 156c8411c7233..6b5e6bffe0571 100644 --- a/packages/events/accumulateInto.js +++ b/packages/events/accumulateInto.js @@ -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 diff --git a/packages/react-art/package.json b/packages/react-art/package.json index c3863c483800d..bbd487f263196 100644 --- a/packages/react-art/package.json +++ b/packages/react-art/package.json @@ -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" diff --git a/packages/react-art/src/ReactARTHostConfig.js b/packages/react-art/src/ReactARTHostConfig.js index 2b109994166bb..33f91a77d4b7b 100644 --- a/packages/react-art/src/ReactARTHostConfig.js +++ b/packages/react-art/src/ReactARTHostConfig.js @@ -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'; diff --git a/packages/react-dom/package.json b/packages/react-dom/package.json index f6ba19cc43080..f46a72eec7923 100644 --- a/packages/react-dom/package.json +++ b/packages/react-dom/package.json @@ -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" diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js index d614d27dd3585..182564111f163 100644 --- a/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js +++ b/packages/react-dom/src/__tests__/ReactCompositeComponent-test.js @@ -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'); @@ -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}; diff --git a/packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js index b167084ad87ba..ec8850090be8b 100644 --- a/packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js @@ -12,7 +12,6 @@ let React; let ReactDOM; let ReactDOMSelection; -let invariant; let getModernOffsetsFromPoints; @@ -21,7 +20,6 @@ describe('ReactDOMSelection', () => { React = require('react'); ReactDOM = require('react-dom'); ReactDOMSelection = require('../client/ReactDOMSelection'); - invariant = require('fbjs/lib/invariant'); ({getModernOffsetsFromPoints} = ReactDOMSelection); }); @@ -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}; } diff --git a/packages/react-dom/src/client/ReactDOM.js b/packages/react-dom/src/client/ReactDOM.js index 184e958142a90..363617fc7e701 100644 --- a/packages/react-dom/src/client/ReactDOM.js +++ b/packages/react-dom/src/client/ReactDOM.js @@ -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'; diff --git a/packages/react-dom/src/client/ReactDOMComponentTree.js b/packages/react-dom/src/client/ReactDOMComponentTree.js index d9c2e2d858aa8..a683df5b068de 100644 --- a/packages/react-dom/src/client/ReactDOMComponentTree.js +++ b/packages/react-dom/src/client/ReactDOMComponentTree.js @@ -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) diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index 4975e55f6731e..c7ec03ed12009 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -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'; diff --git a/packages/react-dom/src/client/ReactDOMFiberInput.js b/packages/react-dom/src/client/ReactDOMFiberInput.js index 9483279516232..c164d984199a0 100644 --- a/packages/react-dom/src/client/ReactDOMFiberInput.js +++ b/packages/react-dom/src/client/ReactDOMFiberInput.js @@ -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'; diff --git a/packages/react-dom/src/client/ReactDOMFiberOption.js b/packages/react-dom/src/client/ReactDOMFiberOption.js index 663b9cf22cc77..e5c04d23924a7 100644 --- a/packages/react-dom/src/client/ReactDOMFiberOption.js +++ b/packages/react-dom/src/client/ReactDOMFiberOption.js @@ -8,7 +8,7 @@ */ import React from 'react'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; let didWarnSelectedSetOnOption = false; diff --git a/packages/react-dom/src/client/ReactDOMFiberSelect.js b/packages/react-dom/src/client/ReactDOMFiberSelect.js index d0ed3ad01bd33..21c7e62ecec19 100644 --- a/packages/react-dom/src/client/ReactDOMFiberSelect.js +++ b/packages/react-dom/src/client/ReactDOMFiberSelect.js @@ -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'; diff --git a/packages/react-dom/src/client/ReactDOMFiberTextarea.js b/packages/react-dom/src/client/ReactDOMFiberTextarea.js index d167161435282..4ff024895e67e 100644 --- a/packages/react-dom/src/client/ReactDOMFiberTextarea.js +++ b/packages/react-dom/src/client/ReactDOMFiberTextarea.js @@ -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'; diff --git a/packages/react-dom/src/client/validateDOMNesting.js b/packages/react-dom/src/client/validateDOMNesting.js index 8f843f7a2f68c..3d3e17cd25800 100644 --- a/packages/react-dom/src/client/validateDOMNesting.js +++ b/packages/react-dom/src/client/validateDOMNesting.js @@ -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'; diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 8473b546fb655..b8b5c248a9edd 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -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'; diff --git a/packages/react-dom/src/server/ReactDOMServerBrowser.js b/packages/react-dom/src/server/ReactDOMServerBrowser.js index 1edfbce979ac9..43044191474c1 100644 --- a/packages/react-dom/src/server/ReactDOMServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMServerBrowser.js @@ -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'; diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index 87673bd4eb923..04234411f2a93 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -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'; diff --git a/packages/react-dom/src/shared/DOMProperty.js b/packages/react-dom/src/shared/DOMProperty.js index b01c069dbad0c..31f222b978854 100644 --- a/packages/react-dom/src/shared/DOMProperty.js +++ b/packages/react-dom/src/shared/DOMProperty.js @@ -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; diff --git a/packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js b/packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js index 0020b4ba668ea..def8ce5a26fb2 100644 --- a/packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js +++ b/packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js @@ -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'; diff --git a/packages/react-dom/src/shared/ReactDOMNullInputValuePropHook.js b/packages/react-dom/src/shared/ReactDOMNullInputValuePropHook.js index 018054cb301ee..b8e5aeb2316f9 100644 --- a/packages/react-dom/src/shared/ReactDOMNullInputValuePropHook.js +++ b/packages/react-dom/src/shared/ReactDOMNullInputValuePropHook.js @@ -6,7 +6,7 @@ */ import {ReactDebugCurrentFrame} from 'shared/ReactGlobalSharedState'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; let didWarnValueNull = false; diff --git a/packages/react-dom/src/shared/ReactDOMUnknownPropertyHook.js b/packages/react-dom/src/shared/ReactDOMUnknownPropertyHook.js index 399a7d89ce5c4..80607b6b65284 100644 --- a/packages/react-dom/src/shared/ReactDOMUnknownPropertyHook.js +++ b/packages/react-dom/src/shared/ReactDOMUnknownPropertyHook.js @@ -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, diff --git a/packages/react-dom/src/shared/assertValidProps.js b/packages/react-dom/src/shared/assertValidProps.js index 60c0ff4f7cfd3..b7985858777a2 100644 --- a/packages/react-dom/src/shared/assertValidProps.js +++ b/packages/react-dom/src/shared/assertValidProps.js @@ -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'; diff --git a/packages/react-dom/src/shared/checkReact.js b/packages/react-dom/src/shared/checkReact.js index ff7192c688ef8..8ce3d0082b930 100644 --- a/packages/react-dom/src/shared/checkReact.js +++ b/packages/react-dom/src/shared/checkReact.js @@ -8,7 +8,7 @@ */ import React from 'react'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; invariant( React, diff --git a/packages/react-dom/src/shared/warnValidStyle.js b/packages/react-dom/src/shared/warnValidStyle.js index 0231d589bb59b..d616c9b3c9071 100644 --- a/packages/react-dom/src/shared/warnValidStyle.js +++ b/packages/react-dom/src/shared/warnValidStyle.js @@ -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'; let warnValidStyle = () => {}; diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index d9948291b3cf0..cc0c5a89f7f57 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -16,7 +16,7 @@ import { HostText, } from 'shared/ReactTypeOfWork'; import SyntheticEvent from 'events/SyntheticEvent'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes'; diff --git a/packages/react-native-renderer/package.json b/packages/react-native-renderer/package.json index 73e282f2c2aee..d5157f1254e7e 100644 --- a/packages/react-native-renderer/package.json +++ b/packages/react-native-renderer/package.json @@ -4,7 +4,6 @@ "private": true, "repository": "facebook/react", "dependencies": { - "fbjs": "^0.8.16", "object-assign": "^4.1.1", "prop-types": "^15.6.0" }, diff --git a/packages/react-native-renderer/src/NativeMethodsMixin.js b/packages/react-native-renderer/src/NativeMethodsMixin.js index c7caa562c51b2..5c38b29656f20 100644 --- a/packages/react-native-renderer/src/NativeMethodsMixin.js +++ b/packages/react-native-renderer/src/NativeMethodsMixin.js @@ -15,7 +15,7 @@ import type { ReactNativeBaseComponentViewConfig, } from './ReactNativeTypes'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Modules provided by RN: import TextInputState from 'TextInputState'; import UIManager from 'UIManager'; diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 0634921b68fec..63cc05480b532 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -25,7 +25,7 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState'; import getComponentName from 'shared/getComponentName'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; const findHostInstance = ReactFabricRenderer.findHostInstance; diff --git a/packages/react-native-renderer/src/ReactFabricComponentTree.js b/packages/react-native-renderer/src/ReactFabricComponentTree.js index 23f5ce9b950ea..4eca1b8fd9171 100644 --- a/packages/react-native-renderer/src/ReactFabricComponentTree.js +++ b/packages/react-native-renderer/src/ReactFabricComponentTree.js @@ -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'; function getInstanceFromInstance(instanceHandle) { return instanceHandle; diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index ef4525d8e5cc7..65443762b1b80 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -21,7 +21,7 @@ import * as ReactNativeFrameScheduling from './ReactNativeFrameScheduling'; import * as ReactNativeViewConfigRegistry from 'ReactNativeViewConfigRegistry'; import deepFreezeAndThrowOnMutationInDev from 'deepFreezeAndThrowOnMutationInDev'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import {dispatchEvent} from './ReactFabricEventEmitter'; diff --git a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js index 59cd7c8f28b2f..f932968c45c89 100644 --- a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js @@ -15,7 +15,7 @@ import { import type {TopLevelType} from 'events/TopLevelEventTypes'; import * as ReactNativeViewConfigRegistry from 'ReactNativeViewConfigRegistry'; import SyntheticEvent from 'events/SyntheticEvent'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; const { customBubblingEventTypes, diff --git a/packages/react-native-renderer/src/ReactNativeComponentTree.js b/packages/react-native-renderer/src/ReactNativeComponentTree.js index 32554cd0bc7c2..cd1e50f3b8d20 100644 --- a/packages/react-native-renderer/src/ReactNativeComponentTree.js +++ b/packages/react-native-renderer/src/ReactNativeComponentTree.js @@ -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'; const instanceCache = {}; const instanceProps = {}; diff --git a/packages/react-native-renderer/src/ReactNativeEventEmitter.js b/packages/react-native-renderer/src/ReactNativeEventEmitter.js index 6b61de63319bd..760887abba5c5 100644 --- a/packages/react-native-renderer/src/ReactNativeEventEmitter.js +++ b/packages/react-native-renderer/src/ReactNativeEventEmitter.js @@ -10,7 +10,7 @@ import {getListener, runExtractedEventsInBatch} from 'events/EventPluginHub'; import {registrationNameModules} from 'events/EventPluginRegistry'; import {batchedUpdates} from 'events/ReactGenericBatching'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; import {getInstanceFromNode} from './ReactNativeComponentTree'; diff --git a/packages/react-native-renderer/src/ReactNativeFiberInspector.js b/packages/react-native-renderer/src/ReactNativeFiberInspector.js index 169e2f40ad25f..766e05760e4a8 100644 --- a/packages/react-native-renderer/src/ReactNativeFiberInspector.js +++ b/packages/react-native-renderer/src/ReactNativeFiberInspector.js @@ -15,7 +15,7 @@ import { } from 'react-reconciler/reflection'; import getComponentName from 'shared/getComponentName'; import {HostComponent} from 'shared/ReactTypeOfWork'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Module provided by RN: import UIManager from 'UIManager'; diff --git a/packages/react-native-renderer/src/ReactNativeHostConfig.js b/packages/react-native-renderer/src/ReactNativeHostConfig.js index 03ce2dc6e023d..8c01e0ec942db 100644 --- a/packages/react-native-renderer/src/ReactNativeHostConfig.js +++ b/packages/react-native-renderer/src/ReactNativeHostConfig.js @@ -9,7 +9,7 @@ import type {ReactNativeBaseComponentViewConfig} from './ReactNativeTypes'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Modules provided by RN: import UIManager from 'UIManager'; diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index 6ddc034282d84..9ff1749c50b84 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -28,7 +28,7 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState'; import getComponentName from 'shared/getComponentName'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; const findHostInstance = ReactNativeFiberRenderer.findHostInstance; diff --git a/packages/react-native-renderer/src/__mocks__/FabricUIManager.js b/packages/react-native-renderer/src/__mocks__/FabricUIManager.js index 3fcf573ab8a50..6e5a2690795d4 100644 --- a/packages/react-native-renderer/src/__mocks__/FabricUIManager.js +++ b/packages/react-native-renderer/src/__mocks__/FabricUIManager.js @@ -9,7 +9,7 @@ // Mock of the Native Hooks -const invariant = require('fbjs/lib/invariant'); +import invariant from 'shared/invariant'; const roots = new Map(); const allocatedTags = new Set(); diff --git a/packages/react-native-renderer/src/__mocks__/ReactNativeViewConfigRegistry.js b/packages/react-native-renderer/src/__mocks__/ReactNativeViewConfigRegistry.js index c8ed940a86095..63476367e5d06 100644 --- a/packages/react-native-renderer/src/__mocks__/ReactNativeViewConfigRegistry.js +++ b/packages/react-native-renderer/src/__mocks__/ReactNativeViewConfigRegistry.js @@ -13,7 +13,7 @@ import type { ViewConfigGetter, } from './ReactNativeTypes'; -const invariant = require('fbjs/lib/invariant'); +import invariant from 'shared/invariant'; // Event configs const customBubblingEventTypes = {}; diff --git a/packages/react-native-renderer/src/__mocks__/UIManager.js b/packages/react-native-renderer/src/__mocks__/UIManager.js index 4a234fbdc11ee..b3f7ac6c5fa7d 100644 --- a/packages/react-native-renderer/src/__mocks__/UIManager.js +++ b/packages/react-native-renderer/src/__mocks__/UIManager.js @@ -9,7 +9,7 @@ // Mock of the Native Hooks -const invariant = require('fbjs/lib/invariant'); +import invariant from 'shared/invariant'; // Map of viewTag -> {children: [childTag], parent: ?parentTag} const roots = []; diff --git a/packages/react-noop-renderer/package.json b/packages/react-noop-renderer/package.json index 25b3a429e5614..99b44fd28983c 100644 --- a/packages/react-noop-renderer/package.json +++ b/packages/react-noop-renderer/package.json @@ -7,7 +7,6 @@ "repository": "facebook/react", "license": "MIT", "dependencies": { - "fbjs": "^0.8.16", "object-assign": "^4.1.1", "prop-types": "^15.6.0", "regenerator-runtime": "^0.11.0", diff --git a/packages/react-reconciler/package.json b/packages/react-reconciler/package.json index 586796e2fb254..d6acdf4c7aebd 100644 --- a/packages/react-reconciler/package.json +++ b/packages/react-reconciler/package.json @@ -25,7 +25,6 @@ "react": "^16.0.0" }, "dependencies": { - "fbjs": "^0.8.16", "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.0" diff --git a/packages/react-reconciler/src/ReactChildFiber.js b/packages/react-reconciler/src/ReactChildFiber.js index 3caf4db2a14e0..19bdfbd0598eb 100644 --- a/packages/react-reconciler/src/ReactChildFiber.js +++ b/packages/react-reconciler/src/ReactChildFiber.js @@ -28,8 +28,8 @@ import { Fragment, } from 'shared/ReactTypeOfWork'; import {getStackAddendumByWorkInProgressFiber} from 'shared/ReactFiberComponentTreeHook'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import { createWorkInProgress, diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js index 34ee91645d79f..2b29ea79aae5b 100644 --- a/packages/react-reconciler/src/ReactFiber.js +++ b/packages/react-reconciler/src/ReactFiber.js @@ -15,7 +15,7 @@ import type {TypeOfSideEffect} from 'shared/ReactTypeOfSideEffect'; import type {ExpirationTime} from './ReactFiberExpirationTime'; import type {UpdateQueue} from './ReactUpdateQueue'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import {enableProfilerTimer} from 'shared/ReactFeatureFlags'; import {NoEffect} from 'shared/ReactTypeOfSideEffect'; import { diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js index 135e85bb0ba6c..d2573168ec343 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -46,10 +46,10 @@ import { debugRenderPhaseSideEffectsForStrictMode, enableProfilerTimer, } from 'shared/ReactFeatureFlags'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import getComponentName from 'shared/getComponentName'; import ReactStrictModeWarnings from './ReactStrictModeWarnings'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; import ReactDebugCurrentFiber from './ReactDebugCurrentFiber'; import {cancelWorkTimer} from './ReactDebugFiberPerf'; diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js index a158b9c0d16cc..444bd104c232b 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.js @@ -22,8 +22,8 @@ import {isMounted} from 'react-reconciler/reflection'; import * as ReactInstanceMap from 'shared/ReactInstanceMap'; import shallowEqual from 'shared/shallowEqual'; import getComponentName from 'shared/getComponentName'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf'; import {StrictMode} from './ReactTypeOfMode'; diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index f9a3dce20044d..786c745b42898 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -38,8 +38,8 @@ import { Update, } from 'shared/ReactTypeOfSideEffect'; import {commitUpdateQueue} from './ReactUpdateQueue'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import {onCommitUnmount} from './ReactFiberDevToolsHook'; import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf'; diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.js b/packages/react-reconciler/src/ReactFiberCompleteWork.js index d9b469c94d1bc..e8db8f19e8432 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.js @@ -39,7 +39,7 @@ import { } from 'shared/ReactTypeOfWork'; import {Placement, Ref, Update} from 'shared/ReactTypeOfSideEffect'; import {ProfileMode} from './ReactTypeOfMode'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import { createInstance, diff --git a/packages/react-reconciler/src/ReactFiberContext.js b/packages/react-reconciler/src/ReactFiberContext.js index 5cad370b96b31..1a1a30f35e014 100644 --- a/packages/react-reconciler/src/ReactFiberContext.js +++ b/packages/react-reconciler/src/ReactFiberContext.js @@ -13,8 +13,8 @@ import type {StackCursor} from './ReactFiberStack'; import {isFiberMounted} from 'react-reconciler/reflection'; import {ClassComponent, HostRoot} from 'shared/ReactTypeOfWork'; import getComponentName from 'shared/getComponentName'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import checkPropTypes from 'prop-types/checkPropTypes'; import ReactDebugCurrentFiber from './ReactDebugCurrentFiber'; diff --git a/packages/react-reconciler/src/ReactFiberDevToolsHook.js b/packages/react-reconciler/src/ReactFiberDevToolsHook.js index e7d77fd99cc9e..dd58854070103 100644 --- a/packages/react-reconciler/src/ReactFiberDevToolsHook.js +++ b/packages/react-reconciler/src/ReactFiberDevToolsHook.js @@ -10,7 +10,7 @@ import type {Fiber} from './ReactFiber'; import type {FiberRoot} from './ReactFiberRoot'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void; diff --git a/packages/react-reconciler/src/ReactFiberHostConfig.js b/packages/react-reconciler/src/ReactFiberHostConfig.js index d06b75b9a4965..c55a36c9b8ff1 100644 --- a/packages/react-reconciler/src/ReactFiberHostConfig.js +++ b/packages/react-reconciler/src/ReactFiberHostConfig.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // We expect that our Rollup, Jest, and Flow configurations // always shim this module with the corresponding host config diff --git a/packages/react-reconciler/src/ReactFiberHostContext.js b/packages/react-reconciler/src/ReactFiberHostContext.js index 4f091e610b559..500d5815ad614 100644 --- a/packages/react-reconciler/src/ReactFiberHostContext.js +++ b/packages/react-reconciler/src/ReactFiberHostContext.js @@ -11,7 +11,7 @@ import type {Fiber} from './ReactFiber'; import type {StackCursor} from './ReactFiberStack'; import type {Container, HostContext} from './ReactFiberHostConfig'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import {getChildHostContext, getRootHostContext} from './ReactFiberHostConfig'; import {createCursor, push, pop} from './ReactFiberStack'; diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.js b/packages/react-reconciler/src/ReactFiberHydrationContext.js index bc4b9eae80e77..8983333a308d5 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.js @@ -18,7 +18,7 @@ import type { import {HostComponent, HostText, HostRoot} from 'shared/ReactTypeOfWork'; import {Deletion, Placement} from 'shared/ReactTypeOfSideEffect'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import {createFiberFromHostInstanceForDeletion} from './ReactFiber'; import { diff --git a/packages/react-reconciler/src/ReactFiberNewContext.js b/packages/react-reconciler/src/ReactFiberNewContext.js index f2715acfb2751..4826412dded63 100644 --- a/packages/react-reconciler/src/ReactFiberNewContext.js +++ b/packages/react-reconciler/src/ReactFiberNewContext.js @@ -18,7 +18,7 @@ export type NewContext = { getContextChangedBits(context: ReactContext): number, }; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; import {isPrimaryRenderer} from './ReactFiberHostConfig'; import {createCursor, push, pop} from './ReactFiberStack'; diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 61ed86e323cb2..3e1c36866fc87 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -25,8 +25,8 @@ import { import * as ReactInstanceMap from 'shared/ReactInstanceMap'; import {HostComponent} from 'shared/ReactTypeOfWork'; import getComponentName from 'shared/getComponentName'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import {getPublicInstance} from './ReactFiberHostConfig'; import { diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 92b83f4414044..1272f69f9662b 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -45,8 +45,8 @@ import { warnAboutLegacyContextAPI, } from 'shared/ReactFeatureFlags'; import getComponentName from 'shared/getComponentName'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import ReactFiberInstrumentation from './ReactFiberInstrumentation'; import ReactDebugCurrentFiber from './ReactDebugCurrentFiber'; diff --git a/packages/react-reconciler/src/ReactFiberStack.js b/packages/react-reconciler/src/ReactFiberStack.js index 9c45e11d1f719..c108e89891784 100644 --- a/packages/react-reconciler/src/ReactFiberStack.js +++ b/packages/react-reconciler/src/ReactFiberStack.js @@ -9,7 +9,7 @@ import type {Fiber} from './ReactFiber'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; export type StackCursor = { current: T, diff --git a/packages/react-reconciler/src/ReactFiberTreeReflection.js b/packages/react-reconciler/src/ReactFiberTreeReflection.js index c988465b756f8..394a4b3871690 100644 --- a/packages/react-reconciler/src/ReactFiberTreeReflection.js +++ b/packages/react-reconciler/src/ReactFiberTreeReflection.js @@ -9,8 +9,8 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; import * as ReactInstanceMap from 'shared/ReactInstanceMap'; import {ReactCurrentOwner} from 'shared/ReactGlobalSharedState'; diff --git a/packages/react-reconciler/src/ReactProfilerTimer.js b/packages/react-reconciler/src/ReactProfilerTimer.js index 7877d7d2977ac..b1455195a8ede 100644 --- a/packages/react-reconciler/src/ReactProfilerTimer.js +++ b/packages/react-reconciler/src/ReactProfilerTimer.js @@ -12,7 +12,7 @@ import type {Fiber} from './ReactFiber'; import getComponentName from 'shared/getComponentName'; import {enableProfilerTimer} from 'shared/ReactFeatureFlags'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; import {now} from './ReactFiberHostConfig'; export type ProfilerTimer = { diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index 9ca543583cf01..365f4bf4d6f00 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -13,7 +13,7 @@ import getComponentName from 'shared/getComponentName'; import {getStackAddendumByWorkInProgressFiber} from 'shared/ReactFiberComponentTreeHook'; import {StrictMode} from './ReactTypeOfMode'; import lowPriorityWarning from 'shared/lowPriorityWarning'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; type LIFECYCLE = | 'UNSAFE_componentWillMount' diff --git a/packages/react-reconciler/src/ReactUpdateQueue.js b/packages/react-reconciler/src/ReactUpdateQueue.js index dc3791c4e1701..1e28051d58bef 100644 --- a/packages/react-reconciler/src/ReactUpdateQueue.js +++ b/packages/react-reconciler/src/ReactUpdateQueue.js @@ -102,8 +102,8 @@ import { import {StrictMode} from './ReactTypeOfMode'; -import invariant from 'fbjs/lib/invariant'; -import warning from 'fbjs/lib/warning'; +import invariant from 'shared/invariant'; +import warning from 'shared/warning'; export type Update = { expirationTime: ExpirationTime, diff --git a/packages/react-reconciler/src/forks/ReactFiberErrorDialog.www.js b/packages/react-reconciler/src/forks/ReactFiberErrorDialog.www.js index 16d9f71c4c999..433448e0c33e0 100644 --- a/packages/react-reconciler/src/forks/ReactFiberErrorDialog.www.js +++ b/packages/react-reconciler/src/forks/ReactFiberErrorDialog.www.js @@ -9,7 +9,7 @@ import type {CapturedError} from '../ReactCapturedValue'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Provided by www const ReactFiberErrorDialogWWW = require('ReactFiberErrorDialog'); diff --git a/packages/react-scheduler/package.json b/packages/react-scheduler/package.json index b5bc00dde16e0..633f48859bcd6 100644 --- a/packages/react-scheduler/package.json +++ b/packages/react-scheduler/package.json @@ -14,7 +14,6 @@ }, "homepage": "https://reactjs.org/", "dependencies": { - "fbjs": "^0.8.16", "object-assign": "^4.1.1" }, "files": [ diff --git a/packages/react-scheduler/src/ReactScheduler.js b/packages/react-scheduler/src/ReactScheduler.js index 4667cfc725ed8..2b016f1275739 100644 --- a/packages/react-scheduler/src/ReactScheduler.js +++ b/packages/react-scheduler/src/ReactScheduler.js @@ -42,7 +42,7 @@ type CallbackConfigType = {| export type CallbackIdType = CallbackConfigType; import {canUseDOM} from 'shared/ExecutionEnvironment'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; if (__DEV__) { if (canUseDOM && typeof requestAnimationFrame !== 'function') { diff --git a/packages/react-test-renderer/package.json b/packages/react-test-renderer/package.json index 6aafaf967b7cf..e1139ddf11e42 100644 --- a/packages/react-test-renderer/package.json +++ b/packages/react-test-renderer/package.json @@ -15,7 +15,6 @@ }, "homepage": "https://reactjs.org/", "dependencies": { - "fbjs": "^0.8.16", "object-assign": "^4.1.1", "prop-types": "^15.6.0", "react-is": "^16.4.1" diff --git a/packages/react-test-renderer/src/ReactShallowRenderer.js b/packages/react-test-renderer/src/ReactShallowRenderer.js index 65020d4842b67..54f671e6607d0 100644 --- a/packages/react-test-renderer/src/ReactShallowRenderer.js +++ b/packages/react-test-renderer/src/ReactShallowRenderer.js @@ -11,7 +11,7 @@ import {isForwardRef} from 'react-is'; import describeComponentFrame from 'shared/describeComponentFrame'; import getComponentName from 'shared/getComponentName'; import shallowEqual from 'shared/shallowEqual'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import checkPropTypes from 'prop-types/checkPropTypes'; const emptyObject = {}; diff --git a/packages/react-test-renderer/src/ReactTestRenderer.js b/packages/react-test-renderer/src/ReactTestRenderer.js index 711f8f6a5e2bb..669e1e7abd5f8 100644 --- a/packages/react-test-renderer/src/ReactTestRenderer.js +++ b/packages/react-test-renderer/src/ReactTestRenderer.js @@ -28,7 +28,7 @@ import { ForwardRef, Profiler, } from 'shared/ReactTypeOfWork'; -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import * as ReactTestHostConfig from './ReactTestHostConfig'; import * as TestRendererScheduling from './ReactTestRendererScheduling'; diff --git a/packages/react/package.json b/packages/react/package.json index a69208d563519..f5a8ecd12552d 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -21,7 +21,6 @@ "node": ">=0.10.0" }, "dependencies": { - "fbjs": "^0.8.16", "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.0" diff --git a/packages/react/src/ReactBaseClasses.js b/packages/react/src/ReactBaseClasses.js index 3f92549e1a6cf..e1682d128ee60 100644 --- a/packages/react/src/ReactBaseClasses.js +++ b/packages/react/src/ReactBaseClasses.js @@ -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 lowPriorityWarning from 'shared/lowPriorityWarning'; import ReactNoopUpdateQueue from './ReactNoopUpdateQueue'; diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index e01f765c9ba01..0bbe5bee14de4 100644 --- a/packages/react/src/ReactChildren.js +++ b/packages/react/src/ReactChildren.js @@ -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 { getIteratorFn, REACT_ELEMENT_TYPE, diff --git a/packages/react/src/ReactContext.js b/packages/react/src/ReactContext.js index d15163e81346c..4c1b06bfed5d3 100644 --- a/packages/react/src/ReactContext.js +++ b/packages/react/src/ReactContext.js @@ -11,7 +11,7 @@ import {REACT_PROVIDER_TYPE, REACT_CONTEXT_TYPE} from 'shared/ReactSymbols'; import type {ReactContext} from 'shared/ReactTypes'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; export function createContext( defaultValue: T, diff --git a/packages/react/src/ReactElement.js b/packages/react/src/ReactElement.js index 9127453b9b55e..80cd607956990 100644 --- a/packages/react/src/ReactElement.js +++ b/packages/react/src/ReactElement.js @@ -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 {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; import ReactCurrentOwner from './ReactCurrentOwner'; diff --git a/packages/react/src/ReactElementValidator.js b/packages/react/src/ReactElementValidator.js index 35dc391f435a2..f0ea9601b8a37 100644 --- a/packages/react/src/ReactElementValidator.js +++ b/packages/react/src/ReactElementValidator.js @@ -22,7 +22,7 @@ import { REACT_FRAGMENT_TYPE, } from 'shared/ReactSymbols'; import checkPropTypes from 'prop-types/checkPropTypes'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; import ReactCurrentOwner from './ReactCurrentOwner'; import {isValidElement, createElement, cloneElement} from './ReactElement'; diff --git a/packages/react/src/ReactNoopUpdateQueue.js b/packages/react/src/ReactNoopUpdateQueue.js index ffd47dacb483a..d21cd561ce35d 100644 --- a/packages/react/src/ReactNoopUpdateQueue.js +++ b/packages/react/src/ReactNoopUpdateQueue.js @@ -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'; const didWarnStateUpdateForUnmountedComponent = {}; diff --git a/packages/react/src/forwardRef.js b/packages/react/src/forwardRef.js index 6c3c1a4343ba9..419af668a3049 100644 --- a/packages/react/src/forwardRef.js +++ b/packages/react/src/forwardRef.js @@ -7,7 +7,7 @@ import {REACT_FORWARD_REF_TYPE} from 'shared/ReactSymbols'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; export default function forwardRef( render: (props: Props, ref: React$ElementRef) => React$Node, diff --git a/packages/shared/HostConfigWithNoHydration.js b/packages/shared/HostConfigWithNoHydration.js index 9458bd50aee83..66bd02fb1b732 100644 --- a/packages/shared/HostConfigWithNoHydration.js +++ b/packages/shared/HostConfigWithNoHydration.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Renderers that don't support hydration // can re-export everything from this module. diff --git a/packages/shared/HostConfigWithNoMutation.js b/packages/shared/HostConfigWithNoMutation.js index 5bce3c671df4f..bb0b7f425b6f6 100644 --- a/packages/shared/HostConfigWithNoMutation.js +++ b/packages/shared/HostConfigWithNoMutation.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Renderers that don't support mutation // can re-export everything from this module. diff --git a/packages/shared/HostConfigWithNoPersistence.js b/packages/shared/HostConfigWithNoPersistence.js index 83e845d6e73ca..1977cb2f7911f 100644 --- a/packages/shared/HostConfigWithNoPersistence.js +++ b/packages/shared/HostConfigWithNoPersistence.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Renderers that don't support persistence // can re-export everything from this module. diff --git a/packages/shared/ReactErrorUtils.js b/packages/shared/ReactErrorUtils.js index 2373e2527ed6f..ef3cb31a78370 100644 --- a/packages/shared/ReactErrorUtils.js +++ b/packages/shared/ReactErrorUtils.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import invokeGuardedCallback from './invokeGuardedCallback'; const ReactErrorUtils = { diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 003d96fe9522f..b3d2b48500549 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; // Exports ReactDOM.createRoot export const enableUserTimingAPI = __DEV__; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js index 1d45d79c79b2a..bd557015195fb 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fabric-fb.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-fb'; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js b/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js index 80aa2d7e46f86..ea6c7cf6d9ec1 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fabric-oss.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as FabricFeatureFlagsType from './ReactFeatureFlags.native-fabric-oss'; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index d36c0143c1c51..b0fdc77f3a51e 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-fb'; diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index 5f4511c8ddda9..3c2b19bf1b580 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as FeatureFlagsShimType from './ReactFeatureFlags.native-oss'; diff --git a/packages/shared/forks/ReactFeatureFlags.persistent.js b/packages/shared/forks/ReactFeatureFlags.persistent.js index 8203c2c9317f5..88773cf900b3b 100644 --- a/packages/shared/forks/ReactFeatureFlags.persistent.js +++ b/packages/shared/forks/ReactFeatureFlags.persistent.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persistent'; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index 70f055d5a228d..1bc79a7b3f440 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; import typeof * as FeatureFlagsType from 'shared/ReactFeatureFlags'; import typeof * as PersistentFeatureFlagsType from './ReactFeatureFlags.persistent'; diff --git a/packages/shared/forks/invariant.www.js b/packages/shared/forks/invariant.www.js new file mode 100644 index 0000000000000..c2611b4cae68e --- /dev/null +++ b/packages/shared/forks/invariant.www.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default require('invariant'); diff --git a/packages/shared/forks/invokeGuardedCallback.www.js b/packages/shared/forks/invokeGuardedCallback.www.js index 3cbe0d6536c9e..c90129f441837 100644 --- a/packages/shared/forks/invokeGuardedCallback.www.js +++ b/packages/shared/forks/invokeGuardedCallback.www.js @@ -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'; const invokeGuardedCallback = require('ReactFbErrorUtils') .invokeGuardedCallback; diff --git a/packages/shared/forks/warning.www.js b/packages/shared/forks/warning.www.js new file mode 100644 index 0000000000000..f47643d294685 --- /dev/null +++ b/packages/shared/forks/warning.www.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default require('warning'); diff --git a/packages/shared/invariant.js b/packages/shared/invariant.js new file mode 100644 index 0000000000000..4cea6d7c73054 --- /dev/null +++ b/packages/shared/invariant.js @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +let validateFormat = () => {}; + +if (__DEV__) { + validateFormat = function(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +export default function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + let error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.', + ); + } else { + const args = [a, b, c, d, e, f]; + let argIndex = 0; + error = new Error( + format.replace(/%s/g, function() { + return args[argIndex++]; + }), + ); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} diff --git a/packages/shared/invokeGuardedCallback.js b/packages/shared/invokeGuardedCallback.js index 6ad3bbc6e0d97..fa6ee451c9193 100644 --- a/packages/shared/invokeGuardedCallback.js +++ b/packages/shared/invokeGuardedCallback.js @@ -7,7 +7,7 @@ * @flow */ -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; let invokeGuardedCallback = function( name: string | null, diff --git a/packages/shared/reactProdInvariant.js b/packages/shared/reactProdInvariant.js index 476e440d543fc..a75c9b106dbf8 100644 --- a/packages/shared/reactProdInvariant.js +++ b/packages/shared/reactProdInvariant.js @@ -9,7 +9,7 @@ // Relying on the `invariant()` implementation lets us // have preserve the format and params in the www builds. -import invariant from 'fbjs/lib/invariant'; +import invariant from 'shared/invariant'; /** * WARNING: DO NOT manually require this module. diff --git a/packages/shared/warning.js b/packages/shared/warning.js new file mode 100644 index 0000000000000..4a8ef4e465c74 --- /dev/null +++ b/packages/shared/warning.js @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +let warning = () => {}; + +if (__DEV__) { + const printWarning = function(format, ...args) { + let argIndex = 0; + const message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; + + warning = function(condition, format, ...args) { + if (format === undefined) { + throw new Error( + '`warning(condition, format, ...args)` requires a warning ' + + 'message argument', + ); + } + if (!condition) { + printWarning(format, ...args); + } + }; +} + +export default warning; diff --git a/packages/simple-cache-provider/package.json b/packages/simple-cache-provider/package.json index f785df0f2eca2..97458201d51df 100644 --- a/packages/simple-cache-provider/package.json +++ b/packages/simple-cache-provider/package.json @@ -9,9 +9,6 @@ "index.js", "cjs/" ], - "dependencies": { - "fbjs": "^0.8.16" - }, "peerDependencies": { "react": "^16.3.0-alpha.1" } diff --git a/packages/simple-cache-provider/src/SimpleCacheProvider.js b/packages/simple-cache-provider/src/SimpleCacheProvider.js index b10721bd9f345..13620cced1095 100644 --- a/packages/simple-cache-provider/src/SimpleCacheProvider.js +++ b/packages/simple-cache-provider/src/SimpleCacheProvider.js @@ -8,7 +8,7 @@ */ import React from 'react'; -import warning from 'fbjs/lib/warning'; +import warning from 'shared/warning'; function noop() {} diff --git a/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js b/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js index fe92a70dbcf9d..c37bef2793b74 100644 --- a/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js +++ b/scripts/error-codes/__tests__/replace-invariant-error-codes-test.js @@ -35,10 +35,10 @@ describe('error codes transform', () => { it('should replace simple invariant calls', () => { compare( - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + "invariant(condition, 'Do not override existing functions.');", "import _prodInvariant from 'shared/reactProdInvariant';\n" + - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + '!condition ? ' + '__DEV__ ? ' + "invariant(false, 'Do not override existing functions.') : " + @@ -54,11 +54,11 @@ describe('error codes transform', () => { `_prodInvariant('16') : void 0;`; compare( - `import invariant from 'invariant'; + `import invariant from 'shared/invariant'; invariant(condition, 'Do not override existing functions.'); invariant(condition, 'Do not override existing functions.');`, `import _prodInvariant from 'shared/reactProdInvariant'; -import invariant from 'invariant'; +import invariant from 'shared/invariant'; ${expectedInvariantTransformResult} ${expectedInvariantTransformResult}` ); @@ -66,10 +66,10 @@ ${expectedInvariantTransformResult}` it('should support invariant calls with args', () => { compare( - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + "invariant(condition, 'Expected %s target to be an array; got %s', 'foo', 'bar');", "import _prodInvariant from 'shared/reactProdInvariant';\n" + - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + '!condition ? ' + '__DEV__ ? ' + "invariant(false, 'Expected %s target to be an array; got %s', 'foo', 'bar') : " + @@ -79,10 +79,10 @@ ${expectedInvariantTransformResult}` it('should support invariant calls with a concatenated template string and args', () => { compare( - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + "invariant(condition, 'Expected a component class, ' + 'got %s.' + '%s', 'Foo', 'Bar');", "import _prodInvariant from 'shared/reactProdInvariant';\n" + - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + '!condition ? ' + '__DEV__ ? ' + "invariant(false, 'Expected a component class, got %s.%s', 'Foo', 'Bar') : " + @@ -92,10 +92,10 @@ ${expectedInvariantTransformResult}` it('should correctly transform invariants that are not in the error codes map', () => { compare( - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + "invariant(condition, 'This is not a real error message.');", "import _prodInvariant from 'shared/reactProdInvariant';\n" + - "import invariant from 'shared/reactProdInvariant';\n" + + "import invariant from 'shared/invariant';\n" + "!condition ? invariant(false, 'This is not a real error message.') : void 0;" ); }); diff --git a/scripts/release/config.js b/scripts/release/config.js index e270967cbc00d..e58462c43ac77 100644 --- a/scripts/release/config.js +++ b/scripts/release/config.js @@ -1,6 +1,6 @@ 'use strict'; -const dependencies = ['fbjs', 'object-assign', 'prop-types']; +const dependencies = ['object-assign', 'prop-types']; const paramDefinitions = [ { diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index cafea350e872d..7b4774506a7a9 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -237,6 +237,20 @@ function isProfilingBundleType(bundleType) { } } +function blacklistFBJS() { + return { + name: 'blacklistFBJS', + resolveId(importee, importer) { + if (/^fbjs\//.test(importee)) { + throw new Error( + `Don't import ${importee} (found in ${importer}). ` + + `Use the utilities in packages/shared/ instead.` + ); + } + }, + }; +} + function getPlugins( entry, externals, @@ -252,7 +266,7 @@ function getPlugins( const forks = Modules.getForks(bundleType, entry, moduleType); const isProduction = isProductionBundleType(bundleType); const isProfiling = isProfilingBundleType(bundleType); - const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD; + const isUMDBundle = bundleType === UMD_DEV || bundleType === UMD_PROD; const isFBBundle = bundleType === FB_WWW_DEV || bundleType === FB_WWW_PROD; const isRNBundle = bundleType === RN_OSS_DEV || @@ -271,6 +285,9 @@ function getPlugins( }, // Shim any modules that need forking in this environment. useForks(forks), + // Ensure we don't try to bundle any fbjs modules + // unless they're transitive (e.g. through prop-types). + !isUMDBundle && blacklistFBJS(), // Use Node resolution mechanism. resolve({ skip: externals, @@ -309,7 +326,7 @@ function getPlugins( Object.assign({}, closureOptions, { // Don't let it create global variables in the browser. // https://github.com/facebook/react/issues/10909 - assume_function_wrapper: !isInGlobalScope, + assume_function_wrapper: !isUMDBundle, // Works because `google-closure-compiler-js` is forked in Yarn lockfile. // We can remove this if GCC merges my PR: // https://github.com/google/closure-compiler/pull/2707 diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 4c9802b3698d8..64def9eb877ec 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -91,6 +91,17 @@ const forks = Object.freeze({ } }, + // This logic is forked on www to fork the formatting function. + 'shared/invariant': (bundleType, entry) => { + switch (bundleType) { + case FB_WWW_DEV: + case FB_WWW_PROD: + return 'shared/forks/invariant.www.js'; + default: + return null; + } + }, + // This logic is forked on www to blacklist warnings. 'shared/lowPriorityWarning': (bundleType, entry) => { switch (bundleType) { @@ -102,6 +113,17 @@ const forks = Object.freeze({ } }, + // This logic is forked on www to blacklist warnings. + 'shared/warning': (bundleType, entry) => { + switch (bundleType) { + case FB_WWW_DEV: + case FB_WWW_PROD: + return 'shared/forks/warning.www.js'; + default: + return null; + } + }, + // In FB bundles, we preserve an inline require to ReactCurrentOwner. // See the explanation in FB version of ReactCurrentOwner in www: 'react/src/ReactCurrentOwner': (bundleType, entry) => { diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index 598d7aa85e450..f814bc195e83f 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -12,11 +12,7 @@ const UMD_PROD = bundleTypes.UMD_PROD; const HAS_NO_SIDE_EFFECTS_ON_IMPORT = false; // const HAS_SIDE_EFFECTS_ON_IMPORT = true; const importSideEffects = Object.freeze({ - 'fbjs/lib/invariant': HAS_NO_SIDE_EFFECTS_ON_IMPORT, - 'fbjs/lib/warning': HAS_NO_SIDE_EFFECTS_ON_IMPORT, 'prop-types/checkPropTypes': HAS_NO_SIDE_EFFECTS_ON_IMPORT, - 'fbjs/lib/camelizeStyleName': HAS_NO_SIDE_EFFECTS_ON_IMPORT, - 'fbjs/lib/hyphenateStyleName': HAS_NO_SIDE_EFFECTS_ON_IMPORT, deepFreezeAndThrowOnMutationInDev: HAS_NO_SIDE_EFFECTS_ON_IMPORT, });