diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 2e5ce598e5ab..666585ab5741 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -130,7 +130,7 @@ const bundles = [ /******* React DOM Server *******/ { babelOpts: babelOptsReact, - bundleTypes: [FB_DEV, FB_PROD], + bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD], config: { destDir: 'build/', globals: { @@ -142,33 +142,7 @@ const bundles = [ entry: 'src/renderers/dom/ReactDOMServer.js', externals: ['prop-types', 'prop-types/checkPropTypes'], fbEntry: 'src/renderers/dom/ReactDOMServer.js', - hasteName: 'ReactDOMServerStack', - isRenderer: true, - label: 'dom-server-stack', - manglePropertiesOnProd: false, - name: 'react-dom-stack/server', - paths: [ - 'src/renderers/dom/**/*.js', - 'src/renderers/shared/**/*.js', - 'src/ReactVersion.js', - 'src/shared/**/*.js', - ], - }, - { - babelOpts: babelOptsReact, - bundleTypes: [UMD_DEV, UMD_PROD, NODE_DEV, NODE_PROD, FB_DEV, FB_PROD], - config: { - destDir: 'build/', - globals: { - react: 'React', - }, - moduleName: 'ReactDOMServer', - sourceMap: false, - }, - entry: 'src/renderers/dom/ReactDOMServerStream.js', - externals: ['prop-types', 'prop-types/checkPropTypes'], - fbEntry: 'src/renderers/dom/ReactDOMServerStream.js', - hasteName: 'ReactDOMServerStream', + hasteName: 'ReactDOMServer', isRenderer: true, label: 'dom-server-stream', manglePropertiesOnProd: false, diff --git a/src/node_modules/react-dom/lib/ReactDOM.js b/src/node_modules/react-dom/lib/ReactDOM.js deleted file mode 100644 index 2cee4e3abeff..000000000000 --- a/src/node_modules/react-dom/lib/ReactDOM.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactDOM'); diff --git a/src/node_modules/react-dom/lib/ReactDOMServer.js b/src/node_modules/react-dom/lib/ReactDOMServer.js deleted file mode 100644 index e02fa01f4091..000000000000 --- a/src/node_modules/react-dom/lib/ReactDOMServer.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactDOMServer'); diff --git a/src/node_modules/react-dom/lib/ReactInstanceMap.js b/src/node_modules/react-dom/lib/ReactInstanceMap.js deleted file mode 100644 index 7e3afdf6cd02..000000000000 --- a/src/node_modules/react-dom/lib/ReactInstanceMap.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactInstanceMap'); diff --git a/src/node_modules/react-dom/lib/ReactPerf.js b/src/node_modules/react-dom/lib/ReactPerf.js deleted file mode 100644 index a0793939a16b..000000000000 --- a/src/node_modules/react-dom/lib/ReactPerf.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactPerf'); diff --git a/src/node_modules/react-dom/lib/ReactTestUtils.js b/src/node_modules/react-dom/lib/ReactTestUtils.js deleted file mode 100644 index ef0d67875e4e..000000000000 --- a/src/node_modules/react-dom/lib/ReactTestUtils.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactTestUtils'); diff --git a/src/node_modules/react-dom/lib/getVendorPrefixedEventName.js b/src/node_modules/react-dom/lib/getVendorPrefixedEventName.js deleted file mode 100644 index 68c931aa4922..000000000000 --- a/src/node_modules/react-dom/lib/getVendorPrefixedEventName.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('getVendorPrefixedEventName'); diff --git a/src/node_modules/react/lib/ReactComponentTreeHook.js b/src/node_modules/react/lib/ReactComponentTreeHook.js deleted file mode 100644 index fe857e7bae3c..000000000000 --- a/src/node_modules/react/lib/ReactComponentTreeHook.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactComponentTreeHook'); diff --git a/src/node_modules/react/lib/ReactCurrentOwner.js b/src/node_modules/react/lib/ReactCurrentOwner.js deleted file mode 100644 index 54ae79f8db27..000000000000 --- a/src/node_modules/react/lib/ReactCurrentOwner.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactCurrentOwner'); diff --git a/src/node_modules/react/lib/ReactDebugCurrentFrame.js b/src/node_modules/react/lib/ReactDebugCurrentFrame.js deleted file mode 100644 index 79df08968327..000000000000 --- a/src/node_modules/react/lib/ReactDebugCurrentFrame.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright 2016-present Facebook. All Rights Reserved. - * - * @flow - */ - -'use strict'; - -module.exports = require('ReactDebugCurrentFrame'); diff --git a/src/renderers/dom/ReactDOMServer.js b/src/renderers/dom/ReactDOMServer.js index 559fbe6bfdfc..81621d9f680a 100644 --- a/src/renderers/dom/ReactDOMServer.js +++ b/src/renderers/dom/ReactDOMServer.js @@ -12,28 +12,15 @@ 'use strict'; var ReactDOMInjection = require('ReactDOMInjection'); -var ReactDOMStackInjection = require('ReactDOMStackInjection'); -var ReactServerRendering = require('ReactServerRendering'); +var ReactServerRenderer = require('ReactServerRenderer'); var ReactVersion = require('ReactVersion'); ReactDOMInjection.inject(); -ReactDOMStackInjection.inject(); var ReactDOMServer = { - renderToString: ReactServerRendering.renderToString, - renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup, + renderToString: ReactServerRenderer.renderToString, + renderToStaticMarkup: ReactServerRenderer.renderToStaticMarkup, version: ReactVersion, }; -if (__DEV__) { - var ReactInstrumentation = require('ReactInstrumentation'); - var ReactDOMUnknownPropertyHook = require('ReactDOMUnknownPropertyHook'); - var ReactDOMNullInputValuePropHook = require('ReactDOMNullInputValuePropHook'); - var ReactDOMInvalidARIAHook = require('ReactDOMInvalidARIAHook'); - - ReactInstrumentation.debugTool.addHook(ReactDOMUnknownPropertyHook); - ReactInstrumentation.debugTool.addHook(ReactDOMNullInputValuePropHook); - ReactInstrumentation.debugTool.addHook(ReactDOMInvalidARIAHook); -} - module.exports = ReactDOMServer; diff --git a/src/renderers/dom/ReactDOMServerStream.js b/src/renderers/dom/ReactDOMServerStream.js deleted file mode 100644 index c4c3abedf455..000000000000 --- a/src/renderers/dom/ReactDOMServerStream.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactDOMServerStream - */ - -'use strict'; - -var ReactDOMInjection = require('ReactDOMInjection'); -var ReactServerRenderer = require('ReactServerRenderer'); -var ReactVersion = require('ReactVersion'); - -ReactDOMInjection.inject(); - -var ReactDOMServer = { - renderToString: ReactServerRenderer.renderToString, - renderToStaticMarkup: ReactServerRenderer.renderToStaticMarkup, - version: ReactVersion, -}; - -module.exports = ReactDOMServer; diff --git a/src/renderers/dom/__mocks__/ReactDOMServer.js b/src/renderers/dom/__mocks__/ReactDOMServer.js deleted file mode 100644 index 7ba363afc59d..000000000000 --- a/src/renderers/dom/__mocks__/ReactDOMServer.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); - -var useFiber = ReactDOMFeatureFlags.useFiber; - -module.exports = useFiber - ? require('ReactDOMServerStream') - : require.requireActual('ReactDOMServer'); diff --git a/src/renderers/dom/stack/server/ReactServerBatchingStrategy.js b/src/renderers/dom/stack/server/ReactServerBatchingStrategy.js deleted file mode 100644 index 35fa02e57d7c..000000000000 --- a/src/renderers/dom/stack/server/ReactServerBatchingStrategy.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactServerBatchingStrategy - */ - -'use strict'; - -var ReactServerBatchingStrategy = { - isBatchingUpdates: false, - batchedUpdates: function(callback) { - // Don't do anything here. During the server rendering we don't want to - // schedule any updates. We will simply ignore them. - }, -}; - -module.exports = ReactServerBatchingStrategy; diff --git a/src/renderers/dom/stack/server/ReactServerRendering.js b/src/renderers/dom/stack/server/ReactServerRendering.js deleted file mode 100644 index e673b84ed3ee..000000000000 --- a/src/renderers/dom/stack/server/ReactServerRendering.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactServerRendering - */ -'use strict'; - -var React = require('react'); -var ReactDOMContainerInfo = require('ReactDOMContainerInfo'); -var ReactInstrumentation = require('ReactInstrumentation'); -var ReactMarkupChecksum = require('ReactMarkupChecksum'); -var ReactReconciler = require('ReactReconciler'); -var ReactServerBatchingStrategy = require('ReactServerBatchingStrategy'); -var ReactServerRenderingTransaction = require('ReactServerRenderingTransaction'); -var ReactUpdates = require('ReactUpdates'); - -var emptyObject = require('fbjs/lib/emptyObject'); -var instantiateReactComponent = require('instantiateReactComponent'); -var invariant = require('fbjs/lib/invariant'); - -var pendingTransactions = 0; - -/** - * @param {ReactElement} element - * @return {string} the HTML markup - */ -function renderToStringImpl(element, makeStaticMarkup) { - var transaction; - var previousBatchingStrategy; - try { - previousBatchingStrategy = ReactUpdates.injection.getBatchingStrategy(); - ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy); - - transaction = ReactServerRenderingTransaction.getPooled(makeStaticMarkup); - - pendingTransactions++; - - return transaction.perform(function() { - var componentInstance = instantiateReactComponent(element, true); - var markup = ReactReconciler.mountComponent( - componentInstance, - transaction, - null, - ReactDOMContainerInfo(), - emptyObject, - 0 /* parentDebugID */, - ); - if (__DEV__) { - ReactInstrumentation.debugTool.onUnmountComponent( - componentInstance._debugID, - ); - } - if (!makeStaticMarkup) { - markup = ReactMarkupChecksum.addChecksumToMarkup(markup); - } - return markup; - }, null); - } finally { - pendingTransactions--; - ReactServerRenderingTransaction.release(transaction); - // Revert to the DOM batching strategy since these two renderers - // currently share these stateful modules. - if (!pendingTransactions) { - ReactUpdates.injection.injectBatchingStrategy(previousBatchingStrategy); - } - } -} - -/** - * Render a ReactElement to its initial HTML. This should only be used on the - * server. - * See https://facebook.github.io/react/docs/react-dom-server.html#rendertostring - */ -function renderToString(element) { - invariant( - React.isValidElement(element), - 'renderToString(): You must pass a valid ReactElement.', - ); - return renderToStringImpl(element, false); -} - -/** - * Similar to renderToString, except this doesn't create extra DOM attributes - * such as data-react-id that React uses internally. - * See https://facebook.github.io/react/docs/react-dom-server.html#rendertostaticmarkup - */ -function renderToStaticMarkup(element) { - invariant( - React.isValidElement(element), - 'renderToStaticMarkup(): You must pass a valid ReactElement.', - ); - return renderToStringImpl(element, true); -} - -module.exports = { - renderToString: renderToString, - renderToStaticMarkup: renderToStaticMarkup, -}; diff --git a/src/renderers/dom/stack/server/ReactServerRenderingTransaction.js b/src/renderers/dom/stack/server/ReactServerRenderingTransaction.js deleted file mode 100644 index 2fa930cc43d2..000000000000 --- a/src/renderers/dom/stack/server/ReactServerRenderingTransaction.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactServerRenderingTransaction - */ - -'use strict'; - -var PooledClass = require('PooledClass'); -var Transaction = require('Transaction'); -var ReactInstrumentation = require('ReactInstrumentation'); -var ReactServerUpdateQueue = require('ReactServerUpdateQueue'); - -/** - * Executed within the scope of the `Transaction` instance. Consider these as - * being member methods, but with an implied ordering while being isolated from - * each other. - */ -var TRANSACTION_WRAPPERS = []; - -if (__DEV__) { - TRANSACTION_WRAPPERS.push({ - initialize: ReactInstrumentation.debugTool.onBeginFlush, - close: ReactInstrumentation.debugTool.onEndFlush, - }); -} - -var noopCallbackQueue = { - enqueue: function() {}, -}; - -/** - * @class ReactServerRenderingTransaction - * @param {boolean} renderToStaticMarkup - */ -function ReactServerRenderingTransaction(renderToStaticMarkup) { - this.reinitializeTransaction(); - this.renderToStaticMarkup = renderToStaticMarkup; - this.useCreateElement = false; - this.updateQueue = new ReactServerUpdateQueue(this); -} - -var Mixin = { - /** - * @see Transaction - * @abstract - * @final - * @return {array} Empty list of operation wrap procedures. - */ - getTransactionWrappers: function() { - return TRANSACTION_WRAPPERS; - }, - - /** - * @return {object} The queue to collect `onDOMReady` callbacks with. - */ - getReactMountReady: function() { - return noopCallbackQueue; - }, - - /** - * @return {object} The queue to collect React async events. - */ - getUpdateQueue: function() { - return this.updateQueue; - }, - - /** - * `PooledClass` looks for this, and will invoke this before allowing this - * instance to be reused. - */ - destructor: function() {}, - - checkpoint: function() {}, - - rollback: function() {}, -}; - -Object.assign(ReactServerRenderingTransaction.prototype, Transaction, Mixin); - -PooledClass.addPoolingTo(ReactServerRenderingTransaction); - -module.exports = ReactServerRenderingTransaction; diff --git a/src/renderers/dom/stack/server/ReactServerUpdateQueue.js b/src/renderers/dom/stack/server/ReactServerUpdateQueue.js deleted file mode 100644 index 35b064f54336..000000000000 --- a/src/renderers/dom/stack/server/ReactServerUpdateQueue.js +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactServerUpdateQueue - * @flow - */ - -'use strict'; - -var ReactUpdateQueue = require('ReactUpdateQueue'); - -var warning = require('fbjs/lib/warning'); - -import type {Transaction} from 'Transaction'; - -function warnNoop( - publicInstance: ReactComponent, - callerName: string, -) { - if (__DEV__) { - var constructor = publicInstance.constructor; - warning( - false, - '%s(...): Can only update a mounting component. ' + - 'This usually means you called %s() outside componentWillMount() on the server. ' + - 'This is a no-op.\n\nPlease check the code for the %s component.', - callerName, - callerName, - (constructor && (constructor.displayName || constructor.name)) || - 'ReactClass', - ); - } -} - -/** - * This is the update queue used for server rendering. - * It delegates to ReactUpdateQueue while server rendering is in progress and - * switches to ReactNoopUpdateQueue after the transaction has completed. - * @class ReactServerUpdateQueue - * @param {Transaction} transaction - */ -class ReactServerUpdateQueue { - transaction: Transaction; - - constructor(transaction: Transaction) { - this.transaction = transaction; - } - - /** - * Checks whether or not this composite component is mounted. - * @param {ReactClass} publicInstance The instance we want to test. - * @return {boolean} True if mounted, false otherwise. - * @protected - * @final - */ - isMounted(publicInstance: ReactComponent): boolean { - return false; - } - - /** - * Forces an update. This should only be invoked when it is known with - * certainty that we are **not** in a DOM transaction. - * - * You may want to call this when you know that some deeper aspect of the - * component's state has changed but `setState` was not called. - * - * This will not invoke `shouldComponentUpdate`, but it will invoke - * `componentWillUpdate` and `componentDidUpdate`. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {?function} callback Called after component is updated. - * @param {?string} Name of the calling function in the public API. - * @internal - */ - enqueueForceUpdate( - publicInstance: ReactComponent, - callback?: Function, - callerName?: string, - ) { - if (this.transaction.isInTransaction()) { - ReactUpdateQueue.enqueueForceUpdate(publicInstance, callback, callerName); - } else { - warnNoop(publicInstance, 'forceUpdate'); - } - } - - /** - * Replaces all of the state. Always use this or `setState` to mutate state. - * You should treat `this.state` as immutable. - * - * There is no guarantee that `this.state` will be immediately updated, so - * accessing `this.state` after calling this method may return the old value. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {object|function} completeState Next state. - * @param {?function} callback Called after component is updated. - * @param {?string} Name of the calling function in the public API. - * @internal - */ - enqueueReplaceState( - publicInstance: ReactComponent, - completeState: Object | Function, - callback?: Function, - callerName?: string, - ) { - if (this.transaction.isInTransaction()) { - ReactUpdateQueue.enqueueReplaceState( - publicInstance, - completeState, - callback, - callerName, - ); - } else { - warnNoop(publicInstance, 'replaceState'); - } - } - - /** - * Sets a subset of the state. This only exists because _pendingState is - * internal. This provides a merging strategy that is not available to deep - * properties which is confusing. TODO: Expose pendingState or don't use it - * during the merge. - * - * @param {ReactClass} publicInstance The instance that should rerender. - * @param {object|function} partialState Next partial state to be merged with state. - * @internal - */ - enqueueSetState( - publicInstance: ReactComponent, - partialState: Object | Function, - callback?: Function, - callerName?: string, - ) { - if (this.transaction.isInTransaction()) { - ReactUpdateQueue.enqueueSetState( - publicInstance, - partialState, - callback, - callerName, - ); - } else { - warnNoop(publicInstance, 'setState'); - } - } -} - -module.exports = ReactServerUpdateQueue;