From 081c0da9324391adaab189598b87c588ff1e457d Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Thu, 4 Jan 2018 22:25:01 -0800 Subject: [PATCH 01/34] Initial work to support advanced compilation of UMD bundles using GCC This makes closure options dynamic, based on bundle type, since UMD and Node bundles expect different things in their externs. At this point, this can build the UMD_PROD versions of core and dom-client and load the babel-standalone fixture with the compiled react and react-dom files. --- .eslintignore | 3 + externs/react-NODE_PROD.ext.js | 1 + externs/react-UMD_PROD.ext.js | 3 + externs/react-dom-UMD_PROD.ext.js | 92 ++ externs/react-dom.ext.js | 71 ++ externs/react.ext.js | 1756 +++++++++++++++++++++++++++++ scripts/rollup/build.js | 80 +- scripts/rollup/results.json | 8 +- 8 files changed, 1988 insertions(+), 26 deletions(-) create mode 100644 externs/react-NODE_PROD.ext.js create mode 100644 externs/react-UMD_PROD.ext.js create mode 100644 externs/react-dom-UMD_PROD.ext.js create mode 100644 externs/react-dom.ext.js create mode 100644 externs/react.ext.js diff --git a/.eslintignore b/.eslintignore index d95f2bf247e3c..22da33f217363 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,3 +12,6 @@ scripts/bench/benchmarks/**/*.js # React repository clone scripts/bench/remote-repo/ + +# Externs +externs/ \ No newline at end of file diff --git a/externs/react-NODE_PROD.ext.js b/externs/react-NODE_PROD.ext.js new file mode 100644 index 0000000000000..7e4b61ceb2fb9 --- /dev/null +++ b/externs/react-NODE_PROD.ext.js @@ -0,0 +1 @@ +var require; diff --git a/externs/react-UMD_PROD.ext.js b/externs/react-UMD_PROD.ext.js new file mode 100644 index 0000000000000..0e9b7a31279aa --- /dev/null +++ b/externs/react-UMD_PROD.ext.js @@ -0,0 +1,3 @@ +var define; +var exports; +var module; \ No newline at end of file diff --git a/externs/react-dom-UMD_PROD.ext.js b/externs/react-dom-UMD_PROD.ext.js new file mode 100644 index 0000000000000..c1166e8cd7c6c --- /dev/null +++ b/externs/react-dom-UMD_PROD.ext.js @@ -0,0 +1,92 @@ +var define; +var exports; +var module; +var require; + +/* Globals not provided by Closure Compiler's BROWSER environment */ +var requestIdleCallback; +var cancelIdleCallback; +var MSApp; +var __REACT_DEVTOOLS_GLOBAL_HOOK__; + +/** + * React event system creates plugins and event properties dynamically. + * These externs are needed when consuming React as a JavaScript module + * in light of new ClojureScript compiler additions (as of version 1.9.456). + * See the following link for an example. + * https://github.com/facebook/react/blob/c7129c/src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js#L43 + */ +var ResponderEventPlugin; +var SimpleEventPlugin; +var TapEventPlugin; +var EnterLeaveEventPlugin; +var ChangeEventPlugin; +var SelectEventPlugin; +var BeforeInputEventPlugin; + +var bubbled; +var captured; +var topAbort; +var topAnimationEnd; +var topAnimationIteration; +var topAnimationStart; +var topBlur; +var topCancel; +var topCanPlay; +var topCanPlayThrough; +var topClick; +var topClose; +var topContextMenu; +var topCopy; +var topCut; +var topDoubleClick; +var topDrag; +var topDragEnd; +var topDragEnter; +var topDragExit; +var topDragLeave; +var topDragOver; +var topDragStart; +var topDrop; +var topDurationChange; +var topEmptied; +var topEncrypted; +var topEnded; +var topError; +var topFocus; +var topInput; +var topInvalid; +var topKeyDown; +var topKeyPress; +var topKeyUp; +var topLoad; +var topLoadedData; +var topLoadedMetadata; +var topLoadStart; +var topMouseDown; +var topMouseMove; +var topMouseOut; +var topMouseOver; +var topMouseUp; +var topPaste; +var topPause; +var topPlay; +var topPlaying; +var topProgress; +var topRateChange; +var topReset; +var topScroll; +var topSeeked; +var topSeeking; +var topStalled; +var topSubmit; +var topSuspend; +var topTimeUpdate; +var topTouchCancel; +var topTouchEnd; +var topTouchMove; +var topTouchStart; +var topTransitionEnd; +var topVolumeChange; +var topWaiting; +var topWheel; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js new file mode 100644 index 0000000000000..aaf7f0b9b6b1c --- /dev/null +++ b/externs/react-dom.ext.js @@ -0,0 +1,71 @@ +/** + * The ReactDOM global object. + * + * @type {!Object} + * @const + */ +var ReactDOM = {}; + +/** + * The current version of ReactDOM. + * + * @type {string} + * @const + */ +ReactDOM.version; + +/** + * @param {React.Component} container + * @param {Element} mountPoint + * @param {Function=} opt_callback + * @return {React.Component} + */ +ReactDOM.render = function(container, mountPoint, opt_callback) {}; + +/** + * @param {Element} container + * @return {boolean} + */ +ReactDOM.unmountComponentAtNode = function(container) {}; + +/** + * @param {React.Component} component + * @return {Element} + */ +ReactDOM.findDOMNode = function(component) {}; + +/** + * @param {Function} callback Function which calls `setState`, `forceUpdate`, etc. + * @param {*=} opt_a Optional argument to pass to the callback. + * @param {*=} opt_b Optional argument to pass to the callback. + * @param {*=} opt_c Optional argument to pass to the callback. + * @param {*=} opt_d Optional argument to pass to the callback. + * @param {*=} opt_e Optional argument to pass to the callback. + * @param {*=} opt_f Optional argument to pass to the callback. + */ +ReactDOM.unstable_batchedUpdates = function( + callback, + opt_a, + opt_b, + opt_c, + opt_d, + opt_e, + opt_f +) {}; + +/** + * @param {React.Component} parentComponent The conceptual parent of this render tree. + * @param {React.ReactElement} nextElement Component element to render. + * @param {Element} container DOM element to render into. + * @param {Function=} opt_callback function triggered on completion + * @return {React.Component} Component instance rendered in `container`. + */ +ReactDOM.unstable_renderSubtreeIntoContainer = function( + parentComponent, + nextElement, + container, + opt_callback +) {}; + +ReactDOM.hydrate = function() {}; +ReactDOM.createPortal = function() {}; diff --git a/externs/react.ext.js b/externs/react.ext.js new file mode 100644 index 0000000000000..dbbebb77300c7 --- /dev/null +++ b/externs/react.ext.js @@ -0,0 +1,1756 @@ +/** + * @type {!Object} + * @const + */ +var React = {}; + +/** + * @type {string} + * @const + */ +React.version; + +React.createClass = function(specification) {}; +React.createFactory = function(reactClass) {}; + +/** + * @param {*} componentClass + * @return {boolean} + * @deprecated + */ +React.isValidClass = function(componentClass) {}; + +/** + * @param {?Object} object + * @return {boolean} True if 'object' is a valid component. + */ +React.isValidElement = function(object) {}; + +/** + * @param {React.Component} container + * @param {Element} mountPoint + * @param {Function=} callback + * @return {React.Component} + * @deprecated + */ +React.renderComponent = function(container, mountPoint, callback) {}; + +/** + * Constructs a component instance of 'constructor' with 'initialProps' and + * renders it into the supplied 'container'. + * + * @param {Function} constructor React component constructor. + * @param {Object} props Initial props of the component instance. + * @param {Element} container DOM element to render into. + * @return {React.Component} Component instance rendered in 'container'. + */ +React.constructAndRenderComponent = function(constructor, props, container) {}; + +/** + * Constructs a component instance of 'constructor' with 'initialProps' and + * renders it into a container node identified by supplied 'id'. + * + * @param {Function} componentConstructor React component constructor + * @param {Object} props Initial props of the component instance. + * @param {string} id ID of the DOM element to render into. + * @return {React.Component} Component instance rendered in the container node. + */ +React.constructAndRenderComponentByID = function( + componentConstructor, + props, + id +) {}; + +React.cloneElement = function(element, props) {}; + +/** + * @interface + */ +React.ReactElement = function() {}; + +/** + * @constructor + */ +React.Component = function() {}; + +/** + * @type {Object} + */ +React.Component.prototype.props; + +/** + * @type {Object} + */ +React.Component.prototype.state; + +/** + * @type {Object} + */ +React.Component.prototype.refs; + +/** + * @type {Object} + */ +React.Component.prototype.context; + +/** + * @type {Object} + * @protected + */ +React.Component.prototype.propTypes; + +/** + * @type {Object} + * @protected + */ +React.Component.prototype.contextTypes; + +/** + * @type {Object} + */ +React.Component.prototype.mixins; + +/** + * @type {Object} + */ +React.Component.prototype.childContextTypes; + +/** + * @return {Object} + */ +React.Component.prototype.getInitialState = function() {}; + +/** + * @return {Object} + */ +React.Component.prototype.getDefaultProps = function() {}; + +/** + * @return {Object} + */ +React.Component.prototype.getChildContext = function() {}; + +/** + * @param {React.Component} targetComponent + * @return {React.Component} + */ +React.Component.prototype.transferPropsTo = function(targetComponent) {}; + +/** + * @param {Function=} callback + */ +React.Component.prototype.forceUpdate = function(callback) {}; + +/** + * @return {boolean} + */ +React.Component.prototype.isMounted = function() {}; + +/** + * @param {Object} nextState + * @param {Function=} callback + */ +React.Component.prototype.setState = function(nextState, callback) {}; + +/** + * @param {Object} nextState + * @param {Function=} callback + */ +React.Component.prototype.replaceState = function(nextState, callback) {}; + +/** + * @protected + */ +React.Component.prototype.componentWillMount = function() {}; + +/** + * @param {Element} element + * @protected + */ +React.Component.prototype.componentDidMount = function(element) {}; + +/** + * @param {Object} nextProps + * @protected + */ +React.Component.prototype.componentWillReceiveProps = function(nextProps) {}; + +/** + * @param {Object} nextProps + * @param {Object} nextState + * @return {boolean} + * @protected + */ +React.Component.prototype.shouldComponentUpdate = function( + nextProps, + nextState +) {}; + +/** + * @param {Object} nextProps + * @param {Object} nextState + * @protected + */ +React.Component.prototype.componentWillUpdate = function( + nextProps, + nextState +) {}; + +/** + * @param {Object} prevProps + * @param {Object} prevState + * @param {Element} rootNode + * @protected + */ +React.Component.prototype.componentDidUpdate = function( + prevProps, + prevState, + rootNode +) {}; + +/** + * @protected + */ +React.Component.prototype.componentWillUnmount = function() {}; + +/** + * @protected + */ +React.Component.prototype.componentDidCatch = function() {}; + +/** + * @return {React.Component} + * @protected + */ +React.Component.prototype.render = function() {}; + +/** + * @extends {React.Component} + * @constructor + */ +React.PureComponent = function() {}; + +/** + * @type {boolean} + */ +React.PureComponent.prototype.isPureReactComponent; + +/** + * Interface to preserve React attributes for advanced compilation. + * @interface + */ +React.ReactAttribute = function() {}; + +/** + * @type {Object} + */ +React.ReactAttribute.dangerouslySetInnerHTML; + +/** + * @type {string} + */ +React.ReactAttribute.__html; + +/** + * @type {string} + */ +React.ReactAttribute.key; + +/** + * @type {string} + */ +React.ReactAttribute.ref; + +// Attributes not defined in default Closure Compiler DOM externs. +// http://facebook.github.io/react/docs/tags-and-attributes.html#html-attributes +// It happens because React favors camelCasing over allinlowercase. +// How to update list: +// 1) Open http://facebook.github.io/react/docs/tags-and-attributes.html#html-attributes +// 2) Github Search in google/closure-compiler for attribute. + +/** + * @type {boolean} + */ +React.ReactAttribute.allowFullScreen; + +/** + * @type {boolean} + */ +React.ReactAttribute.autoComplete; + +/** + * @type {boolean} + */ +React.ReactAttribute.autoFocus; + +/** + * @type {boolean} + */ +React.ReactAttribute.autoPlay; + +/** + * @type {boolean} + */ +React.ReactAttribute.noValidate; + +/** + * @type {boolean} + */ +React.ReactAttribute.spellCheck; + +// http://facebook.github.io/react/docs/events.html + +/** + * @type {Function} + */ +React.ReactAttribute.onCopy; + +/** + * @type {Function} + */ +React.ReactAttribute.onCut; + +/** + * @type {Function} + */ +React.ReactAttribute.onPaste; + +/** + * @type {Function} + */ +React.ReactAttribute.onCompositionEnd; + +/** + * @type {Function} + */ +React.ReactAttribute.onCompositionStart; + +/** + * @type {Function} + */ +React.ReactAttribute.onCompositionUpdate; + +/** + * @type {Function} + */ +React.ReactAttribute.onKeyDown; + +/** + * @type {Function} + */ +React.ReactAttribute.onKeyPress; + +/** + * @type {Function} + */ +React.ReactAttribute.onKeyUp; + +/** + * @type {Function} + */ +React.ReactAttribute.onFocus; + +/** + * @type {Function} + */ +React.ReactAttribute.onBlur; + +/** + * @type {Function} + */ +React.ReactAttribute.onChange; + +/** + * @type {Function} + */ +React.ReactAttribute.onInput; + +/** + * @type {Function} + */ +React.ReactAttribute.onInvalid; + +/** + * @type {Function} + */ +React.ReactAttribute.onSubmit; + +/** + * @type {Function} + */ +React.ReactAttribute.onClick; + +/** + * @type {Function} + */ +React.ReactAttribute.onContextMenu; + +/** + * @type {Function} + */ +React.ReactAttribute.onDoubleClick; + +/** + * @type {Function} + */ +React.ReactAttribute.onDrag; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragEnd; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragEnter; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragExit; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragLeave; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragOver; + +/** + * @type {Function} + */ +React.ReactAttribute.onDragStart; + +/** + * @type {Function} + */ +React.ReactAttribute.onDrop; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseDown; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseEnter; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseLeave; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseMove; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseOut; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseOver; + +/** + * @type {Function} + */ +React.ReactAttribute.onMouseUp; + +/** + * @type {Function} + */ +React.ReactAttribute.onSelect; + +/** + * @type {Function} + */ +React.ReactAttribute.onTouchCancel; + +/** + * @type {Function} + */ +React.ReactAttribute.onTouchEnd; + +/** + * @type {Function} + */ +React.ReactAttribute.onTouchMove; + +/** + * @type {Function} + */ +React.ReactAttribute.onTouchStart; + +/** + * @type {Function} + */ +React.ReactAttribute.onScroll; + +/** + * @type {Function} + */ +React.ReactAttribute.onWheel; + +/** + * @type {Function} + */ +React.ReactAttribute.onAbort; +React.ReactAttribute.onCanPlay; +React.ReactAttribute.onCanPlayThrough; +React.ReactAttribute.onDurationChange; +React.ReactAttribute.onEmptied; +React.ReactAttribute.onEncrypted; +React.ReactAttribute.onEnded; +React.ReactAttribute.onError; +React.ReactAttribute.onLoadedData; +React.ReactAttribute.onLoadedMetadata; +React.ReactAttribute.onLoadStart; +React.ReactAttribute.onPause; +React.ReactAttribute.onPlay; +React.ReactAttribute.onPlaying; +React.ReactAttribute.onProgress; +React.ReactAttribute.onRateChange; +React.ReactAttribute.onSeeked; +React.ReactAttribute.onSeeking; +React.ReactAttribute.onStalled; +React.ReactAttribute.onSuspend; +React.ReactAttribute.onTimeUpdate; +React.ReactAttribute.onVolumeChange; +React.ReactAttribute.onWaiting; + +React.ReactAttribute.onAnimationStart; +React.ReactAttribute.onAnimationEnd; +React.ReactAttribute.onAnimationIteration; + +React.ReactAttribute.onTransitionEnd; + +React.ReactAttribute.onToggle; + +/** + * @interface + */ +React.SyntheticEvent = function() {}; + +/** + * @return {boolean} + */ +React.SyntheticEvent.prototype.persist = function() {}; + +/** + * @type {Object} + */ +React.SyntheticEvent.prototype.nativeEvent; + +/** + * @type {Function} + */ +React.SyntheticEvent.prototype.preventDefault; + +/** + * @type {Function} + */ +React.SyntheticEvent.prototype.stopPropagation; + +/** + * @type {Object} + * @const + */ +React.DOM = {}; + +/** + * @typedef { + * boolean|number|string|React.Component| + * Array.|Array.|Array.|Array. + * } + */ +React.ChildrenArgument; + +/** + * @param {*} componentClass + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + */ +React.createElement = function(componentClass, props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.a = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.abbr = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.address = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.area = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.article = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.aside = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.audio = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.b = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.base = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.bdi = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.bdo = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.big = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.blockquote = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.body = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.br = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.button = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.canvas = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.caption = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.circle = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.cite = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.clipPath = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.code = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.col = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.colgroup = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.data = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.datalist = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.dd = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.defs = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.del = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.details = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.dfn = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.dialog = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.div = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.dl = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.dt = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.ellipse = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.em = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.embed = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.fieldset = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.figcaption = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.figure = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.footer = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.form = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.g = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h1 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h2 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h3 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h4 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h5 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.h6 = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.head = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.header = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.hr = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.html = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.i = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.iframe = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.image = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.img = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.input = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.ins = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.kbd = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.keygen = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.label = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.legend = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.li = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.line = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.linearGradient = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.link = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.main = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.map = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.mark = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.mask = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.menu = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.menuitem = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.meta = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.meter = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.nav = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.noscript = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.object = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.ol = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.optgroup = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.option = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.output = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.p = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.param = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.path = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.pattern = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.picture = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.polygon = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.polyline = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.pre = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.progress = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.q = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.radialGradient = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.rect = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.rp = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.rt = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.ruby = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.s = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.samp = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.script = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.section = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.select = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.small = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.source = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.span = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.stop = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.strong = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.style = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.sub = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.summary = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.sup = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.svg = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.table = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.tbody = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.td = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.text = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.textarea = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.tfoot = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.th = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.thead = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.time = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.title = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.tr = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.track = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.tspan = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.u = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.ul = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.var = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.video = function(props, children) {}; + +/** + * @param {Object=} props + * @param {...React.ChildrenArgument} children + * @return {React.Component} + * @protected + */ +React.DOM.wbr = function(props, children) {}; + +/** + * @typedef {function(boolean, boolean, Object, string, string, string): boolean} React.ChainableTypeChecker + */ +React.ChainableTypeChecker; + +/** + * @type {React.ChainableTypeChecker} + */ +React.ChainableTypeChecker.weak; + +/** + * @type {React.ChainableTypeChecker} + */ +React.ChainableTypeChecker.weak.isRequired; + +/** + * @type {React.ChainableTypeChecker} + */ +React.ChainableTypeChecker.isRequired; + +/** + * @type {React.ChainableTypeChecker} + */ +React.ChainableTypeChecker.isRequired.weak; + +/** + * @type {Object} + */ +React.PropTypes = { + /** @type {React.ChainableTypeChecker} */ + any: function() {}, + /** @type {React.ChainableTypeChecker} */ + array: function() {}, + /** + * @param {React.ChainableTypeChecker} typeChecker + * @return {React.ChainableTypeChecker} + */ + arrayOf: function(typeChecker) {}, + /** @type {React.ChainableTypeChecker} */ + bool: function() {}, + /** @type {React.ChainableTypeChecker} */ + component: function() {}, + /** @type {React.ChainableTypeChecker} */ + element: function() {}, + /** @type {React.ChainableTypeChecker} */ + func: function() {}, + /** + * @param {function (new:Object, ...*): ?} expectedClass + * @return {React.ChainableTypeChecker} + */ + instanceOf: function(expectedClass) {}, + /** @type {React.ChainableTypeChecker} */ + node: function() {}, + /** @type {React.ChainableTypeChecker} */ + number: function() {}, + /** @type {React.ChainableTypeChecker} */ + object: function() {}, + /** + * @param {React.ChainableTypeChecker} typeChecker + * @return {React.ChainableTypeChecker} + */ + objectOf: function(typeChecker) {}, + /** + * @param {Array.<*>} expectedValues + * @return {React.ChainableTypeChecker} + */ + oneOf: function(expectedValues) {}, + /** + * @param {Array.} typeCheckers + * @return {React.ChainableTypeChecker} + */ + oneOfType: function(typeCheckers) {}, + /** @type {React.ChainableTypeChecker} */ + renderable: function() {}, + /** @type {React.ChainableTypeChecker} */ + /** + * @param {Object.} shapeTypes + * @return {React.ChainableTypeChecker} + */ + shape: function(shapeTypes) {}, + /** @type {React.ChainableTypeChecker} */ + string: function() {}, +}; + +/** + * @type {Object} + */ +React.Children; + +/** + * @param {Object} children Children tree container. + * @param {function(*, number)} mapFunction + * @param {*=} mapContext Context for mapFunction. + * @return {Object|undefined} Object containing the ordered map of results. + */ +React.Children.map; + +/** + * @param {Object} children Children tree container. + * @param {function(*, number)} mapFunction + * @param {*=} mapContext Context for mapFunction. + */ +React.Children.forEach; + +/** + * @param {Object} children Children tree container. + * @return {Object|undefined} + */ +React.Children.only; + +/** + * @param {Object} children Children tree container. + * @return {Array.} Flat array of children. + */ +React.Children.toArray; + +React.Fragment = function() {}; + +/* Non-public API needed to compile react and react-dom independently */ + +React.ReactElement.prototype.$$typeof; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {}; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 1b3c0d34bbde3..25a2010d6061f 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -59,17 +59,6 @@ const errorCodeOpts = { errorMapFilePath: 'scripts/error-codes/codes.json', }; -const closureOptions = { - compilationLevel: 'SIMPLE', - languageIn: 'ECMASCRIPT5_STRICT', - languageOut: 'ECMASCRIPT5_STRICT', - env: 'CUSTOM', - warningLevel: 'QUIET', - applyInputSourceMaps: false, - useTypesForOptimization: false, - processCommonJsModules: false, -}; - function getBabelConfig(updateBabelOptions, bundleType, filename) { let options = { exclude: 'node_modules/**', @@ -176,6 +165,55 @@ function isProductionBundleType(bundleType) { } } +function getClosureExterns(packageName, externals, bundleType) { + const externs = [packageName] + .concat(externals) + .map(name => `externs/${name}.ext.js`); + + externs.push(`externs/${packageName}-${bundleType}.ext.js`); + + // TODO: directly pass in correct paths to gcc + const src = externs + .filter(fs.existsSync) + .map(fileName => { + console.log(`Using externs from ${fileName}`); + return fs.readFileSync(fileName, 'utf-8'); + }) + .join('\n'); + + return [{src: src}]; +} + +function getClosureOptions(packageName, externals, bundleType, advancedMode) { + const closureOptions = { + languageIn: 'ECMASCRIPT5_STRICT', + languageOut: 'ECMASCRIPT5_STRICT', + warningLevel: 'QUIET', + applyInputSourceMaps: false, + useTypesForOptimization: false, + processCommonJsModules: false, + }; + + const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD; + + return Object.assign({}, closureOptions, { + env: isInGlobalScope ? 'BROWSER' : 'CUSTOM', + processCommonJsModules: true, + compilationLevel: advancedMode ? 'ADVANCED' : 'SIMPLE', + // Don't let it create global variables in the browser. + // https://github.com/facebook/react/issues/10909 + assumeFunctionWrapper: !isInGlobalScope, + // 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 + // and then the compiled version is released via `google-closure-compiler-js`. + renaming: advancedMode, + externs: advancedMode + ? getClosureExterns(packageName, externals, bundleType) + : [], + }); +} + function getPlugins( entry, externals, @@ -190,7 +228,6 @@ function getPlugins( const findAndRecordErrorCodes = extractErrorCodes(errorCodeOpts); const forks = Modules.getForks(bundleType, entry); const isProduction = isProductionBundleType(bundleType); - const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD; const isFBBundle = bundleType === FB_DEV || bundleType === FB_PROD; const isRNBundle = bundleType === RN_DEV || bundleType === RN_PROD; const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput; @@ -236,16 +273,12 @@ function getPlugins( // Apply dead code elimination and/or minification. isProduction && closure( - Object.assign({}, closureOptions, { - // Don't let it create global variables in the browser. - // https://github.com/facebook/react/issues/10909 - assumeFunctionWrapper: !isInGlobalScope, - // 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 - // and then the compiled version is released via `google-closure-compiler-js`. - renaming: !shouldStayReadable, - }) + getClosureOptions( + packageName, + externals, + bundleType, + !shouldStayReadable + ) ), // Add the whitespace back if necessary. shouldStayReadable && prettier(), @@ -436,6 +469,9 @@ function handleRollupError(error) { `\x1b[31m-- ${error.code}${error.plugin ? ` (${error.plugin})` : ''} --` ); console.error(error.message); + if (!error.loc) { + return; + } const {file, line, column} = error.loc; if (file) { // This looks like an error from Rollup, e.g. missing export. diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index 7dc84e2642fc4..2d6273122a4fb 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -11,8 +11,8 @@ "filename": "react.production.min.js", "bundleType": "UMD_PROD", "packageName": "react", - "size": 6546, - "gzip": 2789 + "size": 5838, + "gzip": 2606 }, { "filename": "react.development.js", @@ -53,8 +53,8 @@ "filename": "react-dom.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-dom", - "size": 93530, - "gzip": 30695 + "size": 76656, + "gzip": 27189 }, { "filename": "react-dom.development.js", From acbf6ae2f1c3d13f0a7be37b839923d642e64de0 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 01:59:41 -0800 Subject: [PATCH 02/34] Allow building node bundles The built bundle is not correct yet because it's missing module.exports. --- externs/react-dom-NODE_PROD.ext.js | 13 +++++++++++++ scripts/rollup/build.js | 8 ++++++++ scripts/rollup/results.json | 8 ++++---- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 externs/react-dom-NODE_PROD.ext.js diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js new file mode 100644 index 0000000000000..24d9e9adcb4c1 --- /dev/null +++ b/externs/react-dom-NODE_PROD.ext.js @@ -0,0 +1,13 @@ +var define; +var require; +var window; +var document; +var performance; +var console; +var setTimeout; +var clearTimeout; +var requestIdleCallback; +var cancelIdleCallback; +var requestAnimationFrame; +var MSApp; +var __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 25a2010d6061f..688a8fdc90a41 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -172,8 +172,16 @@ function getClosureExterns(packageName, externals, bundleType) { externs.push(`externs/${packageName}-${bundleType}.ext.js`); + const used = {}; // TODO: directly pass in correct paths to gcc const src = externs + .filter(fileName => { + if (used[fileName]) { + return false; + } + used[fileName] = true; + return true; + }) .filter(fs.existsSync) .map(fileName => { console.log(`Using externs from ${fileName}`); diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index 2d6273122a4fb..09a9b7c524a73 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -25,8 +25,8 @@ "filename": "react.production.min.js", "bundleType": "NODE_PROD", "packageName": "react", - "size": 5341, - "gzip": 2343 + "size": 4545, + "gzip": 2122 }, { "filename": "React-dev.js", @@ -67,8 +67,8 @@ "filename": "react-dom.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 91951, - "gzip": 29748 + "size": 69369, + "gzip": 26032 }, { "filename": "ReactDOM-dev.js", From 706e247ffaa0b05126a33f28236db5412c3f687a Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 03:50:48 -0800 Subject: [PATCH 03/34] Add more missing externs The missing isReactComponent was causing Component subclasses to be treated as functional components. The missing properties on ReactElement were breaking other type dependant behavior. --- externs/react.ext.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/externs/react.ext.js b/externs/react.ext.js index dbbebb77300c7..6452310a5c23b 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -73,6 +73,11 @@ React.ReactElement = function() {}; */ React.Component = function() {}; +/** + * @type {Object} + */ +React.Component.prototype.isReactComponent; + /** * @type {Object} */ @@ -1751,6 +1756,12 @@ React.Fragment = function() {}; /* Non-public API needed to compile react and react-dom independently */ React.ReactElement.prototype.$$typeof; +React.ReactElement.prototype.type; +React.ReactElement.prototype.key; +React.ReactElement.prototype.ref; +React.ReactElement.prototype.props; +React.ReactElement.prototype._owner; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {}; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; From 8f6eb00769816e593923fd89641e87f82093a308 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 03:46:14 -0800 Subject: [PATCH 04/34] Switch to BROWSER env and don't process commonjs modules The browser environment helps ensure that dom attributes don't get renamed, for example. With processCommonJsModules set to true, gcc was removing the module.exports from the compiled bundles. --- scripts/rollup/build.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 688a8fdc90a41..99c77667ea469 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -194,6 +194,7 @@ function getClosureExterns(packageName, externals, bundleType) { function getClosureOptions(packageName, externals, bundleType, advancedMode) { const closureOptions = { + env: 'BROWSER', languageIn: 'ECMASCRIPT5_STRICT', languageOut: 'ECMASCRIPT5_STRICT', warningLevel: 'QUIET', @@ -205,8 +206,6 @@ function getClosureOptions(packageName, externals, bundleType, advancedMode) { const isInGlobalScope = bundleType === UMD_DEV || bundleType === UMD_PROD; return Object.assign({}, closureOptions, { - env: isInGlobalScope ? 'BROWSER' : 'CUSTOM', - processCommonJsModules: true, compilationLevel: advancedMode ? 'ADVANCED' : 'SIMPLE', // Don't let it create global variables in the browser. // https://github.com/facebook/react/issues/10909 From 0edde2d6fcafbbbbf373572b91623b84885c756a Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 18:35:53 -0800 Subject: [PATCH 05/34] Move common externs to react.ext.js So we don't have to keep defining these for each bundle --- externs/react-NODE_PROD.ext.js | 1 - externs/react-UMD_PROD.ext.js | 3 --- externs/react-dom-NODE_PROD.ext.js | 3 --- externs/react-dom-UMD_PROD.ext.js | 6 ------ externs/react.ext.js | 5 +++++ 5 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 externs/react-NODE_PROD.ext.js delete mode 100644 externs/react-UMD_PROD.ext.js diff --git a/externs/react-NODE_PROD.ext.js b/externs/react-NODE_PROD.ext.js deleted file mode 100644 index 7e4b61ceb2fb9..0000000000000 --- a/externs/react-NODE_PROD.ext.js +++ /dev/null @@ -1 +0,0 @@ -var require; diff --git a/externs/react-UMD_PROD.ext.js b/externs/react-UMD_PROD.ext.js deleted file mode 100644 index 0e9b7a31279aa..0000000000000 --- a/externs/react-UMD_PROD.ext.js +++ /dev/null @@ -1,3 +0,0 @@ -var define; -var exports; -var module; \ No newline at end of file diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 24d9e9adcb4c1..bc63b982ecf5e 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -1,5 +1,3 @@ -var define; -var require; var window; var document; var performance; @@ -10,4 +8,3 @@ var requestIdleCallback; var cancelIdleCallback; var requestAnimationFrame; var MSApp; -var __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/externs/react-dom-UMD_PROD.ext.js b/externs/react-dom-UMD_PROD.ext.js index c1166e8cd7c6c..38f6b296f9754 100644 --- a/externs/react-dom-UMD_PROD.ext.js +++ b/externs/react-dom-UMD_PROD.ext.js @@ -1,13 +1,7 @@ -var define; -var exports; -var module; -var require; - /* Globals not provided by Closure Compiler's BROWSER environment */ var requestIdleCallback; var cancelIdleCallback; var MSApp; -var __REACT_DEVTOOLS_GLOBAL_HOOK__; /** * React event system creates plugins and event properties dynamically. diff --git a/externs/react.ext.js b/externs/react.ext.js index 6452310a5c23b..fc94e2720d2da 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1765,3 +1765,8 @@ React.ReactElement.prototype._owner; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {}; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; + +var __REACT_DEVTOOLS_GLOBAL_HOOK__; + +var module, require, exports, define; +module.exports; From 1ec3e29537d13d7d5c0356d2dd5296c011f55dcd Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 18:42:19 -0800 Subject: [PATCH 06/34] Fix some "duplicate name" errors from GCC Event -> FakeEvent hasOwnProperty -> objHasOwnProperty escape -> escapeKey Suppressed the error on ReactART.Text since it's exported --- packages/react-art/src/ReactART.js | 1 + .../react-dom/src/test-utils/ReactTestUtils.js | 14 +++++++------- packages/react/src/ReactChildren.js | 4 ++-- packages/react/src/ReactElement.js | 10 +++++----- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/react-art/src/ReactART.js b/packages/react-art/src/ReactART.js index 4023654f29363..a8c39428e7776 100644 --- a/packages/react-art/src/ReactART.js +++ b/packages/react-art/src/ReactART.js @@ -357,6 +357,7 @@ class Surface extends React.Component { } } +/** @suppress {duplicate} */ class Text extends React.Component { constructor(props) { super(props); diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index d32d8eca45579..3b24aade89afc 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -32,7 +32,7 @@ const { const topLevelTypes = BrowserEventConstants.topLevelTypes; -function Event(suffix) {} +function FakeEvent(suffix) {} /** * @class ReactTestUtils @@ -298,7 +298,7 @@ const ReactTestUtils = { * on an `Element` node. * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes` * @param {!Element} node The dom to simulate an event occurring on. - * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. + * @param {?FakeEvent} fakeNativeEvent Fake native event to use in SyntheticEvent. */ simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) { fakeNativeEvent.target = node; @@ -310,7 +310,7 @@ const ReactTestUtils = { * on the `ReactDOMComponent` `comp`. * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`. * @param {!ReactDOMComponent} comp - * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. + * @param {?FakeEvent} fakeNativeEvent Fake native event to use in SyntheticEvent. */ simulateNativeEventOnDOMComponent: function( topLevelType, @@ -359,7 +359,7 @@ function makeSimulator(eventType) { const dispatchConfig = EventPluginRegistry.eventNameDispatchConfigs[eventType]; - const fakeNativeEvent = new Event(); + const fakeNativeEvent = new FakeEvent(); fakeNativeEvent.target = domNode; fakeNativeEvent.type = eventType.toLowerCase(); @@ -441,7 +441,7 @@ buildSimulators(); function makeNativeSimulator(eventType) { return function(domComponentOrNode, nativeEventData) { - const fakeNativeEvent = new Event(eventType); + const fakeNativeEvent = new FakeEvent(eventType); Object.assign(fakeNativeEvent, nativeEventData); if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { ReactTestUtils.simulateNativeEventOnDOMComponent( @@ -461,14 +461,14 @@ function makeNativeSimulator(eventType) { } Object.keys(topLevelTypes).forEach(function(eventType) { - // Event type is stored as 'topClick' - we transform that to 'click' + // FakeEvent type is stored as 'topClick' - we transform that to 'click' const convenienceName = eventType.indexOf('top') === 0 ? eventType.charAt(3).toLowerCase() + eventType.substr(4) : eventType; /** * @param {!Element|ReactDOMComponent} domComponentOrNode - * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. + * @param {?FakeEvent} nativeEventData Fake native event to use in SyntheticEvent. */ ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator( eventType, diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index b44b833912894..1a8909c7e863f 100644 --- a/packages/react/src/ReactChildren.js +++ b/packages/react/src/ReactChildren.js @@ -26,7 +26,7 @@ const SUBSEPARATOR = ':'; * @param {string} key to be escaped. * @return {string} the escaped key. */ -function escape(key) { +function escapeKey(key) { const escapeRegex = /[=:]/g; const escaperLookup = { '=': '=0', @@ -250,7 +250,7 @@ function getComponentKey(component, index) { component.key != null ) { // Explicit key - return escape(component.key); + return escapeKey(component.key); } // Implicit key determined by the index in the set return index.toString(36); diff --git a/packages/react/src/ReactElement.js b/packages/react/src/ReactElement.js index a988bfb800033..67960b8c57d52 100644 --- a/packages/react/src/ReactElement.js +++ b/packages/react/src/ReactElement.js @@ -10,7 +10,7 @@ import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols'; import ReactCurrentOwner from './ReactCurrentOwner'; -const hasOwnProperty = Object.prototype.hasOwnProperty; +const objHasOwnProperty = Object.prototype.hasOwnProperty; const RESERVED_PROPS = { key: true, @@ -23,7 +23,7 @@ let specialPropKeyWarningShown, specialPropRefWarningShown; function hasValidRef(config) { if (__DEV__) { - if (hasOwnProperty.call(config, 'ref')) { + if (objHasOwnProperty.call(config, 'ref')) { const getter = Object.getOwnPropertyDescriptor(config, 'ref').get; if (getter && getter.isReactWarning) { return false; @@ -35,7 +35,7 @@ function hasValidRef(config) { function hasValidKey(config) { if (__DEV__) { - if (hasOwnProperty.call(config, 'key')) { + if (objHasOwnProperty.call(config, 'key')) { const getter = Object.getOwnPropertyDescriptor(config, 'key').get; if (getter && getter.isReactWarning) { return false; @@ -191,7 +191,7 @@ export function createElement(type, config, children) { // Remaining properties are added to a new props object for (propName in config) { if ( - hasOwnProperty.call(config, propName) && + objHasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName) ) { props[propName] = config[propName]; @@ -325,7 +325,7 @@ export function cloneElement(element, config, children) { } for (propName in config) { if ( - hasOwnProperty.call(config, propName) && + objHasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName) ) { if (config[propName] === undefined && defaultProps !== undefined) { From ca08db9b1641686830e7cebfa18ba5fad5ca0fa1 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:21:13 -0800 Subject: [PATCH 07/34] Remove externs obviated by BROWSER Also suppress duplicate warnings because now that we don't use processCommonJsModules, these are treated as global variables. --- externs/react-dom-NODE_PROD.ext.js | 7 ------- externs/react-dom.ext.js | 1 + externs/react.ext.js | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index bc63b982ecf5e..46777c20d3047 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -1,10 +1,3 @@ -var window; -var document; -var performance; -var console; -var setTimeout; -var clearTimeout; var requestIdleCallback; var cancelIdleCallback; -var requestAnimationFrame; var MSApp; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index aaf7f0b9b6b1c..be9b23c8ad78d 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -3,6 +3,7 @@ * * @type {!Object} * @const + * @suppress {duplicate} */ var ReactDOM = {}; diff --git a/externs/react.ext.js b/externs/react.ext.js index fc94e2720d2da..5ebc058a0786d 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1,6 +1,7 @@ /** * @type {!Object} * @const + * @suppress {duplicate} */ var React = {}; From d828f310b5060694eab74920ec2f4dff4b12cd63 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:24:05 -0800 Subject: [PATCH 08/34] Move plugins to react-dom.ext.js This is needed by both UMD and NODE bundles, even though the NODE bundle generates a duplicate warning. --- externs/react-dom-UMD_PROD.ext.js | 15 --------------- externs/react-dom.ext.js | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/externs/react-dom-UMD_PROD.ext.js b/externs/react-dom-UMD_PROD.ext.js index 38f6b296f9754..4a33d2fb34b07 100644 --- a/externs/react-dom-UMD_PROD.ext.js +++ b/externs/react-dom-UMD_PROD.ext.js @@ -3,21 +3,6 @@ var requestIdleCallback; var cancelIdleCallback; var MSApp; -/** - * React event system creates plugins and event properties dynamically. - * These externs are needed when consuming React as a JavaScript module - * in light of new ClojureScript compiler additions (as of version 1.9.456). - * See the following link for an example. - * https://github.com/facebook/react/blob/c7129c/src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js#L43 - */ -var ResponderEventPlugin; -var SimpleEventPlugin; -var TapEventPlugin; -var EnterLeaveEventPlugin; -var ChangeEventPlugin; -var SelectEventPlugin; -var BeforeInputEventPlugin; - var bubbled; var captured; var topAbort; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index be9b23c8ad78d..6b632f324c88d 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -70,3 +70,26 @@ ReactDOM.unstable_renderSubtreeIntoContainer = function( ReactDOM.hydrate = function() {}; ReactDOM.createPortal = function() {}; + + +/** + * React event system creates plugins and event properties dynamically. + * These externs are needed when consuming React as a JavaScript module + * in light of new ClojureScript compiler additions (as of version 1.9.456). + * See the following link for an example. + * https://github.com/facebook/react/blob/c7129c/src/renderers/dom/shared/eventPlugins/SimpleEventPlugin.js#L43 + */ +/** @suppress {duplicate} */ +var ResponderEventPlugin; +/** @suppress {duplicate} */ +var SimpleEventPlugin; +/** @suppress {duplicate} */ +var TapEventPlugin; +/** @suppress {duplicate} */ +var EnterLeaveEventPlugin; +/** @suppress {duplicate} */ +var ChangeEventPlugin; +/** @suppress {duplicate} */ +var SelectEventPlugin; +/** @suppress {duplicate} */ +var BeforeInputEventPlugin; From 9a43caf76e2959fd814ce0e20050b662d5e28545 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:26:25 -0800 Subject: [PATCH 09/34] Add more externs to get more tests to work --- externs/react-dom-NODE_PROD.ext.js | 32 ++++++++++++++++++++++++++++++ externs/react.ext.js | 16 +++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 46777c20d3047..e32b8bb4575a2 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -1,3 +1,35 @@ var requestIdleCallback; var cancelIdleCallback; var MSApp; + +/** @suppress {duplicate} */ +var ReactTestUtils; +ReactTestUtils.Simulate; +ReactTestUtils.Simulate.change; +ReactTestUtils.Simulate.click; +ReactTestUtils.Simulate.keyDown; +ReactTestUtils.Simulate.mouseEnter; +ReactTestUtils.Simulate.mouseMove; +ReactTestUtils.SimulateNative; +ReactTestUtils.SimulateNative.blur; +ReactTestUtils.SimulateNative.click; +ReactTestUtils.SimulateNative.mouseIn; +ReactTestUtils.SimulateNative.mouseMove; +ReactTestUtils.SimulateNative.mouseOut; +ReactTestUtils.SimulateNative.touchEnd; +ReactTestUtils.SimulateNative.touchStart; +ReactTestUtils.default; +ReactTestUtils.findAllInRenderedTree; +ReactTestUtils.findRenderedDOMComponentWithClass; +ReactTestUtils.findRenderedDOMComponentWithTag; +ReactTestUtils.isCompositeComponent; +ReactTestUtils.isCompositeComponentWithType; +ReactTestUtils.isDOMComponent; +ReactTestUtils.mockComponent; +ReactTestUtils.nativeTouchData; +ReactTestUtils.renderIntoDocument; +ReactTestUtils.scryRenderedComponentsWithType; +ReactTestUtils.scryRenderedDOMComponentsWithClass; +ReactTestUtils.scryRenderedDOMComponentsWithTag; +ReactTestUtils.simulateNativeEventOnDOMComponent; +ReactTestUtils.simulateNativeEventOnNode; \ No newline at end of file diff --git a/externs/react.ext.js b/externs/react.ext.js index 5ebc058a0786d..d8bb60d90b6e1 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1766,8 +1766,24 @@ React.ReactElement.prototype._owner; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {}; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.assign; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginHub; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginRegistry; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPropagators; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactControlledComponent; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMEventListener; var __REACT_DEVTOOLS_GLOBAL_HOOK__; +/** @suppress {duplicate} */ +var EventPluginHub; +EventPluginHub.injection = {}; +EventPluginHub.injection.injectEventPluginOrder; +EventPluginHub.injection.injectEventPluginsByName; +EventPluginHub.enqueueEvents; +EventPluginHub.extractEvents; +EventPluginHub.processEventQueue; +EventPluginHub.getListener; + var module, require, exports, define; module.exports; From 0f6dca5f019dfa18da9d995d7701b0b93c7aec86 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:30:06 -0800 Subject: [PATCH 10/34] Add externs for names used from fbjs These are treated as external dependencies in node bundles, so have to prevent renaming them. We should eventually still rename these in UMD bundles. --- externs/fbjs.ext.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 externs/fbjs.ext.js diff --git a/externs/fbjs.ext.js b/externs/fbjs.ext.js new file mode 100644 index 0000000000000..bbfdaec8158db --- /dev/null +++ b/externs/fbjs.ext.js @@ -0,0 +1,29 @@ +/** @suppress {duplicate} */ +var ExecutionEnvironment; +/** @suppress {duplicate} */ +var TouchEventUtils; +/** @suppress {duplicate} */ +var camelizeStyleName; +/** @suppress {duplicate} */ +var containsNode; +/** @suppress {duplicate} */ +var emptyFunction; +emptyFunction.thatReturns; +emptyFunction.thatReturnsNull; +emptyFunction.thatReturnsTrue; +emptyFunction.thatReturnsFalse; +emptyFunction.thatReturnsArgument; +/** @suppress {duplicate} */ +var emptyObject; +/** @suppress {duplicate} */ +var getActiveElement; +/** @suppress {duplicate} */ +var hyphenateStyleName; +/** @suppress {duplicate} */ +var invariant; +/** @suppress {duplicate} */ +var memoizeStringOnly; +/** @suppress {duplicate} */ +var shallowEqual; +/** @suppress {duplicate} */ +var warning; \ No newline at end of file From 5d89dff010c81c53c037604a14358cfd35def520 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:32:27 -0800 Subject: [PATCH 11/34] Add externs to get remaining bundles to compile --- externs/react-art-UMD_PROD.ext.js | 1 + externs/react-art.ext.js | 2 ++ externs/react-noop-renderer.ext.js | 1 + 3 files changed, 4 insertions(+) create mode 100644 externs/react-art-UMD_PROD.ext.js create mode 100644 externs/react-art.ext.js create mode 100644 externs/react-noop-renderer.ext.js diff --git a/externs/react-art-UMD_PROD.ext.js b/externs/react-art-UMD_PROD.ext.js new file mode 100644 index 0000000000000..ce9fc61c43ad6 --- /dev/null +++ b/externs/react-art-UMD_PROD.ext.js @@ -0,0 +1 @@ +var global; \ No newline at end of file diff --git a/externs/react-art.ext.js b/externs/react-art.ext.js new file mode 100644 index 0000000000000..35e748556b020 --- /dev/null +++ b/externs/react-art.ext.js @@ -0,0 +1,2 @@ +var requestIdleCallback; +var cancelIdleCallback; \ No newline at end of file diff --git a/externs/react-noop-renderer.ext.js b/externs/react-noop-renderer.ext.js new file mode 100644 index 0000000000000..10615099e0c64 --- /dev/null +++ b/externs/react-noop-renderer.ext.js @@ -0,0 +1 @@ +var regeneratorRuntime; \ No newline at end of file From 923dc07e120a33e2f9bc3d123ce215fb81979ff6 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:40:53 -0800 Subject: [PATCH 12/34] Check-in compilation results --- scripts/rollup/results.json | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index 09a9b7c524a73..c16abe40d2a57 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -11,8 +11,8 @@ "filename": "react.production.min.js", "bundleType": "UMD_PROD", "packageName": "react", - "size": 5838, - "gzip": 2606 + "size": 5880, + "gzip": 2619 }, { "filename": "react.development.js", @@ -25,8 +25,8 @@ "filename": "react.production.min.js", "bundleType": "NODE_PROD", "packageName": "react", - "size": 4545, - "gzip": 2122 + "size": 4916, + "gzip": 2210 }, { "filename": "React-dev.js", @@ -53,8 +53,8 @@ "filename": "react-dom.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-dom", - "size": 76656, - "gzip": 27189 + "size": 77046, + "gzip": 27256 }, { "filename": "react-dom.development.js", @@ -67,8 +67,8 @@ "filename": "react-dom.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 69369, - "gzip": 26032 + "size": 75249, + "gzip": 27045 }, { "filename": "ReactDOM-dev.js", @@ -95,8 +95,8 @@ "filename": "react-dom-test-utils.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-dom", - "size": 10583, - "gzip": 3916 + "size": 8583, + "gzip": 3545 }, { "filename": "react-dom-test-utils.development.js", @@ -109,8 +109,8 @@ "filename": "react-dom-test-utils.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 10160, - "gzip": 3834 + "size": 9012, + "gzip": 3487 }, { "filename": "ReactTestUtils-dev.js", @@ -130,8 +130,8 @@ "filename": "react-dom-unstable-native-dependencies.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-dom", - "size": 11337, - "gzip": 3913 + "size": 8153, + "gzip": 3499 }, { "filename": "react-dom-unstable-native-dependencies.development.js", @@ -144,8 +144,8 @@ "filename": "react-dom-unstable-native-dependencies.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 10884, - "gzip": 3780 + "size": 8080, + "gzip": 3417 }, { "filename": "ReactDOMUnstableNativeDependencies-dev.js", @@ -172,8 +172,8 @@ "filename": "react-dom-server.browser.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-dom", - "size": 14258, - "gzip": 5749 + "size": 13088, + "gzip": 5457 }, { "filename": "react-dom-server.browser.development.js", @@ -186,8 +186,8 @@ "filename": "react-dom-server.browser.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 13600, - "gzip": 5503 + "size": 12626, + "gzip": 5225 }, { "filename": "ReactDOMServer-dev.js", @@ -214,8 +214,8 @@ "filename": "react-dom-server.node.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 14424, - "gzip": 5812 + "size": 13325, + "gzip": 5473 }, { "filename": "react-art.development.js", @@ -228,8 +228,8 @@ "filename": "react-art.production.min.js", "bundleType": "UMD_PROD", "packageName": "react-art", - "size": 83166, - "gzip": 25969 + "size": 67764, + "gzip": 23643 }, { "filename": "react-art.development.js", @@ -242,8 +242,8 @@ "filename": "react-art.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-art", - "size": 46841, - "gzip": 14915 + "size": 36776, + "gzip": 13523 }, { "filename": "ReactART-dev.js", @@ -312,8 +312,8 @@ "filename": "react-test-renderer.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-test-renderer", - "size": 45203, - "gzip": 14330 + "size": 34861, + "gzip": 12815 }, { "filename": "ReactTestRenderer-dev.js", @@ -333,8 +333,8 @@ "filename": "react-test-renderer-shallow.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-test-renderer", - "size": 5522, - "gzip": 2004 + "size": 3890, + "gzip": 1713 }, { "filename": "ReactShallowRenderer-dev.js", @@ -354,8 +354,8 @@ "filename": "react-noop-renderer.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-noop-renderer", - "size": 6381, - "gzip": 2558 + "size": 5434, + "gzip": 2216 }, { "filename": "react-reconciler.development.js", @@ -368,8 +368,8 @@ "filename": "react-reconciler.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-reconciler", - "size": 38513, - "gzip": 12317 + "size": 29747, + "gzip": 11135 }, { "filename": "react-reconciler-reflection.development.js", @@ -382,8 +382,8 @@ "filename": "react-reconciler-reflection.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-reconciler", - "size": 2408, - "gzip": 1062 + "size": 2133, + "gzip": 979 }, { "filename": "react-call-return.development.js", @@ -396,8 +396,8 @@ "filename": "react-call-return.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-call-return", - "size": 971, - "gzip": 525 + "size": 849, + "gzip": 474 } ] } \ No newline at end of file From 8508a5ecade3cad77b4b753fc9480a2278902c27 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 19:55:33 -0800 Subject: [PATCH 13/34] run prettier --- externs/fbjs.ext.js | 2 +- externs/react-art-UMD_PROD.ext.js | 2 +- externs/react-art.ext.js | 2 +- externs/react-dom-NODE_PROD.ext.js | 2 +- externs/react-dom.ext.js | 1 - externs/react-noop-renderer.ext.js | 2 +- externs/react.ext.js | 3 ++- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/externs/fbjs.ext.js b/externs/fbjs.ext.js index bbfdaec8158db..9f6360d7891fc 100644 --- a/externs/fbjs.ext.js +++ b/externs/fbjs.ext.js @@ -26,4 +26,4 @@ var memoizeStringOnly; /** @suppress {duplicate} */ var shallowEqual; /** @suppress {duplicate} */ -var warning; \ No newline at end of file +var warning; diff --git a/externs/react-art-UMD_PROD.ext.js b/externs/react-art-UMD_PROD.ext.js index ce9fc61c43ad6..994158b096fcd 100644 --- a/externs/react-art-UMD_PROD.ext.js +++ b/externs/react-art-UMD_PROD.ext.js @@ -1 +1 @@ -var global; \ No newline at end of file +var global; diff --git a/externs/react-art.ext.js b/externs/react-art.ext.js index 35e748556b020..905a5151b69f5 100644 --- a/externs/react-art.ext.js +++ b/externs/react-art.ext.js @@ -1,2 +1,2 @@ var requestIdleCallback; -var cancelIdleCallback; \ No newline at end of file +var cancelIdleCallback; diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index e32b8bb4575a2..2b4ce5cafeb15 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -32,4 +32,4 @@ ReactTestUtils.scryRenderedComponentsWithType; ReactTestUtils.scryRenderedDOMComponentsWithClass; ReactTestUtils.scryRenderedDOMComponentsWithTag; ReactTestUtils.simulateNativeEventOnDOMComponent; -ReactTestUtils.simulateNativeEventOnNode; \ No newline at end of file +ReactTestUtils.simulateNativeEventOnNode; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 6b632f324c88d..8b1f55abeb677 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -71,7 +71,6 @@ ReactDOM.unstable_renderSubtreeIntoContainer = function( ReactDOM.hydrate = function() {}; ReactDOM.createPortal = function() {}; - /** * React event system creates plugins and event properties dynamically. * These externs are needed when consuming React as a JavaScript module diff --git a/externs/react-noop-renderer.ext.js b/externs/react-noop-renderer.ext.js index 10615099e0c64..5d96a5c4ac0ee 100644 --- a/externs/react-noop-renderer.ext.js +++ b/externs/react-noop-renderer.ext.js @@ -1 +1 @@ -var regeneratorRuntime; \ No newline at end of file +var regeneratorRuntime; diff --git a/externs/react.ext.js b/externs/react.ext.js index d8bb60d90b6e1..7941ad8d55b90 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1769,7 +1769,8 @@ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginHub; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPluginRegistry; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.EventPropagators; -React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactControlledComponent; +React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .ReactControlledComponent; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMEventListener; From 7d50185b83e679aacff248dcf071eeefb8ce0219 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 20:48:28 -0800 Subject: [PATCH 14/34] Prevent GCC from emptying RESERVED_PROPS GCC seems to incorrectly remove all of the properties from `RESERVED_PROPS` because they are never accessed by name. Replaced this with a Set since that was the intent anyway. --- packages/react/src/ReactElement.js | 16 ++++++++-------- scripts/rollup/results.json | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/react/src/ReactElement.js b/packages/react/src/ReactElement.js index 67960b8c57d52..f42e5b4a6af59 100644 --- a/packages/react/src/ReactElement.js +++ b/packages/react/src/ReactElement.js @@ -12,12 +12,12 @@ import ReactCurrentOwner from './ReactCurrentOwner'; const objHasOwnProperty = Object.prototype.hasOwnProperty; -const RESERVED_PROPS = { - key: true, - ref: true, - __self: true, - __source: true, -}; +const RESERVED_PROPS = new Set([ + "key", + "ref", + "__self", + "__source" +]); let specialPropKeyWarningShown, specialPropRefWarningShown; @@ -192,7 +192,7 @@ export function createElement(type, config, children) { for (propName in config) { if ( objHasOwnProperty.call(config, propName) && - !RESERVED_PROPS.hasOwnProperty(propName) + !RESERVED_PROPS.has(propName) ) { props[propName] = config[propName]; } @@ -326,7 +326,7 @@ export function cloneElement(element, config, children) { for (propName in config) { if ( objHasOwnProperty.call(config, propName) && - !RESERVED_PROPS.hasOwnProperty(propName) + !RESERVED_PROPS.has(propName) ) { if (config[propName] === undefined && defaultProps !== undefined) { // Resolve default props diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index c16abe40d2a57..43a88d2119171 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -18,15 +18,15 @@ "filename": "react.development.js", "bundleType": "NODE_DEV", "packageName": "react", - "size": 45812, - "gzip": 12711 + "size": 45773, + "gzip": 12715 }, { "filename": "react.production.min.js", "bundleType": "NODE_PROD", "packageName": "react", - "size": 4916, - "gzip": 2210 + "size": 4949, + "gzip": 2242 }, { "filename": "React-dev.js", @@ -67,8 +67,8 @@ "filename": "react-dom.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 75249, - "gzip": 27045 + "size": 75261, + "gzip": 27054 }, { "filename": "ReactDOM-dev.js", @@ -242,8 +242,8 @@ "filename": "react-art.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-art", - "size": 36776, - "gzip": 13523 + "size": 36788, + "gzip": 13529 }, { "filename": "ReactART-dev.js", @@ -312,8 +312,8 @@ "filename": "react-test-renderer.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-test-renderer", - "size": 34861, - "gzip": 12815 + "size": 34873, + "gzip": 12817 }, { "filename": "ReactTestRenderer-dev.js", @@ -333,8 +333,8 @@ "filename": "react-test-renderer-shallow.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-test-renderer", - "size": 3890, - "gzip": 1713 + "size": 3895, + "gzip": 1716 }, { "filename": "ReactShallowRenderer-dev.js", @@ -368,8 +368,8 @@ "filename": "react-reconciler.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-reconciler", - "size": 29747, - "gzip": 11135 + "size": 29759, + "gzip": 11136 }, { "filename": "react-reconciler-reflection.development.js", From c8a14d31d7559f6c22ea4a37f48a45b9e91e39a1 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 21:39:00 -0800 Subject: [PATCH 15/34] Add externs for FiberNode --- externs/react.ext.js | 27 +++++++++++++++++++++++++++ scripts/rollup/results.json | 8 ++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/externs/react.ext.js b/externs/react.ext.js index 7941ad8d55b90..15771a8a79d92 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1754,6 +1754,33 @@ React.Children.toArray; React.Fragment = function() {}; +/** @suppress {duplicate} */ +var FiberNode = {}; +FiberNode.prototype.tag; +FiberNode.prototype.key; +FiberNode.prototype.type; +FiberNode.prototype.stateNode; +FiberNode.prototype.return; +FiberNode.prototype.child; +FiberNode.prototype.sibling; +FiberNode.prototype.index; +FiberNode.prototype.ref; +FiberNode.prototype.pendingProps; +FiberNode.prototype.memoizedProps; +FiberNode.prototype.updateQueue; +FiberNode.prototype.memoizedState; +FiberNode.prototype.internalContextTag; +FiberNode.prototype.effectTag; +FiberNode.prototype.nextEffect; +FiberNode.prototype.firstEffect; +FiberNode.prototype.lastEffect; +FiberNode.prototype.expirationTime; +FiberNode.prototype.alternate; +FiberNode.prototype._debugID; +FiberNode.prototype._debugSource; +FiberNode.prototype._debugOwner; +FiberNode.prototype._debugIsCurrentlyTiming; + /* Non-public API needed to compile react and react-dom independently */ React.ReactElement.prototype.$$typeof; diff --git a/scripts/rollup/results.json b/scripts/rollup/results.json index 43a88d2119171..af85ea347b618 100644 --- a/scripts/rollup/results.json +++ b/scripts/rollup/results.json @@ -67,8 +67,8 @@ "filename": "react-dom.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 75261, - "gzip": 27054 + "size": 79599, + "gzip": 27410 }, { "filename": "ReactDOM-dev.js", @@ -109,8 +109,8 @@ "filename": "react-dom-test-utils.production.min.js", "bundleType": "NODE_PROD", "packageName": "react-dom", - "size": 9012, - "gzip": 3487 + "size": 9140, + "gzip": 3513 }, { "filename": "ReactTestUtils-dev.js", From 0aca7a7f3528c1b428e8694912afb9521b51aabb Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 21:41:14 -0800 Subject: [PATCH 16/34] Add missing extern for Component.defaultProps --- externs/react.ext.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/externs/react.ext.js b/externs/react.ext.js index 15771a8a79d92..82a562854bd1c 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -121,6 +121,11 @@ React.Component.prototype.mixins; */ React.Component.prototype.childContextTypes; +/** + * @type {Object} + */ +React.Component.prototype.defaultProps; + /** * @return {Object} */ From 2b23c2b42dc510da82156a34f14be1270ffe4a57 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 21:41:55 -0800 Subject: [PATCH 17/34] Decouple forcePrettyOutput from shouldStayReadable This allows us to run prettier even after compiling in ADVANCED mode, which can be really useful when debugging problems with the minified output. --- scripts/rollup/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rollup/build.js b/scripts/rollup/build.js index 99c77667ea469..abccd39a44ab1 100644 --- a/scripts/rollup/build.js +++ b/scripts/rollup/build.js @@ -237,7 +237,7 @@ function getPlugins( const isProduction = isProductionBundleType(bundleType); const isFBBundle = bundleType === FB_DEV || bundleType === FB_PROD; const isRNBundle = bundleType === RN_DEV || bundleType === RN_PROD; - const shouldStayReadable = isFBBundle || isRNBundle || forcePrettyOutput; + const shouldStayReadable = isFBBundle || isRNBundle; return [ // Extract error codes from invariant() messages into a file. shouldExtractErrors && { @@ -288,7 +288,7 @@ function getPlugins( ) ), // Add the whitespace back if necessary. - shouldStayReadable && prettier(), + (shouldStayReadable || forcePrettyOutput) && prettier(), // License and haste headers, top-level `if` blocks. { transformBundle(source) { From d0b197b7b7d361288a7b82922240c4744d353fbf Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Fri, 5 Jan 2018 21:51:09 -0800 Subject: [PATCH 18/34] run prettier --- packages/react/src/ReactElement.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/react/src/ReactElement.js b/packages/react/src/ReactElement.js index f42e5b4a6af59..b4d1d7d5fe6ee 100644 --- a/packages/react/src/ReactElement.js +++ b/packages/react/src/ReactElement.js @@ -12,12 +12,7 @@ import ReactCurrentOwner from './ReactCurrentOwner'; const objHasOwnProperty = Object.prototype.hasOwnProperty; -const RESERVED_PROPS = new Set([ - "key", - "ref", - "__self", - "__source" -]); +const RESERVED_PROPS = new Set(['key', 'ref', '__self', '__source']); let specialPropKeyWarningShown, specialPropRefWarningShown; From 1930287d5a5ccb00b90dfa5453d786a75a5f4839 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 00:15:40 -0800 Subject: [PATCH 19/34] Add a missing extern on ReactDOM --- externs/react-dom.ext.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 8b1f55abeb677..d3e14227ac303 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -54,6 +54,8 @@ ReactDOM.unstable_batchedUpdates = function( opt_f ) {}; +ReactDOM.unstable_deferredUpdates; + /** * @param {React.Component} parentComponent The conceptual parent of this render tree. * @param {React.ReactElement} nextElement Component element to render. From 7b01e2059509d37b61518ed3bd3c3a55d73dfda8 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 00:16:04 -0800 Subject: [PATCH 20/34] Add more fiber externs --- externs/react.ext.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/externs/react.ext.js b/externs/react.ext.js index 82a562854bd1c..7635d55e91499 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -79,6 +79,11 @@ React.Component = function() {}; */ React.Component.prototype.isReactComponent; +/** + * @type {Object} + */ +React.Component.prototype.updater; + /** * @type {Object} */ @@ -1786,6 +1791,31 @@ FiberNode.prototype._debugSource; FiberNode.prototype._debugOwner; FiberNode.prototype._debugIsCurrentlyTiming; +var Deadline = {}; +Deadline.prototype.timeRemaining; + +var Reconciler = {}; +Reconciler.createContainer; +Reconciler.updateContainer; +Reconciler.updateContainerAtExpirationTime; +Reconciler.flushRoot; +Reconciler.requestWork; +Reconciler.batchedUpdates; +Reconciler.unbatchedUpdates; +Reconciler.flushSync; +Reconciler.deferredUpdates; +Reconciler.injectIntoDevTools; +Reconciler.computeUniqueAsyncExpiration; +Reconciler.getPublicRootInstance; +Reconciler.findHostInstance; +Reconciler.findHostInstanceWithNoPortals; + +var updater = {}; +updater.isMounted; +updater.enqueueSetState; +updater.enqueueReplaceState; +updater.enqueueForceUpdate; + /* Non-public API needed to compile react and react-dom independently */ React.ReactElement.prototype.$$typeof; From 67b2f3b015d33dfa4b6d2841982098d7d09762a8 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 00:16:24 -0800 Subject: [PATCH 21/34] Add externs for react-call-return --- externs/react-call-return.ext.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 externs/react-call-return.ext.js diff --git a/externs/react-call-return.ext.js b/externs/react-call-return.ext.js new file mode 100644 index 0000000000000..fc39edd946932 --- /dev/null +++ b/externs/react-call-return.ext.js @@ -0,0 +1,8 @@ +/** @suppress {duplicate} */ +var unstable_createCall; +/** @suppress {duplicate} */ +var unstable_createReturn; +/** @suppress {duplicate} */ +var unstable_isCall; +/** @suppress {duplicate} */ +var unstable_isReturn; From ed620f20b14892d4a3f208fa7a3330489f0070df Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 00:52:23 -0800 Subject: [PATCH 22/34] Add externs for ReactDOMServer and stream.Readable --- externs/react-dom-NODE_PROD.ext.js | 5 +++++ externs/react-dom.ext.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 2b4ce5cafeb15..91e8bf0c70cb6 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -33,3 +33,8 @@ ReactTestUtils.scryRenderedDOMComponentsWithClass; ReactTestUtils.scryRenderedDOMComponentsWithTag; ReactTestUtils.simulateNativeEventOnDOMComponent; ReactTestUtils.simulateNativeEventOnNode; + +/** @suppress {duplicate} */ +var stream; +stream.Readable; +stream.Readable._read; \ No newline at end of file diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index d3e14227ac303..72b6b1332f26f 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -73,6 +73,13 @@ ReactDOM.unstable_renderSubtreeIntoContainer = function( ReactDOM.hydrate = function() {}; ReactDOM.createPortal = function() {}; +/** @suppress {duplicate} */ +var ReactDOMServer = {}; +ReactDOMServer.renderToString; +ReactDOMServer.renderToStaticMarkup; +ReactDOMServer.renderToNodeStream; +ReactDOMServer.renderToStaticNodeStream; + /** * React event system creates plugins and event properties dynamically. * These externs are needed when consuming React as a JavaScript module From 505945b2578fad28e11f1eb028e41897a3539186 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 02:05:47 -0800 Subject: [PATCH 23/34] Fix test failures because of suppressReactErrorLogging getting renamed --- externs/react-dom-NODE_PROD.ext.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 91e8bf0c70cb6..7ddc4c4c0e33f 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -37,4 +37,6 @@ ReactTestUtils.simulateNativeEventOnNode; /** @suppress {duplicate} */ var stream; stream.Readable; -stream.Readable._read; \ No newline at end of file +stream.Readable._read; + +Error.prototype.suppressReactErrorLogging; From 9146ac486c8b746075781a5fb4e0a1ee9d6b8d40 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 12:51:03 -0800 Subject: [PATCH 24/34] Update externs for SyntheticEvent --- externs/react.ext.js | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/externs/react.ext.js b/externs/react.ext.js index 7635d55e91499..c47d6d870d4d1 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -551,30 +551,33 @@ React.ReactAttribute.onTransitionEnd; React.ReactAttribute.onToggle; -/** - * @interface - */ React.SyntheticEvent = function() {}; - -/** - * @return {boolean} - */ -React.SyntheticEvent.prototype.persist = function() {}; - -/** - * @type {Object} - */ +React.SyntheticEvent.extend; +React.SyntheticEvent.eventPool; +React.SyntheticEvent.getPooled; +React.SyntheticEvent.release; +React.SyntheticEvent.prototype.destructor; +React.SyntheticEvent.prototype.persist; +React.SyntheticEvent.prototype.isPersistent; React.SyntheticEvent.prototype.nativeEvent; - -/** - * @type {Function} - */ React.SyntheticEvent.prototype.preventDefault; - -/** - * @type {Function} - */ React.SyntheticEvent.prototype.stopPropagation; +/** @type {DispatchConfig} */ +React.SyntheticEvent.prototype.dispatchConfig; +React.SyntheticEvent.prototype.nativeEvent; +React.SyntheticEvent.prototype._targetInst; +React.SyntheticEvent.prototype.isDefaultPrevented; +React.SyntheticEvent.prototype.isPropagationStopped; +React.SyntheticEvent.prototype._dispatchListeners; +React.SyntheticEvent.prototype._dispatchInstances; + +/** @suppress {duplicate} */ +var DispatchConfig; +DispatchConfig.dependencies; +DispatchConfig.phasedRegistrationNames = {}; +DispatchConfig.phasedRegistrationNames.bubbled; +DispatchConfig.phasedRegistrationNames.captured; +DispatchConfig.registrationName; /** * @type {Object} From 1b98ddd82937be856fdeb2bbbe442791388f22ff Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 12:51:21 -0800 Subject: [PATCH 25/34] Add complete externs for __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED These are used extensively by react-dom etc., so best to keep them all in externs instead of trying to whack-a-mole. --- externs/react.ext.js | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/externs/react.ext.js b/externs/react.ext.js index c47d6d870d4d1..afe2eed09a374 100644 --- a/externs/react.ext.js +++ b/externs/react.ext.js @@ -1839,8 +1839,6 @@ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMComponentTree; React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactDOMEventListener; -var __REACT_DEVTOOLS_GLOBAL_HOOK__; - /** @suppress {duplicate} */ var EventPluginHub; EventPluginHub.injection = {}; @@ -1851,5 +1849,45 @@ EventPluginHub.extractEvents; EventPluginHub.processEventQueue; EventPluginHub.getListener; +/** @suppress {duplicate} */ +var EventPluginRegistry; +EventPluginRegistry.eventNameDispatchConfigs; + +/** @suppress {duplicate} */ +var EventPropagators; +EventPropagators.accumulateTwoPhaseDispatches; +EventPropagators.accumulateTwoPhaseDispatchesSkipTarget; +EventPropagators.accumulateEnterLeaveDispatches; +EventPropagators.accumulateDirectDispatches; + +/** @suppress {duplicate} */ +var ReactControlledComponent; +ReactControlledComponent.injection = {}; +ReactControlledComponent.injection.injectFiberControlledHostComponent; +ReactControlledComponent.enqueueStateRestore; +ReactControlledComponent.restoreStateIfNeeded; + +/** @suppress {duplicate} */ +var ReactDOMComponentTree; +ReactDOMComponentTree.precacheFiberNode; +ReactDOMComponentTree.getClosestInstanceFromNode; +ReactDOMComponentTree.getInstanceFromNode; +ReactDOMComponentTree.getNodeFromInstance; +ReactDOMComponentTree.getFiberCurrentPropsFromNode; +ReactDOMComponentTree.updateFiberProps; + +/** @suppress {duplicate} */ +var ReactDOMEventListener; +ReactDOMEventListener._enabled; +ReactDOMEventListener._handleTopLevel; +ReactDOMEventListener.setHandleTopLevel; +ReactDOMEventListener.setEnabled; +ReactDOMEventListener.isEnabled; +ReactDOMEventListener.trapBubbledEvent; +ReactDOMEventListener.trapCapturedEvent; +ReactDOMEventListener.dispatchEvent; + +var __REACT_DEVTOOLS_GLOBAL_HOOK__; + var module, require, exports, define; module.exports; From 8bfc5e4c41ee22c76af2f09dff0dabf0586bd4bd Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 13:57:40 -0800 Subject: [PATCH 26/34] Fix externs for BrowserEventConstants These are needed in both UMD and NODE bundles, plus these were outdated. --- externs/react-dom-UMD_PROD.ext.js | 67 ---------------------------- externs/react-dom.ext.js | 72 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/externs/react-dom-UMD_PROD.ext.js b/externs/react-dom-UMD_PROD.ext.js index 4a33d2fb34b07..b968a1f092737 100644 --- a/externs/react-dom-UMD_PROD.ext.js +++ b/externs/react-dom-UMD_PROD.ext.js @@ -2,70 +2,3 @@ var requestIdleCallback; var cancelIdleCallback; var MSApp; - -var bubbled; -var captured; -var topAbort; -var topAnimationEnd; -var topAnimationIteration; -var topAnimationStart; -var topBlur; -var topCancel; -var topCanPlay; -var topCanPlayThrough; -var topClick; -var topClose; -var topContextMenu; -var topCopy; -var topCut; -var topDoubleClick; -var topDrag; -var topDragEnd; -var topDragEnter; -var topDragExit; -var topDragLeave; -var topDragOver; -var topDragStart; -var topDrop; -var topDurationChange; -var topEmptied; -var topEncrypted; -var topEnded; -var topError; -var topFocus; -var topInput; -var topInvalid; -var topKeyDown; -var topKeyPress; -var topKeyUp; -var topLoad; -var topLoadedData; -var topLoadedMetadata; -var topLoadStart; -var topMouseDown; -var topMouseMove; -var topMouseOut; -var topMouseOver; -var topMouseUp; -var topPaste; -var topPause; -var topPlay; -var topPlaying; -var topProgress; -var topRateChange; -var topReset; -var topScroll; -var topSeeked; -var topSeeking; -var topStalled; -var topSubmit; -var topSuspend; -var topTimeUpdate; -var topTouchCancel; -var topTouchEnd; -var topTouchMove; -var topTouchStart; -var topTransitionEnd; -var topVolumeChange; -var topWaiting; -var topWheel; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 72b6b1332f26f..859025d73d8e6 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -101,3 +101,75 @@ var ChangeEventPlugin; var SelectEventPlugin; /** @suppress {duplicate} */ var BeforeInputEventPlugin; + +var bubbled; +var captured; +/* Keep in sync with BrowserEventConstants */ +var topAbort; +var topAnimationEnd; +var topAnimationIteration; +var topAnimationStart; +var topBlur; +var topCancel; +var topCanPlay; +var topCanPlayThrough; +var topChange; +var topClick; +var topClose; +var topCompositionEnd; +var topCompositionStart; +var topCompositionUpdate; +var topContextMenu; +var topCopy; +var topCut; +var topDoubleClick; +var topDrag; +var topDragEnd; +var topDragEnter; +var topDragExit; +var topDragLeave; +var topDragOver; +var topDragStart; +var topDrop; +var topDurationChange; +var topEmptied; +var topEncrypted; +var topEnded; +var topError; +var topFocus; +var topInput; +var topKeyDown; +var topKeyPress; +var topKeyUp; +var topLoadedData; +var topLoad; +var topLoadedMetadata; +var topLoadStart; +var topMouseDown; +var topMouseMove; +var topMouseOut; +var topMouseOver; +var topMouseUp; +var topPaste; +var topPause; +var topPlay; +var topPlaying; +var topProgress; +var topRateChange; +var topScroll; +var topSeeked; +var topSeeking; +var topSelectionChange; +var topStalled; +var topSuspend; +var topTextInput; +var topTimeUpdate; +var topToggle; +var topTouchCancel; +var topTouchEnd; +var topTouchMove; +var topTouchStart; +var topTransitionEnd; +var topVolumeChange; +var topWaiting; +var topWheel; From 4ddec6686c42121f3fd85db685a86a4a3f10026b Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 17:04:08 -0800 Subject: [PATCH 27/34] Add missing fbjs extern for ExecutionEnvironment.canUseDOM --- externs/fbjs.ext.js | 1 + 1 file changed, 1 insertion(+) diff --git a/externs/fbjs.ext.js b/externs/fbjs.ext.js index 9f6360d7891fc..6c7bcd112602e 100644 --- a/externs/fbjs.ext.js +++ b/externs/fbjs.ext.js @@ -1,5 +1,6 @@ /** @suppress {duplicate} */ var ExecutionEnvironment; +ExecutionEnvironment.canUseDOM; /** @suppress {duplicate} */ var TouchEventUtils; /** @suppress {duplicate} */ From af1652885b473af0a18a3790ad61f10b399e726d Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 17:04:51 -0800 Subject: [PATCH 28/34] Avoid duplicating react-dom externs --- externs/react-dom-NODE_PROD.ext.js | 4 ---- externs/react-dom-UMD_PROD.ext.js | 4 ---- externs/react-dom.ext.js | 5 +++++ 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 externs/react-dom-UMD_PROD.ext.js diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 7ddc4c4c0e33f..9dfce116f64bb 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -1,7 +1,3 @@ -var requestIdleCallback; -var cancelIdleCallback; -var MSApp; - /** @suppress {duplicate} */ var ReactTestUtils; ReactTestUtils.Simulate; diff --git a/externs/react-dom-UMD_PROD.ext.js b/externs/react-dom-UMD_PROD.ext.js deleted file mode 100644 index b968a1f092737..0000000000000 --- a/externs/react-dom-UMD_PROD.ext.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Globals not provided by Closure Compiler's BROWSER environment */ -var requestIdleCallback; -var cancelIdleCallback; -var MSApp; diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 859025d73d8e6..3b711be652632 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -173,3 +173,8 @@ var topTransitionEnd; var topVolumeChange; var topWaiting; var topWheel; + +/* Globals not provided by the BROWSER environment */ +var requestIdleCallback; +var cancelIdleCallback; +var MSApp; From 4b2234ffb1d4659bdbacf73fd0d334d0d5ec4aaf Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 17:05:33 -0800 Subject: [PATCH 29/34] Add debug-test-build and debug-test-build-prod These are useful for understanding why a test is failing in prod. --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index b17d950e443e5..f53c979e3eaf8 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,9 @@ "test": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.source.js", "test-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.source.js", "test-prod-build": "yarn test-build-prod", + "debug-test-build": "cross-env NODE_ENV=development node --inspect-brk node_modules/.bin/jest --config ./scripts/jest/config.build.js", "test-build": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.build.js", + "debug-test-build-prod": "cross-env NODE_ENV=production node --inspect-brk node_modules/.bin/jest --config ./scripts/jest/config.build.js", "test-build-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.build.js", "flow": "node ./scripts/tasks/flow.js", "prettier": "node ./scripts/prettier/index.js write-changed", From 6fb8cce0b788a78bee2fb4debe394efed9aef006 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 19:47:45 -0800 Subject: [PATCH 30/34] Clean-up ReactDOM externs Removed unnecessary annotations and updated the externs for React 16 --- externs/react-dom.ext.js | 82 ++++++---------------------------------- 1 file changed, 11 insertions(+), 71 deletions(-) diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 3b711be652632..40ee0c11f91be 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -1,77 +1,17 @@ -/** - * The ReactDOM global object. - * - * @type {!Object} - * @const - * @suppress {duplicate} - */ +/** @suppress {duplicate} */ var ReactDOM = {}; - -/** - * The current version of ReactDOM. - * - * @type {string} - * @const - */ ReactDOM.version; - -/** - * @param {React.Component} container - * @param {Element} mountPoint - * @param {Function=} opt_callback - * @return {React.Component} - */ -ReactDOM.render = function(container, mountPoint, opt_callback) {}; - -/** - * @param {Element} container - * @return {boolean} - */ -ReactDOM.unmountComponentAtNode = function(container) {}; - -/** - * @param {React.Component} component - * @return {Element} - */ -ReactDOM.findDOMNode = function(component) {}; - -/** - * @param {Function} callback Function which calls `setState`, `forceUpdate`, etc. - * @param {*=} opt_a Optional argument to pass to the callback. - * @param {*=} opt_b Optional argument to pass to the callback. - * @param {*=} opt_c Optional argument to pass to the callback. - * @param {*=} opt_d Optional argument to pass to the callback. - * @param {*=} opt_e Optional argument to pass to the callback. - * @param {*=} opt_f Optional argument to pass to the callback. - */ -ReactDOM.unstable_batchedUpdates = function( - callback, - opt_a, - opt_b, - opt_c, - opt_d, - opt_e, - opt_f -) {}; - +ReactDOM.findDOMNode; +ReactDOM.hydrate; +ReactDOM.render; +ReactDOM.unstable_renderSubtreeIntoContainer; +ReactDOM.unmountComponentAtNode; +ReactDOM.createPortal; +ReactDOM.unstable_createPortal; +ReactDOM.unstable_batchedUpdates; ReactDOM.unstable_deferredUpdates; - -/** - * @param {React.Component} parentComponent The conceptual parent of this render tree. - * @param {React.ReactElement} nextElement Component element to render. - * @param {Element} container DOM element to render into. - * @param {Function=} opt_callback function triggered on completion - * @return {React.Component} Component instance rendered in `container`. - */ -ReactDOM.unstable_renderSubtreeIntoContainer = function( - parentComponent, - nextElement, - container, - opt_callback -) {}; - -ReactDOM.hydrate = function() {}; -ReactDOM.createPortal = function() {}; +ReactDOM.flushSync; +ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; /** @suppress {duplicate} */ var ReactDOMServer = {}; From 436c08cf7236b6e821f5eaf46379719bb6da0c69 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 20:38:09 -0800 Subject: [PATCH 31/34] Make ReactInstanceMap work correctly --- externs/react-dom.ext.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index 40ee0c11f91be..f0d4afe2929e2 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -20,6 +20,9 @@ ReactDOMServer.renderToStaticMarkup; ReactDOMServer.renderToNodeStream; ReactDOMServer.renderToStaticNodeStream; +/* Used by ReactInstanceMap */ +var _reactInternalFiber; + /** * React event system creates plugins and event properties dynamically. * These externs are needed when consuming React as a JavaScript module From 629dbc297a31b947792a717ce31b825204df7fa5 Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 20:38:37 -0800 Subject: [PATCH 32/34] Stop renaming mockImplementation for tests --- externs/react-dom-NODE_PROD.ext.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/externs/react-dom-NODE_PROD.ext.js b/externs/react-dom-NODE_PROD.ext.js index 9dfce116f64bb..7621f03c79ece 100644 --- a/externs/react-dom-NODE_PROD.ext.js +++ b/externs/react-dom-NODE_PROD.ext.js @@ -36,3 +36,6 @@ stream.Readable; stream.Readable._read; Error.prototype.suppressReactErrorLogging; + +var MockComponent; +MockComponent.prototype.render.mockImplementation; From f14d054126497cdcfc49291f1f7f9705b33de9cd Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 21:04:06 -0800 Subject: [PATCH 33/34] Add externs for CSSProperty --- externs/react-dom.ext.js | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/externs/react-dom.ext.js b/externs/react-dom.ext.js index f0d4afe2929e2..8f04f8277815e 100644 --- a/externs/react-dom.ext.js +++ b/externs/react-dom.ext.js @@ -117,6 +117,49 @@ var topVolumeChange; var topWaiting; var topWheel; +/* Keep in sync with CSSProperty */ +var animationIterationCount; +var borderImageOutset; +var borderImageSlice; +var borderImageWidth; +var boxFlex; +var boxFlexGroup; +var boxOrdinalGroup; +var columnCount; +var columns; +var flex; +var flexGrow; +var flexPositive; +var flexShrink; +var flexNegative; +var flexOrder; +var gridRow; +var gridRowEnd; +var gridRowSpan; +var gridRowStart; +var gridColumn; +var gridColumnEnd; +var gridColumnSpan; +var gridColumnStart; +var fontWeight; +var lineClamp; +var lineHeight; +var opacity; +var order; +var orphans; +var tabSize; +var widows; +var zIndex; +var zoom; +var fillOpacity; +var floodOpacity; +var stopOpacity; +var strokeDasharray; +var strokeDashoffset; +var strokeMiterlimit; +var strokeOpacity; +var strokeWidth; + /* Globals not provided by the BROWSER environment */ var requestIdleCallback; var cancelIdleCallback; From 23ef5a63f74f7dba95ec77ae17024124b568d17e Mon Sep 17 00:00:00 2001 From: Shrey Banga Date: Sat, 6 Jan 2018 21:04:58 -0800 Subject: [PATCH 34/34] Add externs for test-renderer --- externs/react-test-renderer.ext.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 externs/react-test-renderer.ext.js diff --git a/externs/react-test-renderer.ext.js b/externs/react-test-renderer.ext.js new file mode 100644 index 0000000000000..82a4890bffb4d --- /dev/null +++ b/externs/react-test-renderer.ext.js @@ -0,0 +1,12 @@ +/** @suppress {duplicate} */ +var ReactShallowRenderer; +ReactShallowRenderer.createRenderer; +ReactShallowRenderer.prototype.getMountedInstance; +ReactShallowRenderer.prototype.getRenderedOutput; +ReactShallowRenderer.prototype.render; +ReactShallowRenderer.prototype.unmount; + +/** @suppress {duplicate} */ +var ReactTestRendererFiber; +ReactTestRendererFiber.prototype.create; +ReactTestRendererFiber.prototype.unstable_batchedUpdates;