Apply optimization for unused actions (#69178)#4
Apply optimization for unused actions (#69178)#4MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| ) { | ||
| actions.delete(filePath) | ||
| } | ||
| } |
There was a problem hiding this comment.
Unreachable else-if block contains dead code
Medium Severity
The else if (!containsAll) condition at line 974 can never evaluate to true. After line 967's if (!usedActionNames) continue, usedActionNames is guaranteed truthy. The preceding if (usedActionNames && !containsAll) at line 969 therefore simplifies to if (!containsAll). The else branch is only reached when containsAll is true, making the !containsAll check always false. This renders the actions.delete(filePath) call unreachable.
| // Collect used exported actions. | ||
| if (visitedModule.has(modResource) && actions) { | ||
| this.setUsedActionsInEntry(entryName, modResource, ids) | ||
| } |
There was a problem hiding this comment.
First visit skips recording used action identifiers
High Severity
In collectActionsInDep, setUsedActionsInEntry is only called when visitedModule.has(modResource) is true (on revisit). On first visit to an action module, the imported identifiers (ids) are not recorded. When multiple components in the same entry import different actions from the same file, the first component's action identifiers are lost, potentially causing those actions to be incorrectly filtered out during tree-shaking.
| usedActions: { | ||
| node: {} as Record<string, Set<string>>, | ||
| edge: {} as Record<string, Set<string>>, | ||
| }, |
There was a problem hiding this comment.
Declared pluginState.usedActions is never used
Low Severity
The usedActions property added to pluginState at lines 80-83 is declared but never read or written anywhere in the code. The implementation uses the instance property this.usedActions instead. This dead code adds confusion and increases maintenance burden.


PR_034
Note
Medium Risk
Touches webpack entry generation for Server Actions and changes what gets emitted into the server reference manifest; mistakes could break action availability at runtime, though the new test coverage reduces the risk.
Overview
Reduces
server-reference-manifest.jsonbloat by tracking which server actions are actually imported per entry and runtime (node vs edge) inFlightClientEntryPlugin, then filtering the action list before creating action entries.This introduces a second module-graph traversal to collect imported identifiers (including handling
esmvscjssemantics and preserving inline$$ACTION_identifiers), and adds new production tests covering basic usage, shared modules, re-exports, mixed ESM/CJS imports, and edge runtime behavior.Written by Cursor Bugbot for commit e951e89. This will update automatically on new commits. Configure here.