Apply optimization for unused actions (#69178)#4
Open
MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
Open
Apply optimization for unused actions (#69178)#4MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
MitchLewis930 wants to merge 1 commit intopr_034_beforefrom
Conversation
Greptile OverviewGreptile SummaryThis PR implements tree-shaking optimization for server actions in Next.js webpack builds, eliminating unused exported actions from the bundle to reduce size. Key Changes:
Test Coverage:
Turbopack Status: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant WP as Webpack Compilation
participant FCEP as FlightClientEntryPlugin
participant MG as Module Graph
participant AM as Action Manifest
Note over WP,FCEP: Server Entry Processing
WP->>FCEP: processServerEntry(entryName, dependencies)
FCEP->>MG: Traverse module graph from entry
MG-->>FCEP: Collect client components & CSS imports
Note over FCEP,MG: Track Used Actions (New)
FCEP->>MG: filterUsedActions(module, importedIds)
loop For each dependency
MG->>FCEP: Get dependency.ids (imported identifiers)
alt Is action server layer entry
FCEP->>FCEP: setUsedActionsInEntry(entryName, modResource, ids)
else Continue traversing
FCEP->>MG: Recurse to next module
end
end
Note over WP,FCEP: Client Entry Processing
WP->>FCEP: injectClientEntryAndSSRModules()
FCEP->>MG: collectClientActionsFromDependencies(entryName)
MG-->>FCEP: Return all action imports
Note over FCEP,MG: Filter Unused Actions
loop For each action module
FCEP->>FCEP: getUsedActionsInEntry(entryName, filePath)
alt Has usedActionNames and not wildcard
FCEP->>FCEP: Filter to only used action names
else No usage tracked
FCEP->>FCEP: Remove from actions map (tree-shaken)
end
end
Note over FCEP,AM: Create Action Entries
FCEP->>WP: injectActionEntry(filteredActions, entryName)
FCEP->>AM: Update action manifest with remaining actions
WP-->>FCEP: Action entry created
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_034