Reproduction link or steps
https://repl.rolldown.rs/#eNptkEFPhDAQhf/KpJctLlbYRBNZPerVBI+uBxZahLCdzdCuawj/3SksURMvbd+81+nXGYQR2SC0dfSl2j6crch+dCzKIM9HJAdXYAgPsFI3BpHdFdtaZI68HmMx15YOFzXfN0ggTwVBC4/w9h5Dznuy5e0BNrd3W1iv82hHOwvQqqPvP6TMYR2sSDl8ddTYWqYser/vHck0mtIXLONt6Rq08CwjGOY2JdoeO606rGU7hcewCOYk7LoKP63ijGnqX8z/OH/+X2lT+M4tb3BVU3PgWRVdthQBGLAp3dNZlz5QvVClKYMwpDkxgYxiZJQT905VopLrvXaF2tyL8RsSQ4Dw
What is expected?
j to be declared in a scope that can be referenced from F like:
//#region foo.js
function F() {
console.log(j);
}
var j;
var init_foo = __esm({ "foo.js"() {
j = [];
for (var R = 0; R < 256; ++R) j.push((R + 256).toString(16).substr(1));
} });
//#endregion
What is actually happening?
j is declared in a closure and cannot be referenced from F.
//#region foo.js
function F() {
console.log(j);
}
var init_foo = __esm({ "foo.js"() {
for (var j = [], R = 0; R < 256; ++R) j.push((R + 256).toString(16).substr(1));
} });
//#endregion
System Info
Any additional comments?
Originally reported at vitejs/rolldown-vite#327