Compile the react bundle with GCC advanced mode#11995
Compile the react bundle with GCC advanced mode#11995banga wants to merge 3 commits intofacebook:masterfrom
Conversation
externs/react.ext.js
Outdated
|
|
||
| React.PureComponent.prototype.isPureReactComponent; | ||
|
|
||
| React.SyntheticEvent; |
There was a problem hiding this comment.
I wouldn't expect this to be in public API of React package
externs/react.ext.js
Outdated
| React.SyntheticEvent.prototype._dispatchInstances; | ||
|
|
||
| /** @suppress {duplicate} */ | ||
| var DispatchConfig; |
externs/react.ext.js
Outdated
| DispatchConfig.registrationName; | ||
|
|
||
| /** @suppress {duplicate} */ | ||
| var FiberNode = {}; |
There was a problem hiding this comment.
Same, this shouldn't be in React package
externs/react.ext.js
Outdated
| FiberNode.prototype._debugIsCurrentlyTiming; | ||
|
|
||
| var Deadline = {}; | ||
| Deadline.prototype.timeRemaining; |
externs/react.ext.js
Outdated
| var Deadline = {}; | ||
| Deadline.prototype.timeRemaining; | ||
|
|
||
| var Reconciler = {}; |
externs/react.ext.js
Outdated
| 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; |
There was a problem hiding this comment.
This shouldn't be here (same for all of them below). It's on ReactDOM's field, not React's.
Most of these are needed to build react-dom
Some of these were outdated from previous runs
| @@ -0,0 +1,30 @@ | |||
| /** @suppress {duplicate} */ | |||
There was a problem hiding this comment.
This is only needed for the node bundles because the contents of fbjs are not included in those bundles, so properties like emptyFunction.thatReturns get renamed when they shouldn't be. I also remember hitting a problem with canUseDOM not being set to true when it should be, but I can't repro that right now. I was being defensive when I created this file by including everything from fbjs that I saw being used, but we can cut it down to a smaller set of things if that would be preferable.
There was a problem hiding this comment.
Forgot to mention — this file is not pulled in for UMD bundles, because fbjs is not part of externals for those, which are checked in getClosureExterns to determine which externs files to look for.
|
Hey @gaearon, just checking if you got a chance to look at this. |
|
(Whoops, tapped the wrong button) |
|
Hey @banga, This is very valuable but my focus has shifted from working on the repo infrastructure to React app compilation experiments so I won't have time to fully review/merge/support this in the near future. I think it's safe to assume that whenever we decide to get back to this, the changes won't be very different (aside from fixing up the whitelists). I'll happily do that once I feel comfortable with spending more time on this. Please be assured this work was not in vain. This is the first time we actually had a complete PR that implements this, and it shows exactly the parts we need to fix first. (e.g. for ReactDOM bundle, I'm not very happy with whitelists like internal variable names having to be whitelisted—this means we need to rewrite those parts in a way that doesn't rely on those names. And I don't want to change how React is bundled before we're ready to start converting the others—although I very much appreciate a demo of how it could be done.) Does this make sense? I think we can revisit in a few months. |
|
Yeah, that makes sense. Completely agree about rewriting the parts that share internal names. Ideally the whitelist should exactly match the public react API. |
| @@ -0,0 +1,76 @@ | |||
| /** @suppress {duplicate} */ | |||
There was a problem hiding this comment.
While there is some value in having a clearly defined API somewhere (which can also be used as an externs file for other project, even better if it had type annotations), why are you not using the @expose annotation instead?
| const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
| const objHasOwnProperty = Object.prototype.hasOwnProperty; | ||
|
|
||
| const RESERVED_PROPS = { |
There was a problem hiding this comment.
Related to #12368 #12370 #12530
This RESERVED_PROPS change is no longer required because Closure-compiler was fixed to not collapse properties of objects which are accessed using hasOwnProperty: google/closure-compiler@c13cf48
This fix is included in release v20180319
Based on discussions on the mentioned PR's I think the change should be reverted.
|
Any plans to revisit this any time soon? |
|
+1 |
Follow-up from #11967 to only compile the
reactbundle with GCC advanced mode. I also cleaned up the externs here to be consistent with the current public API. I also removed the type annotations from the externs file, since we don't use GCC for type-checking anyway.