Don’t bundle DebugTool in production#7189
Merged
gaearon merged 1 commit intofacebook:masterfrom Jul 5, 2016
gaearon:disable-debugtool-in-prod
Merged
Don’t bundle DebugTool in production#7189gaearon merged 1 commit intofacebook:masterfrom gaearon:disable-debugtool-in-prod
gaearon merged 1 commit intofacebook:masterfrom
gaearon:disable-debugtool-in-prod
Conversation
zpao
pushed a commit
that referenced
this pull request
Jul 8, 2016
(cherry picked from commit 5d31ebc)
usmanajmal
pushed a commit
to usmanajmal/react
that referenced
this pull request
Jul 11, 2016
keyz
pushed a commit
to keyz/react
that referenced
this pull request
Jul 13, 2016
gaearon
added a commit
that referenced
this pull request
Jul 14, 2016
zpao
pushed a commit
that referenced
this pull request
Jul 22, 2016
keyz
pushed a commit
to keyz/react
that referenced
this pull request
Jul 25, 2016
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most of this diff is indentation.
I am removing all
__DEV__checks fromReactDebugToolandReactDOMDebugToolcode. Instead, I am conditionally requiring them—in production,ReactInstrumentation.debugToolandReactDOMInstrumentation.debugToolwould now benullafter this change.Why I am doing this:
.debugTool.*are guarded by__DEV__.__PROFILE__build, we can change the same condition to include__PROFILE__. There’s nothing here that would make it harder in the future.In the future, we might allow attaching devtools in production. Let’s do it when we actually have a use case for it. Right now it’s weird because we have these constraints that don’t actually end up getting used. This makes debug tool architecture more confusing to whoever who will be adding the
__PROFILE__build.Even when we allow this, it is likely that the actual DebugTool would be external code. There is no need for it to live inside React. The default “broadcasting” DebugTools are good for development but I don’t see why they are useful in prod.
Let’s just keep it simple for now and let the code reflect our real usage. Debug tools are only called in development environment now.
This reduces build size a bit:
If we are concerned about stray
.debugTool.*calls that would blow up in production, we can lint against using.debugTool.outside a__DEV__block. We don’t add new calls very often though so I’m not sure if it’s worth it.