Allow removal of debug code in production builds#349
Conversation
|
Thanks @tschaub - It may be a good idea to create a utility function to do this? Something like: That way we can keep the NODE_ENV check inside a single function. |
|
@hai-cea I understand the desire to move the repeated code to utility functions, however I think that might defeat the purpose. The idea here is to keep the warning strings out of production builds. If the implementation of Defining a I understand if these checks seems like a hassle to maintain. And removing the warning strings from production builds is a pretty minor optimization. There would still be some benefit of a utility function that was a no-op in production. |
Allow removal of debug code in production builds
|
Thanks @tschaub - Makes sense to me. |
|
Why are we using process.NODE_ENV when react is using process.env.NODE_ENV ? |
|
@oliviertassinari very bad typo. Needs to be fixed. |
|
@oliviertassinari's PR has been merged |
By wrapping debug code in conditions with
process.NODE_ENV !== 'production', people using compressors that do dead code removal can generate production builds without the debug code.This is possible using Browserify with the
envifytransform before running code through Uglify (with--compress dead_code=true). React itself uses this same pattern.