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

Error __DEV__ is not defined on Web if not patched manually in webpack #29

Closed
AlanSl opened this issue Jun 21, 2022 · 0 comments · Fixed by #30
Closed

Error __DEV__ is not defined on Web if not patched manually in webpack #29

AlanSl opened this issue Jun 21, 2022 · 0 comments · Fixed by #30

Comments

@AlanSl
Copy link
Contributor

AlanSl commented Jun 21, 2022

There are a couple of raw checks on __DEV__ in logger.ts that will cause a hard crash if @gorhom/portals is used in a default React Native Web build. The cause is that React Native Web doesn't define a global __DEV__ variable like React Native does.

Many libraries avoid this by doing a check that doesn't presume the existence of the global variable, e.g. if (typeof __DEV__ !== 'undefined' && __DEV__) instead of if (__DEV__).

Individual apps could work around having dependencies like this that do raw checks on __DEV__ by implementing their own webpack plugins to rewrite __DEV__ and then apply this to the appropriate modules in their build; but this can be a problem if using this library in a shared package like a components library, because it forces every consumer to add this config to their web builds, which can be difficult in some environments.

I'm happy to put up a PR for this [edit] - #30

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 a pull request may close this issue.

1 participant