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

Check self.process before reading for browser compatibility #2910

Closed
wants to merge 1 commit into from

Conversation

keanulee
Copy link

With this patch, browsers can directly run the ES module build of Redux from https://unpkg.com/redux@4.0.0-beta.2/es/redux.js?module and other tools that converts package names to paths.

Fixes #2907

@timdorr
Copy link
Member

timdorr commented Mar 28, 2018

Thanks for this. I think it looks good, but anyone else want to chime in?

@jimbolla
Copy link
Contributor

@timdorr The thing to verify is that those blocks still get removed in the prod build. I suppose comparing the prod build size before and after this change would work.

@timdorr
Copy link
Member

timdorr commented Mar 28, 2018

Yep, I'll want to verify locally to be sure. I'll try to run that through tonight or tomorrow at some point.

@kaushik94
Copy link

@jimbolla @timdorr the way react does this check is by defining a __DEV__ variable. Chances are you already knew this. Although I don't know how to define this globally, we can still define something like this in index.js file and export from there to check if(__DEV__) , I think this would be a cleaner solution? I would be glad to implement this, and also would like to work on this library for self-improvement. I would be happy if I can contribute, even if it's a small change :)

@timdorr
Copy link
Member

timdorr commented Apr 1, 2018

@kaushik94 That's transformed into a NODE_ENV check during the build process. They use it as a shorthand while coding, but it's not how the build comes out compiled.

@timdorr
Copy link
Member

timdorr commented Apr 9, 2018

I checked against the production build, and they are still sticking around in the UMD build, unfortunately. I'm not sure there is a good way to fix this internally at the moment.

I would instead either use the UMD version or "polyfill" with window.process = { env: 'production' } before importing.

This pull request was closed.
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.

4 participants