Skip to content

Show async module scope in bundle analyzer - #98918

Merged
wbinnssmith merged 2 commits into
wbinnssmith/bundle-analyzer-delta-treemapfrom
wbinnssmith/bundle-analyzer-async-scopes
Oct 2, 2026
Merged

wbinnssmith merged 2 commits into
wbinnssmith/bundle-analyzer-delta-treemapfrom
wbinnssmith/bundle-analyzer-async-scopes

Conversation

@wbinnssmith

@wbinnssmith wbinnssmith commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

What?

Show source load scope in the bundle analyzer's single-build view: label async-only and mixed sources in the table, mark them in the treemap with a legend, and add an Initial only filter.

Why?

Help distinguish sources reachable only behind an async import boundary from sources reachable through an initial path (or both). This describes module-graph reachability, not when a browser actually requests a chunk.

How?

Traverse the route's active-entry module graph, propagating initial, async, and traced reachability across dependencies. Combine the reached module scopes for each source, then pass the resulting classification to the table, treemap, and filter. The new filter and indicators apply to the single-build view; the comparison view keeps its existing behavior.

Verification: Bundle-analyzer typecheck, focused lint/format checks, and production build passed; all eight combinations of the scope flags were checked when simplifying the classification logic.

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 5c0e8b0

@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from ad47f1f to 5dd4d24 Compare September 22, 2026 22:43
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 5dd4d24 to 7f6b183 Compare September 24, 2026 17:39
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch 4 times, most recently from 37c5dcf to 5f38e02 Compare September 25, 2026 19:55
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch 2 times, most recently from 81b2912 to ea38acf Compare September 25, 2026 21:50
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch 2 times, most recently from 1d704c8 to da27048 Compare September 28, 2026 16:33
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from da27048 to cce7862 Compare September 28, 2026 19:21
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from cce7862 to eb166cc Compare September 28, 2026 19:33
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from eb166cc to 76542f9 Compare September 28, 2026 21:22
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 76542f9 to 6fc165c Compare September 28, 2026 22:29
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 6fc165c to 6b547c9 Compare September 28, 2026 22:42
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 6b547c9 to a8b2884 Compare September 28, 2026 23:19
@wbinnssmith
wbinnssmith marked this pull request as ready for review September 29, 2026 00:06
}
}, [modulesData, analyzeData])

const filterSource = useMemo(() => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can go with react compiler

className="flex h-8 cursor-pointer items-center gap-2 whitespace-nowrap px-1"
title="Show only modules with an initial synchronous path"
>
<span className="text-xs">Initial only</span>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial load only

Comment thread apps/bundle-analyzer/lib/module-graph.ts Outdated
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 23ca839 to 0da39f5 Compare October 1, 2026 01:06
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch 3 times, most recently from 6351a7d to a08b81d Compare October 1, 2026 21:32
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from a08b81d to 616ae35 Compare October 2, 2026 00:07
export type SourceLoadScope =
| 'initial'
| 'async'
| 'mixed'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial|Async → "mixed"

That logic doesn't make sense to me. If a module is loaded initially and async, that will cause it to be loaded initially and not async.

So I think it should be Initial|Async → Initial

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distinction may matter to the user: it might be surprising to turn an import async only to find it's still part of the initial payload. Showing it as mixed would be a cue that something is still retaining it synchronously.

@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from 1977904 to d776af5 Compare October 2, 2026 15:43
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch 2 times, most recently from 616ae35 to ca4d491 Compare October 2, 2026 18:17
@wbinnssmith
wbinnssmith removed this pull request from stack #98790 October 2, 2026 20:22
@wbinnssmith
wbinnssmith added this pull request to stack #99604 October 2, 2026 20:23
vercel-fleet-prod Bot and others added 2 commits October 2, 2026 13:34
Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
Co-authored-by: Will Binns-Smith <755844+wbinnssmith@users.noreply.github.com>
@wbinnssmith
wbinnssmith force-pushed the wbinnssmith/bundle-analyzer-async-scopes branch from ca4d491 to 5c0e8b0 Compare October 2, 2026 20:44
@wbinnssmith
wbinnssmith merged commit 3737d0f into canary Oct 2, 2026
153 of 171 checks passed
@wbinnssmith
wbinnssmith deleted the wbinnssmith/bundle-analyzer-async-scopes branch October 2, 2026 21:20
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants