When this code
// source
if (true) {
function foo () {};
eval('');
}
is transformed with default settings in esbuild 0.16.10, esbuild produces the following invalid output
// transformed
if (true) {
let foo = function() {
};
var foo = foo;
;
eval("");
}
=> Identifier 'foo' has already been declared
To reproduce, just call the transform API like this:
// index.js
console.log(require('esbuild').transformSync(`if (true) { function foo () {}; eval(''); }`).code)
I'm aware that direct eval should be avoided, but esbuild still should be able to produce valid output when it is used in the sources.