Using a combination of babelify, watchify, envify, and uglify, I have set the node_env with the following command:
watchify ... -g [envify --NODE_ENV development]
This led me to consider creating an assert function like this:
import assert from 'assert';
function debug_assert(actual, expected, message = 'AssertionError'){
if(process.env.NODE_ENV !== 'production'){
assert.equal(actual, expected, message);
}
}
It's interesting how uglify is able to remove the body of debug_assert but not calls to debug_assert in the code.
Is there a way to properly eliminate assert calls from the release build without adding too much extra code?