Nocturnal Pumpkin Maelstrom

    babel-plugin-constif

    1.1.0 • Public • Published

    babel-plugin-constif

    This plugin allows Babel to remove if conditionals with string literals as condition.

    Example

    In

    if ("isDebug")
    	console.log(1);
    else
    	console.log(2);

    Out

    // IS_DEBUG=true babel script.js
    console.log(1);
    
    // IS_DEBUG=false babel script.js
    console.log(2);
    
    // babel script.js
    if ("isDebug")
    	console.log(1);
    else
    	console.log(2);

    Installation

    npm install --save-dev babel-plugin-constif

    Usage

    Via .babelrc (Recommended)

    .babelrc

    {
      "plugins": [
        ["constif", {var1: true, var2:false}]
      ]
    }

    Via CLI

    VAR1=true VAR2=0 babel --plugins constif script.js

    Via Node API

    require("babel-core").transform("code", {
      plugins: [
        ["constif", {var1: true, var2:false}]
      ]
    });

    Install

    npm i babel-plugin-constif

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • arash16