Protect __DEV__
from mis-minification / aggressive tree-shaking
#8393
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.
Inspired by discussion with @abdonrd: #8347 (comment)
Find/replace string transforms aside, I caught and fixed a real bug in this PR, which was that a webpack production build without any special handling for
__DEV__
would fail to include the__DEV__
polyfill (presumably due to tree-shaking), leading toReferenceError
exceptions within@apollo/client
code. Although we recommend using a minifier to inline__DEV__
as a boolean constant, it's important that everything works without configuring inlining (or anything else) in a build step. This PR restores that principle. Configuring your minifier to inline__DEV__
should be merely an optimization opportunity, not a hard requirement.Verified using our reproduction app (which is based on Create React App and thus also webpack).