Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect __DEV__ from mis-minification / aggressive tree-shaking #8393

Merged
merged 3 commits into from
Jun 17, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Jun 17, 2021

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 to ReferenceError 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).

@benjamn benjamn force-pushed the protect-__DEV__-from-misminification branch from 70c36de to e04e959 Compare June 17, 2021 19:48
@benjamn benjamn merged commit 666ed72 into release-3.4 Jun 17, 2021
@benjamn benjamn deleted the protect-__DEV__-from-misminification branch June 17, 2021 19:53
@hwillson hwillson added this to Done in Release 3.4 Jun 22, 2021
@hwillson hwillson removed this from the MM-2021-06 milestone Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants