babel-plugin-transform-constant-string
transform constant string variable
Example
In
{ const bar = 'foo-bar' console; return bar}
Out
"use strict";const HELLO_WORLD = 'HELLO_WORLD'; { const bar = 'foo-bar'; const THIS_IS_A_CONSTANT_STRING_VALUE = 'THIS_IS_A_CONSTANT_STRING_VALUE'; console; const A_FOO = 'A_FOO'; const B_BAR = 'B_BAR'; const C_FOO_BAR = 'C_FOO_BAR'; return bar;}// output code
Installation
$ npm install babel-plugin-transform-constant-string
Usage
.babelrc
(Recommended)
Via .babelrc
{ "plugins": ["transform-constant-string", { "callName": "CONST" // string, which callee to be transformed, default is "CONST", "exportCallName": "CONSPORT" // string, which will add `export` for the variable, default is "CONSPORT" }]}
Via CLI
$ babel --plugins transform-constant-string script.js
Via Node API
;
license
MIT