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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -