When running the code snippet (taken from a MDN page regarding the let keyword in ES2015) through the online Babel transpiler, it fails with the following error:
repl: We found a path that isn't a NodePath instance. Possiblly due to bad serialisation.
Code
var list = document.getElementById("list");
for (var i = 1; i <= 5; i++) {
var item = document.createElement("LI");
item.appendChild(document.createTextNode("Item " + i));
let j = i;
item.onclick = function (ev) {
console.log("Item " + j + " is clicked.");
};
list.appendChild(item);
}
Why is the error thrown and what can I do about?