1

Could someone suggest the right way to eliminate constants from the code in production mode? I've already tested babel-plugin-constant-folding and babel-plugin-dead-code-elimination but they both work only with babel 5, not with babel 6.

Example:

const K=1;
const B=K + 13;
console.log("b=" + B);

I expect to get:

console.log("k=" + 1 + ", b=" + 14)

or, better (honestly, I don't need this level of optimization, replacing all ID with their values without string concat is completely enough for me):

console.log("k=1, b=13")

but get only:

var K = 1,
    B = K + 13;
console.log("k=" + K + ", b=" + B);

Could someone suggest me the right sequence of babel plugins?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81

0 Answers0