-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Displaying wrong warning about process.env.NODE_ENV #4180
Comments
@schmeter Afraid that's not enough details to understand what your setup is. Can you put together a repo that reproduces this issue? Where are you "setting |
@markerikson Setup can be found here, see PR with related logs in setup phase and production output: https://github.com/schmeter/music/pull/20/files |
Just defining |
@markerikson Closing might be quite overhasty here, the issue is as described: Displaying that |
@schmeter per my comment, the issue is not about setting the actual value of In other words, this code in a library in if (process.env.NODE_ENV !== 'production') {
console.log('Some dev-only warning')
} Must get transformed into this code during the build process: if ('production' !== 'production') {
console.log('Some dev-only warning')
} which will then be eliminated by a minifier as the comparison results in dead code. This requires a literal string search-and-replace operation, completely separate from the actual value of Now, it's true that the value used in that search-and-replace is normally based on the value of With Webpack, you'd normally do it using the new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
VERSION: JSON.stringify('5fa3b9'),
BROWSER_SUPPORTS_HTML5: true,
TWO: '1+1',
'typeof window': JSON.stringify('object'),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}) or alternately the Ultimately, this is an issue with your build setup. I see per https://github.com/schmeter/music/blob/034e56554164489d1758b12ccb5e4ebe41f61682/Gruntfile.js#L38-L40 that you're defining |
Ah, gotcha. Per the release notes for 4.1.0 at https://github.com/reduxjs/redux/releases/tag/v4.1.0 , we removed the |
The message says it quite explicitly: You are currently using minified code outside of NODE_ENV === "production". This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) to ensure you have the correct code for your production build. I use loose-envify as announced an it fails? Envify doesn't work too. |
I've never used Browserify or loose-envify myself. My assumption, based on the existence of that field in our Because we removed that listed transform from our own That, ultimately, is something that's outside the scope of Redux itself. |
So the issue here is still that this warning is wrong, isn't it? If loose-envify is removed, it should not be announced to be used, I guess. |
The warning is correct. What appears to be happening is that loose-envify is no longer getting applied to the Redux library code, and thus the warning is coming into play. Related: https://github.com/browserify/browserify#browserifytransform |
Nah. Variables set and minification applied. If extraordinary transforming is enforced by specific implementions, a "help-yourself"-warning with indistinct expression is neither helpful nor correct. As you don't agree with that grammar, that's your playground then. Thanks for having a look and clarifying that. |
@schmeter I'm not sure you're understanding what I'm saying here. Per Browserify's docs, if a As far as I can see, Browserify doesn't automatically transform lib sources otherwise. I'm assuming that listing transforms in your Browserify config will, by default, only apply those to your own application's source code, but not to libraries. We removed that entry from our But no, it's not our responsibility to try to list exact instructions on how to configure external tools like that, and especially in a warning message. A pointer in the general direction is sufficient. |
@markerikson Understanding is exactly what I'm talking about. If the warning would express clearly what is happening here, no questions needed to redux devs. As it is not, here's the thread: The message is not sufficient. You cannot argue as a person who sends a message, but I can as I receive it. Easy principle, not opinionated but proven in ages. Besides: Sharing is caring. A future answer to someone pointing at things should be: Thanks for making things up here, as free QA to our work is always very welcome. We'll consider to have better message output for the future. Closing an issue because of an opinion is the opposite. |
tl;dr to all future googlers: process.env.NODE_ENV = "production";
browserify()
.transform(require('envify'), { global: true }) Like markerikson pointed out, envify will only process react code if you pass a specific Sucks to be a browserify user, this thread appears to be the only source of information about the true purpose of envify lib and how to properly use it. There also appears to be a vagueness in the usage of the lib. Hope I was the last person to still keep looking for the solution from here. |
What is the current behavior?
Console output is the following: You are currently using minified code outside of NODE_ENV === "production"...
Steps to Reproduce
What is the expected behavior?
No output.
Environment Details
4.1.1, all browsers.
The text was updated successfully, but these errors were encountered: