Skip to content

transfomer: Namespace variable updates not reflected inside namespace functions #14227

@shulaoda

Description

@shulaoda

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

Metadata

Metadata

Labels

A-transformerArea - Transformer / TranspilerC-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions