Skip to content

[flutter_tools] Fix web compiler output tracking in web builds - #196563

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:web-build-tracking
Nov 24, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
kevmoo:web-build-tracking

Conversation

@kevmoo

@kevmoo kevmoo commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes perpetual rebuilds and stale artifact leaks across consecutive flutter build web, --wasm, --source-maps, and --web-content-hash transitions, exposes resolved directory getters on Environment in build_system.dart, and replaces compiler filename regexes with WebCompiledArtifact list-pattern matching (follow-up to #196491; part of #149031).

  • Adds resolvedProjectDir and resolvedOutputDir getters on Environment (resolving symlinks and relative paths without mutating raw projectDir/outputDir), replacing per-target _resolveDirectory helpers in web.dart and updating _deleteStaleOutputs.
  • Scopes recorded_uses_js.json, recorded_uses_wasm.json, and {BUILD_DIR}/main.dart.support.js (Dart2WasmTarget.supportJsFileName) to active {BUILD_DIR} compiler targets (passing and keying active recordedUsesFileNames across LinkHooks, WebReleaseBundle, and copyAssets/IconTreeShaker, cleaning stale Wasm outputs and dart2wasm.d on dry runs, excluding {BUILD_DIR}/main.dart.support.js from Dart2JSTarget.resolveOutputs, WebReleaseBundle.resolveInputs, and non-Wasm WebTemplatedFiles.resolveInputs without dropping user web/** files, and dropping non-existent main.dart.mjs.map tracking) so unchanged non-dry-run and bundle targets skip cleanly without deleting _flutter.supportsDart2Wasm.
  • Strips absent assetManifest, fontManifest, and extraAssets keys in injectManifestBuildConfig (including when all three become absent) when re-injecting _flutter.buildConfig.
  • Replaces the compiler and bundle filename RegExp fields in web.dart with WebCompiledArtifact (basename.split('.') Dart 3 list patterns).

Pre-launch Checklist

- Replace the scattered compiler and bundle filename regexes with
  `WebCompiledArtifact` list-pattern classification so JS, Wasm,
  source-map, dump-info, and deferred module outputs share one source of
  truth without misclassifying `main.dart.support.js`.
- Clean stale compiler outputs in `buildDir` across unhashed `--wasm`,
  `--source-maps`, and `--dump-info` toggles, track
  `main.dart.support.js` on `Dart2WasmTarget` while excluding it from
  `Dart2JSTarget` wildcard outputs, and mark `main.dart.mjs.map`
  optional so consecutive `--wasm` builds skip cleanly.
- Keep `recorded_uses_*.json` on the compiler targets rather than bundle
  stems, mark web `recorded_uses` inputs optional in `LinkHooks` for
  JS-only builds, and reset stale `recorded_uses_wasm.json` on Wasm
  dry-runs.
- Strip stale `assetManifest`, `fontManifest`, and `extraAssets` entries
  before re-injecting hashed manifest paths into `_flutter.buildConfig`.
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 13, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Initial AI review pass

LoveDoLove pushed a commit to LoveDoLove-Forked-Projects/flutter that referenced this pull request Nov 17, 2026
…ions (flutter#196491)

Fixes flutter#196452 by registering
root templated `index.html` outputs in the build graph and
canonicalizing symlinked and relative output paths so switching off
`--web-content-hash` never deletes freshly generated `index.html`.

- Replaces literal `{PROJECT_DIR}/web/*/index.html` and
`{OUTPUT_DIR}/*/index.html` patterns (`SourceVisitor.visitPattern`
expands `*` only in the final filename segment) with optional
`{PROJECT_DIR}/web/index.html`,
`{PROJECT_DIR}/web/flutter_bootstrap.js`, `{OUTPUT_DIR}/index.html`, and
`web_templated_files.d` (deleting stale `outputDir/index.html` when
`web/index.html` is absent), templating only root `web/index.html` while
keeping nested `web/sub/index.html` files as plain static resource
copies.
- Canonicalizes `outputDir` and `projectDir` via
`resolveSymbolicLinksSync()` across `WebTemplatedFiles`,
`WebReleaseBundle`, and `WebServiceWorker` so relative `-o` and
symlinked output directories (such as macOS `/tmp -> /private/tmp`)
match `Source.pattern` keys across flag transitions and template edits.
- Scoped strictly to `WebTemplatedFiles`, `WebReleaseBundle`, and
`WebServiceWorker` so this fix cherry-picks cleanly onto `3.50`
(`WebCompiledArtifact` and compiler output tracking updates moved to
follow-up flutter#196563).

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@kevmoo
kevmoo marked this pull request as ready for review November 17, 2026 19:17

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Flutter build system's web target compilation by introducing a WebCompiledArtifact enum to classify and track compiled web artifacts instead of using complex regular expressions. It also updates the Environment class to resolve relative, symlinked, and uncreated project and output directories safely, and ensures stale manifest keys are dropped when updating build configurations. Feedback on the changes points out that buildStemSource checks for an exact match with main.dart.mjs.map to mark it optional, which fails when webContentHash is enabled and a wildcard is present; it is suggested to check if the stem ends with mjs.map instead.

- Pass active compileTargets recordedUsesFileNames into LinkHooks and
  return null on Wasm dry runs while keeping inputs non-optional.
- Run _cleanStaleBuildOutputs unconditionally in Dart2WasmTarget.build
  and delete stale dart2wasm.d on dry runs.
- Extract Dart2WasmTarget.supportJsFileName and exclude it from
  WebReleaseBundle.resolveInputs and non-Wasm WebTemplatedFiles.resolveInputs.
- Inline regex guards into a single switch in WebCompiledArtifact.tryParse
  and mark Dart2WebTarget.buildStemSource @VisibleForTesting.
- Strip stale manifest keys in injectManifestBuildConfig even when all
  manifest fields become empty.
@kevmoo
kevmoo requested a review from bkonyi November 17, 2026 21:19
@kevmoo kevmoo added the CICD Run CI/CD label Nov 17, 2026
@kevmoo
kevmoo requested a review from mdebbar November 17, 2026 22:06
kevmoo added a commit to kevmoo/scripts.dart that referenced this pull request Nov 23, 2026
Add `kscripts pr-triage reply` and a gated `❓ Clarify (Author |
Reviewer)` assessment bucket to `/pr-triage`. This lets triage post
non-resolving inline replies and surface genuine ambiguities on PRs like
[flutter/flutter#196563](flutter/flutter#196563)
and
[dart-lang/site-www#7615](https://github.com/dart-lang/site-www#7615).

- **Non-resolving inline replies**: `kscripts pr-triage reply [--react
<+1|-1>] <comment_id> "<reply_body>"` posts to
`pulls/<pr>/comments/<id>/replies` (with optional `+1`/`-1` reaction and
`-p <url>` support) without calling `resolveReviewThread`, and rejects
`PRRT_` thread IDs or 3-argument `resolve` syntax with prescriptive
usage hints.
- **3-precondition `❓ Clarify` gate**: Requires a `checked:` lookup
proof in `Empirical Verification`, `2+` readings with material
behavioral/API/scope divergence, and a split between PR-author
trade-offs (`❓ Clarify (Author)`) and underspecified human-reviewer
comments (`❓ Clarify (Reviewer)`, never bots), replacing Step 6's unused
adjustment placeholder with concrete fork options.
- Key LinkHooks on recordedUsesFileNames so compiler transitions rebuild link_hooks.
- Drop main.dart.mjs.map tracking, buildStemSource, and Wasm _hashAndRenameWebOutput sourceMapFile args.
- Simplify WebTemplatedFiles.resolveInputs and Environment._resolveDirectory.
@kevmoo
kevmoo requested a review from mdebbar November 23, 2026 21:56
…eNames to IconTreeShaker

- Scope `Dart2WasmTarget.removeBuildSupportJs` to `{BUILD_DIR}/main.dart.support.js` so user `web/**/main.dart.support.js` inputs stay tracked.
- Thread active `recordedUsesFileNames` through `WebReleaseBundle.inputs`, `WebReleaseBundle.buildKey`, `copyAssets`, and `IconTreeShaker`.
- Add regression tests for `web/vendor/main.dart.support.js` edits, `--no-wasm-dry-run` icon subsetting, and repeat default Wasm dry-run builds.
@kevmoo
kevmoo dismissed mdebbar’s stale review November 24, 2026 03:19

Addressed in c15bee8 (scoped supportJs filtering to buildDir, passed active recordedUsesFileNames to IconTreeShaker, and added repeat dry-run assertions); re-requesting review from mdebbar.

@kevmoo
kevmoo requested a review from mdebbar November 24, 2026 03:19

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into flutter:master with commit f8f3f6e Nov 24, 2026
21 of 22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@kevmoo
kevmoo deleted the web-build-tracking branch November 24, 2026 20:25
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions)

flutter/flutter@b75c5b3...06f1c24

2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375)
2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371)
2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369)
2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364)
2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270)
2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219)
2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714)
2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965)
2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267)
2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363)
2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748)
2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596)
2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071)
2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351)
2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310)
2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266)
2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944)
2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918)
2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815)
2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229)
2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482)
2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300)
2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302)
2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004)
2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334)
2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333)
2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095)
2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355)
2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206)
2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771)
2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245)
2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563)
2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807)
2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316)
2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945)
2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309)
2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants