Repository navigation
Conversation
clydin
force-pushed
the
refactor/transitive-initial-files
branch
2 times, most recently
from
October 19, 2026 22:03
cc5e7af to
294c059
Compare
clydin
marked this pull request as ready for review
October 19, 2026 22:10
There was a problem hiding this comment.
Code Review
This pull request refactors the transitive initial files analysis by centralizing the logic into a new helper function, findTransitiveInitialFiles, in bundler-files.ts and adding comprehensive unit tests. The chunk optimizer and bundler context have been updated to use this new helper. Feedback on the changes suggests replacing the for...of loop in findTransitiveInitialFiles with a standard index-based for loop to avoid potential issues when mutating the queue array during iteration.
…nalysis Previously, both `BundlerContext` and `optimizeChunks` maintained separate implementations for discovering transitive initial files and calculating their import depths from the esbuild metafile. Both implementations used a depth-first stack traversal via `Array.prototype.pop()`, which visited deeper branches in reverse import order and failed to propagate updated minimum depths to the transitive dependencies of already-visited chunks in diamond dependency graphs. This commit extracts a shared `findTransitiveInitialFiles` helper that uses a breadth-first queue traversal over direct static imports. Processing chunks in breadth-first order guarantees that each file is discovered at its true shortest import depth on first visit, preserves the natural declaration order of imports at each depth level, and eliminates the duplicated metafile traversal logic across initial bundling and chunk optimization.
clydin
force-pushed
the
refactor/transitive-initial-files
branch
from
October 19, 2026 22:15
294c059 to
7751600
Compare
alan-agius4
approved these changes
Oct 20, 2026
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.
Previously, both
BundlerContextandoptimizeChunksmaintained separate implementations for discovering transitive initial files and calculating their import depths from the esbuild metafile. Both implementations used a depth-first stack traversal viaArray.prototype.pop(), which visited deeper branches in reverse import order and failed to propagate updated minimum depths to the transitive dependencies of already-visited chunks in diamond dependency graphs.This commit extracts a shared
findTransitiveInitialFileshelper that uses a breadth-first queue traversal over direct static imports. Processing chunks in breadth-first order guarantees that each file is discovered at its true shortest import depth on first visit, preserves the natural declaration order of imports at each depth level, and eliminates the duplicated metafile traversal logic across initial bundling and chunk optimization.