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

Guide tree-shaking by calling checkDEV() in utilities/globals/index.ts #8767

Merged
merged 3 commits into from Sep 10, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Sep 10, 2021

Actually using checkDEV by calling it (instead of just re-exporting it) appears to fix the reproduction provided in this comment by @lauraseidler: #8674 (comment)

I would have thought the "sideEffects": true configuration in @apollo/client/utilities/globals/package.json would be enough to keep the modules in @apollo/client/utilities/globals/* from being tree-shaken, but apparently Vite is clever enough to second-guess that guidance when it comes to uncalled function declarations like checkDEV.

Thankfully, we can get away with calling checkDEV() just this once, in the module that declares/exports it.

Actually using `checkDEV` by calling it (instead of just re-exporting
it) appears to fix the reproduction provided in this comment:
#8674 (comment)
@brainkim
Copy link
Contributor

LGTM

@benjamn benjamn merged commit e0ea45c into main Sep 10, 2021
@benjamn benjamn deleted the fix-vite-tree-shaking branch September 10, 2021 21:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants