if ( 0 ) {
var x = foo();
}
// or
if (0) var x = bar();
out:
This can either be done by hoisting vars for all functions before IfStatement is reached, or by analysing the pathToBeRemoved for var declarations.
I tried the latter approach here - https://github.com/boopathi/babel-minify/blob/0fbb45d18b13df53dd225dbd36ef0af88c7190ea/packages/babel-plugin-transform-conditionals/src/replace-with.js#L65-L88
out:
This can either be done by hoisting vars for all functions before IfStatement is reached, or by analysing the pathToBeRemoved for var declarations.
I tried the latter approach here - https://github.com/boopathi/babel-minify/blob/0fbb45d18b13df53dd225dbd36ef0af88c7190ea/packages/babel-plugin-transform-conditionals/src/replace-with.js#L65-L88