bundle-analyzer: add 'Sync only' filter toggle#92958
Open
bmaurer wants to merge 1 commit intovercel:canaryfrom
Open
bundle-analyzer: add 'Sync only' filter toggle#92958bmaurer wants to merge 1 commit intovercel:canaryfrom
bmaurer wants to merge 1 commit intovercel:canaryfrom
Conversation
Adds a toggle in the bundle-analyzer toolbar that filters the treemap to show only modules reachable from an entry without crossing an async import() boundary. Uses the existing `computeModuleDepthMap` where async edges add 1000 to the depth; a source is kept if any of its module indices has depth < 1000. Helps developers see what's actually in the initial critical path without the noise of lazy-loaded code.
Collaborator
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
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.
What
Adds a Sync only toggle to the bundle-analyzer toolbar that filters the treemap to show only modules reachable from an entry without crossing an async
import()boundary.Why
When analyzing a route, the treemap currently shows every reachable module, including anything behind one or more
(async)hops. For example a 418KBcytoscape.esm.mjscan show up on the home-page treemap even though it's only reachable via:That makes it hard to see what's actually in the critical initial load. The data model already distinguishes sync vs async edges — this just exposes it as a filter.
How
computeModuleDepthMapalready encodes this: each async hop adds 1000 to a module's depth. So any module whose depth is>= 1000is behind at least one async boundary.filterSourcereceives asourceIndex, so we bridge throughmodulesData.getModuleIndiciesFromPath(fullSourcePath(sourceIndex))and keep the source if any of its module indices has depth< 1000. Existing filters (environment, file type) are unchanged.The toggle button sits next to the existing environment/type filters. No change to the import-chain view — it still shows the
(async)markers in the chain so users can see where the boundary is.Verification
Tested against a minimal demo app with a home page that sync-imports a small utility and uses
dynamic(() => import('./HeavyChart'))whereHeavyChartpulls in a 25-filebig-lib/*tree.big-lib/*files, −75 KB)All
big-libmodules landed at depth 1005–1006 in the depth map, confirming they're correctly detected as async-only.tsc --noEmitandnext buildpass inapps/bundle-analyzer.