fix(javascript): preserve exact static CommonJS export keys

This commit is contained in:
Rudy Celekli
2026-10-09 17:26:13 -04:00
parent 411498d45f
commit a47517c67c
3 changed files with 94 additions and 44 deletions
@@ -15,7 +15,7 @@ it("collects a 12,000-member CommonJS export path without recursion", () => {
]);
});
it("preserves empty, dynamic, this, and private member path behavior", () => {
it("preserves empty keys without inventing dynamic, this, or private exports", () => {
const file = parseJavaScriptSource(`
exports[""].value = 1;
exports[""] = 0;
@@ -24,11 +24,7 @@ it("preserves empty, dynamic, this, and private member path behavior", () => {
class Example { #private = 0; read() { this.#private = 1; } }
`);
if (file === null) throw new Error("Expected valid JavaScript");
expect(collectJavaScriptExports(file).values).toEqual([
"",
".value",
"key.value",
]);
expect(collectJavaScriptExports(file).values).toEqual(["", ".value"]);
});
it("keeps left-first and outer-member-first bundler runtime matches", () => {