When exporting a variable from a namespace and later updating it outside of the namespace, the update is not reflected inside namespace functions. This leads to inconsistent state between internal and external references.
Example
export namespace Foo {
export let baz = 1;
export function bar() {
return ++baz;
}
}
Foo.baz = 10;
console.log(Foo.bar()); // Should print 11 - but prints 2
console.log(Foo.bar()); // Should prints 2
console.log(Foo.baz); // Still prints 1;
Related Links
Playground here
Original issue: rolldown/rolldown#6347