fix(javascript): ignore bare CommonJS exports rebinding

Assigning a new value to the exports alias does not replace module.exports. Stop inventing a default export link and definite return-shape changes for that assignment.

Validation: 22 semantic structure source tests and 49 compiled CLI/MCP acceptance tests passed. The new regression checks Node require returns an empty export object for both versions and both adapters report missing defaults without definite changes.
This commit is contained in:
morluto
2026-10-11 07:30:52 +08:00
parent c57e759ae6
commit 8b2f8514c5
2 changed files with 26 additions and 1 deletions
@@ -641,7 +641,7 @@ const commonJsExportName = (
node: t.Node,
state: JavaScriptSemanticAnalysisState,
): string | undefined => {
if (isUnshadowedGlobal(node, state, "exports")) return "default";
// Rebinding the CommonJS `exports` alias does not replace `module.exports`.
if (!t.isMemberExpression(node) && !t.isOptionalMemberExpression(node))
return undefined;
const key = semanticStaticPropertyKey(node.property, node.computed);