warn user when using minified code outside of NODE_ENV 'production'#1075
warn user when using minified code outside of NODE_ENV 'production'#1075timdorr merged 1 commit intoreduxjs:masterfrom
Conversation
554e8d9 to
56592f7
Compare
|
This looks correct. (Have you checked whether it works?) |
56592f7 to
1d91a0c
Compare
|
@gaearon updated, is this what you meant by moving the check inline? Yes, I tested with this branch in a small app using redux and webpack with
|
src/index.js
Outdated
There was a problem hiding this comment.
We're only using warningMessage once, let's put it right inside the console.warn call?
There was a problem hiding this comment.
yeah, that makes sense, updated.
7ee88ba to
2da0dea
Compare
|
Thanks! |
2da0dea to
dee4645
Compare
|
@gaearon sounds good thanks for such a great project and for the quick review/feedback! |
dee4645 to
76f6174
Compare
|
utilzing → utilizing. Or much better: using. |
76f6174 to
320a1c7
Compare
320a1c7 to
9b4754c
Compare
|
I'll tweak the error message anyway before merging, no worries! |
|
@gaearon I'm going to merge this in and tweak the message a tad on master. Please flog me appropriately if you disagree or don't like my tweaks :) |
warn user when using minified code outside of NODE_ENV 'production'
|
Thanks, please do! |
|
Out in 3.0.6, thanks! |
|
Hi |
|
I would use another ENV for swapping your configuration based on environment (
|
Yes, this is the reason we went with it. For example, React behaves much slower with |
|
Searched the source code and saw this now |
|
Well, it's being used in tons of projects now so we're not changing it anytime soon :-) |
|
If you don't want to deal with it you can use UMD builds. The minified build is envified for prod environment. |
|
I will use my own environment as suggested :) |
There was a problem hiding this comment.
This line seems to behave differently in ie9 vs. modern browsers. Possible cause of #1311?
|
We are using react with Java backend and this same error pops up. Why is that? |
|
It means you are minifying the code, but not envifying the CommonJS build. What do you build your JavaScript assets with? |
|
We are using Webpack, is this what we should do |
Yes. |
| */ | ||
| function isCrushed() {} | ||
|
|
||
| if (isCrushed.name !== 'isCrushed' && process.env.NODE_ENV !== 'production') { |
There was a problem hiding this comment.
This doesn't seem right, if process.env.NODE_ENV is not defined that doesn't necessarily indicate that I'm using minified code outside of production, or am I missing something? In our codebase we define NODE_ENV without the "process.env" prefix but I can imagine lots of apps have no need to define it.
There was a problem hiding this comment.
From POV it was pretty surprising to see this pop up in production builds. Doesn't seem like something a library should try to enforce IMO.
There was a problem hiding this comment.
That comes from the Node universe, where process.env.NODE_ENV is defined by default. process is a global in Node. It is used in many libraries (React included) to define where development code is. Our module bundler (and most common setups) replaces the text process.env.NODE_ENV with "production", which gets eliminated by an optimizer as dead code.
So, it would be a good idea to emulate the same behavior, even if you don't like it. There are some Babel plugins to make this easier (letting you use a global DEV). You're probably getting development builds of many other things for the same reason.
There was a problem hiding this comment.
The CommonJS build of Redux uses Node conventions. You can explicitly use the UMD builds in dist folder if you’d rather avoid them.
We just went ahead with the same pattern React is using. If you use the CommonJS build of React and don’t envify process.env.NODE_ENV, you are running a slow development version of React in production.
From http://facebook.github.io/react/docs/getting-started.html#using-react-from-npm:
We just follow the same convention.
There was a problem hiding this comment.
Fair enough. I suppose it makes sense for libraries to follow a convention for this and being loud about an inefficient build is good service. Thanks to both for your responses!
There was a problem hiding this comment.
Out of curiosity though I would expect to see conditionals with process.env.NODE_ENV or similar in the react codebase, but I don't. If I'm using webpack and requiring react how does defining it make the react build faster?
There was a problem hiding this comment.
They use DEV in their codebase, which is converted to the process.env format when they build the CommonJS version for publishing.

@gaearon my attempt at #1029 . Likely still needs a bit of work but I wanted to get your opinion before i continued. thanks!