minify
minify copied to clipboard
[Bug] DCE is failed with block expression
Code
const { transform } = require('@babel/core');
console.log(
transform(
`let isWeb = true;
{
if (isWeb) {
console.log('xyz');
} else {
console.log('abcd');
}
}
`,
{
plugins: ['babel-plugin-minify-dead-code-elimination'],
}
)
);
If code with a block expression, it will not remove the console.log('abcd');
Output
let isWeb = true;
{
if (isWeb) {
console.log('xyz');
} else {
console.log('abcd');
}
}
Expected
let isWeb = true;
{
console.log('xyz');
}
babel-plugin-minify-dead-code-elimination v0.3.0 is the expected output.
The reason of I updated the babel-plugin-minify-dead-code-elimination is the latest version @babel/traverse will remove the ThisExpression https://github.com/babel/minify/issues/1028
In my view, is it a break change for @babel/traverse ?