build-if.macro
This is a babel macro that lets you test a predicate at build-time, leaving the unused branch out of your runtime code, and pruning away any imports that were used only by the unused branch.
For example, this:
;console;
Compiles to:
console;
You will often want to use this in conjunction with a macro like preval
to compute the predicate:
;; const DEBUG_MODE = preval`module.exports = Boolean(process.env.ENABLE_DEBUG)`; { // ... ; // ...}