Repository navigation
fix(javascript): honor computed keys when naming callables, exports, requests and options - #536
Conversation
…requests and options
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19d3573419
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // `exports[key]`/`module.exports[key]` assign an export whose name is not | ||
| // knowable. Report the wildcard rather than the variable name, and never | ||
| // collapse it into `default`, which would claim a real default export. | ||
| if (key === null) return "*"; |
There was a problem hiding this comment.
Check the export receiver before accepting a dynamic key
For any ordinary dynamic assignment such as cache[key] = value, key is null and this early return reports a wildcard CommonJS export without first verifying that the receiver is exports or module.exports. collectCommonJsExport therefore adds a fabricated module link, and downstream moduleFormat can misclassify otherwise unrelated source as CommonJS; restrict the wildcard result to recognized CommonJS export receivers.
AGENTS.md reference: AGENTS.md:L9-L9
Useful? React with 👍 / 👎.
…requests and options (morluto#536)
Generalizes the fix from #507 (computed destructuring keys) to the four sibling readers that still resolved a property name straight off the key node without consulting
computed. Each one reports an invented name — a variable name presented as a fact about the program.commonJsExportName:exports[key] = addonyieldedexportedName: "key", andmodule.exports[key] = addonyieldeddefault, claiming a real default export. Now returnsnullfor a non-committing key and reports the wildcard*— the assignment is observed, its name is not invented, and it is no longer collapsed intodefault.callableName:{[key]() {}}andclass A { [key]() {} }were namedkey; they now use the existing[computed@<offset>]form the module-table reader already uses.requestFields:fetch(url, {[key]: 1})reported a request field namedkey.objectProperty(child processes):spawn(cmd, {[env]: vars})was read as a literalenvoption and setenvironmentSupplied: true.calleeNameAt:target[method]()producedtarget.method, fabricating a runtime call shape.Root cause is one shared defect rather than five:
semanticStaticPropertyName(key, computed)already existed for exactly this, but only 5 of ~10 call sites used it. Rather than patch each reader again, I added a localmemberKeyhelper in the projection module (distinguishing "no name" from "empty name") and routed the CJS export path through it.Tests: added dynamic-key cases to the structure and runtime-boundaries suites. Full suite green (1918 passed); the only 2 failures were a stale generated
docs/product-catalog.jsondigest left by the concurrent #535 schema work, which resolves afternpm ci+mcp-catalog:generateand is unrelated to this change.