Closed alexeygolev closed 8 years ago
This is a great idea. Instead of just doing if(process.env.NODE_ENV!=="production")
to avoid the checking it might be nicer to conditionally define the function so that the type checking is completely left out.
Fair enough. The condition will still be env
I assume?
@alexeygolev Please take a look at the last commit. If it looks good to you I'll push it to npm.
@paldepind Dead code elimination can't figure it out:) We are still going to have all that validation code in production:) My idea was to eliminate it completely... To do this we need to actually wrap pieces of code into if(process.env.NODE_ENV!=="production"). This way the uglyfier will see if(false) and just remove it from the output on the build stage. This way we reduce the footprint of the library in addition to disabling the validators. Thoughts?
I use webpack which does the same kind of think as envify does. React uses the same trick for their warning messages. It lets you be quite verbose for development environments but remove it completely for production. I'm not sure if you find it useful though so the PR is more to illustrate the case)
Really nice lib! I thought it might be nice to wrap the validation logic into
if(process.env.NODE_ENV!=="production")
. This way the lib will be super light in production and additional type checking features could be introduce for development id needed.