babel / babel/minify

strange dead code elimination output

Open
#895 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

I have all done the test with http://babeljs.io/repl it says babel 6.x

input :
```
(function(){
// not call function, should delete.
function nfn1(){
console.log("not use1");
}
// not use object ,should delete.
var nobj = {};
// not call function, should delete.
nobj.m = function(){
console.log("not use2");
}
var flag = false;
if (flag==true){
console.log("not use3");
}
function kNew(){
return {};
}
var gObj = null;
function kGetDefault(){
if (gObj === null){
gObj = kNew();
}
return gObj;
}
function kSetDefault(ke){
gObj = ke;
}
// /////////
// should remain test:
function uobj(){
console.log("use 3");
}
// export api,must in the source code.
window["abc"] = function(){
console.log("use 1");
}
// direct run code, must in the output code
console.log("use 2");
uobj();

})();
```

output:
```
(function() {
var h = null;
(window.abc = function() {
console.log("use 1");
}),
console.log("use 2"),
(function() {
console.log("use 3");
})();
})();
```

What is the `var h = null;` stuff?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.