javascript - How to have asserts removed in release build? -
i use babelify + watchify + envify + uglify , set node_env watchify ... -g [envify --node_env development]
so thought of having assert this:
import assert 'assert'; function debug_assert(actual, expected, message = 'assertionerror'){ if(process.env.node_env !== 'production'){ assert.equal(actual, expected, message); } }
uglify smart enough cut out body of debug_assert not actual calls debug_assert in code.
without code possible have assert calls removed release build?
you use jsfmt , code rewriting feature:
jsfmt --rewrite "assert.equal(a, b, c) -> ''" file.js
haven't tested, might job. replaces occurrences of assert.equal
empty string.
Comments
Post a Comment