babel-plugin-conditional-compilation

c/c++ style conditional compilation

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-conditional-compilation
0.0.17 years ago7 years agoMinified + gzip package size for babel-plugin-conditional-compilation in KB

Readme

babel-plugin-conditional-compilation
c/c++ style conditional compilation

Example

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.

Installation

$ npm install babel-plugin-conditional-compilation

Usage

Via .babelrc (Recommended)

.babelrc
{
  "plugins": ["conditional-compilation", {/* compile-time constants */}]
}

Via Node API

require("babel-core").transform("code", {
  plugins: ["conditional-compilation", {/* compile-time constants*/}]
});