c/c++ style conditional compilation
In
.babelrc
"plugins": [
["conditional-compilation", {
"DEBUG": 2
}]
]
somfile.js
let DEBUG;
"#if DEBUG > 1";
DEBUG = 1;
"#endif";
Out
somfile.js
let DEBUG;
DEBUG = 1;
For complete examples look at test directory.
$ npm install babel-plugin-conditional-compilation
.babelrc
{
"plugins": ["conditional-compilation", {/* compile-time constants */}]
}
require("babel-core").transform("code", {
plugins: ["conditional-compilation", {/* compile-time constants*/}]
});