-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
warn user when using minified code outside of NODE_ENV 'production' #1075
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,22 @@ import bindActionCreators from './utils/bindActionCreators' | |
import applyMiddleware from './utils/applyMiddleware' | ||
import compose from './utils/compose' | ||
|
||
/* | ||
* create a function so that we can check if the function name has been altered by minification | ||
* if the function has been minified and NODE_ENV !== 'production', warn the user | ||
*/ | ||
function isCrushed() {} | ||
|
||
if (isCrushed.name !== 'isCrushed' && process.env.NODE_ENV !== 'production') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't seem right, if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That comes from the Node universe, where 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CommonJS build of Redux uses Node conventions. You can explicitly use the UMD builds in We just went ahead with the same pattern React is using. If you use the CommonJS build of React and don’t envify 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity though I would expect to see conditionals with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They use DEV in their codebase, which is converted to the process.env format when they build the CommonJS version for publishing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting, got it! |
||
/*eslint-disable no-console */ | ||
console.error('You are currently using minified code outside of NODE_ENV === \'production\'. ' + | ||
'This means that you are running a slower development only build of Redux. ' + | ||
'Consult tools such as loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + | ||
'and DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + | ||
'to build with proper NODE_ENV') | ||
/*eslint-enable */ | ||
} | ||
|
||
export { | ||
createStore, | ||
combineReducers, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems to behave differently in ie9 vs. modern browsers. Possible cause of #1311?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, fixed in 3.1.4.