Skip to content

Fix stale JS bundle and E2E build blockers in Components AGENTS.md - #68800

Merged
javiercn merged 3 commits into
mainfrom
javiercn-agents-md-js-bundle-freshness
Aug 28, 2026
Merged

javiercn merged 3 commits into
mainfrom
javiercn-agents-md-js-bundle-freshness

Conversation

@javiercn

@javiercn javiercn commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Three defects in src/Components/AGENTS.md, all found by an agent actually hitting them during the investigation that shipped #68088 — not by reading the file.

1. The JS asset path was wrong

src/Components/Web.JS/rollup.config.mjs maps outputs under _framework/, so the real artifact is dist\Debug\_framework\blazor.web.js. The documented path omitted _framework and therefore never existed, which made the check useless as written.

2. Presence is not freshness

npm run build:production writes only dist/Release and has no prebuild/clean of its own, so running it alone leaves a stale dist/Debug. The .NET Debug build then silently consumes the old bundle and E2E tests behave exactly as if the .ts change were never made — no error message anywhere. In the #68088 investigation this burned a full E2E cycle chasing a fix that was never in the bundle under test.

Section 2 now compares the bundle's timestamp against the newest .ts source, in both PowerShell and bash, says to use npm run build and never build:production alone, and notes to re-check after a git stash, git checkout --, or branch switch that touches a .ts.

3. Two build blockers that stopped the documented E2E command

The documented E2E build command fails twice on a fresh worktree, and the file pointed agents straight at it for exactly that case. In #68088 this cost ~21 minutes across two consecutive failures.

Rather than documenting these as symptoms to recognize after the fact, the guidance now steers around them up front:

  • Submodules — git submodule update --init --recursive is part of first-time setup, with a note that worktrees do not inherit submodules from the checkout they were created from. (Verified: in a fresh worktree git submodule status reports MessagePack-CSharp uninitialized and the directory is empty.)
  • ANCM native assets — -p:UseIisNativeAssets=false is now baked into every documented dotnet build / dotnet run command, plus a short "Standard build flags" note and a Quick Reference entry saying to pass it unless you are working on IIS. The E2E section keeps a one-line explanation of why it is required there, and a pointer back to step 1 if the build fails on MessagePack instead.

Components.TestServer references Microsoft.AspNetCore.Server.IIS, the project that raises the ANCM error, so its dotnet run line gets the flag too.

Verification

Both freshness checks were verified on a synthetic tree, no build required: bundle absent → STALE; bundle touched after the .ts → fresh; .ts touched again → STALE; bundle removed → STALE. The literal text as it appears in the doc was re-run from a file to confirm the pasted form behaves identically.

-print -quit was deliberately avoided — -quit is a GNU find extension and is absent on macOS/BSD. The snippet uses only POSIX predicates plus head -n 1, and guards the missing-bundle case before reaching find -newer.

The MSBuild claims were checked against the repo: .gitmodules declares the MessagePack submodule path, and UseIisNativeAssets is what gates the ANCM error in Microsoft.AspNetCore.Server.IIS.csproj:43 and the ValidateNativeComponentsBuilt target in Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj:33.

Documentation-only. No tests were run and none are needed.

The documented path omitted the _framework segment, so the check never
matched a real artifact. It also only tested for presence, which misses
the common failure where
pm run build:production was run alone and
left a stale dist/Debug bundle that the .NET Debug build silently
consumes.

Replace it with a freshness comparison against the newest .ts source,
in both PowerShell and bash.

Co-authored-by: Copilot App <[email protected]>
Copilot AI lite review requested due to automatic review settings August 26, 2026 11:27
@javiercn
javiercn requested a review from a team as a code owner August 26, 2026 11:27

Copilot AI 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.

Pull request overview

Updates Components agent guidance to verify JavaScript bundle freshness (not just presence) by comparing the built bundle’s timestamp against the newest TypeScript source, helping prevent Debug builds/tests from silently using stale dist/Debug outputs.

Changes:

  • Rewrites “Check JS assets” guidance to validate that dist/Debug/_framework/blazor.web.js is newer than the newest .ts source.
  • Adds ready-to-run freshness checks for both PowerShell and bash.
  • Updates Quick Reference and explicitly warns against using npm run build:production alone (since it can leave dist/Debug stale).
Suppressed comments (1)

src/Components/AGENTS.md:170

  • Quick Reference step 2 tells readers to run npm run build when the bundle is stale, but doesn’t say where to run it. Since the step above explicitly says to run the check from the repo root (and npm run build at the root builds all workspaces), calling out the repo root here reduces ambiguity.
1. **First time only**: `.\eng\build.cmd` → create `artifacts\agent-sentinel.txt`
2. **Check JS assets are fresh**: Verify `src\Components\Web.JS\dist\Debug\_framework\blazor.web.js` is newer than the newest `.ts` source (see step 2 above for the command); run `npm run build` - never `build:production` alone - if `STALE`

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Components/AGENTS.md
Comment on lines +113 to +114
- If it reports `STALE`, run `npm run build` from `src\Components\Web.JS`, then re-run the check.
- Always use `npm run build`. **Never** use `npm run build:production` on its own: it writes only `dist\Release` and leaves `dist\Debug` stale, so the Debug build keeps using your old code.
The first E2E build in a fresh worktree fails twice: once on the
uninitialized MessagePack submodule, and once on missing ANCM native
assets. Neither was documented, so agents rediscover both the slow way.

Co-authored-by: Copilot App <[email protected]>
@javiercn javiercn changed the title Check JS bundle freshness, not presence, in Components AGENTS.md Fix stale JS bundle and undocumented E2E build blockers in Components AGENTS.md Aug 26, 2026
Initializing submodules is now part of first-time setup, and
-p:UseIisNativeAssets=false is baked into every documented dotnet build
command rather than offered as an after-the-fact remedy.

Co-authored-by: Copilot App <[email protected]>
@javiercn javiercn changed the title Fix stale JS bundle and undocumented E2E build blockers in Components AGENTS.md Fix stale JS bundle and E2E build blockers in Components AGENTS.md Aug 26, 2026

@oroztocil oroztocil left a comment

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.

Nice 👍

@javiercn
javiercn merged commit 4342bb3 into main Aug 28, 2026
14 checks passed
@javiercn
javiercn deleted the javiercn-agents-md-js-bundle-freshness branch August 28, 2026 12:33
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants