facebookarchive / prepack

A JavaScript bundle optimizer.
http://prepack.io
Other
14.22k stars 424 forks source link

Prepack emits if-statements with no consequent or alternate code #2220

Open NTillmann opened 6 years ago

NTillmann commented 6 years ago

This

(function () {
  let n = global.__abstract ? __abstract("number", "23") : 23;
  if (n === 42) {
    let d = Date.now(); // dead pure generator entry
  }
})();

prepacks to

if (23 === 42) {}

which is obviously suboptimal.

During its fixpoint computation, the visitor should not visit the condition until at least one generator entry cannot be omitted.

Gyran commented 6 years ago

This sounds interesting to look at. Any pointers on where to start looking?

Gyran commented 6 years ago

Should the output be just nothing?

jhalak27 commented 4 years ago

@NTillmann I am new here, could you tell me more about this issue?