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

fix(utils): warn only in development environment #3367

Merged
merged 9 commits into from
Jan 15, 2019

Conversation

francoischalifour
Copy link
Member

This is the new signature of the warning method:

warning(condition: boolean, message: string)

It logs a warning only if the condition is not met.

The condition is now part of the method so that the production UMD build is stripped correctly with less code.

@francoischalifour francoischalifour requested a review from a team December 19, 2018 14:52
@algobot
Copy link
Contributor

algobot commented Dec 19, 2018

Deploy preview for instantsearchjs ready!

Built with commit 5eb1e79

https://deploy-preview-3367--instantsearchjs.netlify.com

@Haroenv
Copy link
Contributor

Haroenv commented Dec 19, 2018

the boolean trap as first argument seems a bit odd, since I would be surprised if the bundler can actually detect this as unused code when DEV is false. It probably needs to have its own if around each of them

@francoischalifour
Copy link
Member Author

The bundler does detect them. If we keep the wrapping if, it will transpile to something like:

// ...
{
  // whatever was here on top on the warning
}
// ...

With the condition inside the warning method, it's completely stripped.

FYI this is what React is doing for their invariant and warning functions.

@Haroenv
Copy link
Contributor

Haroenv commented Dec 19, 2018

Ah you're right, it's quite surprising that the bundler inlines those things. I didn't expect that, but that's good news!

@francoischalifour francoischalifour changed the base branch from v3 to develop December 20, 2018 14:43
Haroenv
Haroenv previously requested changes Jan 4, 2019
src/connectors/geo-search/connectGeoSearch.js Outdated Show resolved Hide resolved
src/connectors/geo-search/connectGeoSearch.js Outdated Show resolved Hide resolved
src/connectors/geo-search/connectGeoSearch.js Outdated Show resolved Hide resolved
@francoischalifour francoischalifour dismissed Haroenv’s stale review January 4, 2019 12:56

Removed unnecessary checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants