chore(bundle-size-tools): drop unused/flawed legacy behaviors#27242
Merged
ChumpChief merged 4 commits intomicrosoft:mainfrom May 6, 2026
Merged
chore(bundle-size-tools): drop unused/flawed legacy behaviors#27242ChumpChief merged 4 commits intomicrosoft:mainfrom
ChumpChief merged 4 commits intomicrosoft:mainfrom
Conversation
The producer-side regression-detection check (any non-total metric growing by more than 5KB triggers a `sizeRegressionDetected: boolean` field on the result) was a hardcoded threshold baked into the producer. Per the broader design direction, the producer should be unopinionated about thresholds and emit raw size data; the consumer (the future GH Actions workflow that posts PR comments / manages labels) decides what counts as a regression. Removes: - detectSizeRegression function - sizeRegressionThresholdBytes constant - sizeRegressionDetected field from BundleSizeDiffResult's "changes" variant - BundleMetric type import (only used by the removed function) The result.json schema's "changes" variant now contains only `comparison`; the "no-changes" variant is unchanged. No consumer reads result.json yet (the GH workflow that will is a future PR), so this is a no-op at the seam and lets that future consumer set its own threshold. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two pre-existing behaviors getting cut, both noted as flawed by PR 2's design: 1. **tagWaiting:** when the baseline build was incomplete at PR-build time, the comparator would tag the PR's own build with a marker so a downstream process could re-run the comparison once the baseline finished. The downstream half (consuming the tag, retriggering the PR build) was never written. The tagging was effectively no-op overhead. PR 3's GH-Actions workflow approach (re-run flub generate bundleSizeDiff on a schedule) replaces this need entirely. 2. **naive fallback:** when no CI build was found for the baseline commit (or the build had no usable artifact), the comparator walked prior commits via `getPriorCommit` looking for one with a usable build. The resulting comparison was incorrect-by-design — main-side deltas between merge-base and merge-base − N were attributed to the PR. Removing both lets ADOSizeComparator's getSizeComparison flatten from a while-loop with continue/fallback branches into a linear sequence of early-return validations. The error messages also become more specific — "No CI build found for baseline commit X" / "Baseline build did not publish bundle artifacts" rather than the generic "Could not find a usable baseline build". Removed: - bundle-size-tools/src/ADO/getBuildTagForCommit.ts (whole file) - ADOSizeComparator.tagBuildAsWaiting private method - ADOSizeComparator.naiveFallbackCommitGenerator static method - ADOSizeComparator constructor params: adoBuildId, getFallbackCommit - getSizeComparison's `tagWaiting` parameter - IADOConstants fields: prBuildDefinitionId, projectRepoGuid (only used by the now-gone tagWaiting / comments machinery) - utilities/gitCommands.ts's getPriorCommit (only used by the fallback) - All corresponding barrel exports Updated: - build-cli's bundleSizeDiff.ts: simplified the ADOSizeComparator constructor call (drops the trailing `undefined` and naiveFallbackCommitGenerator args) and the getSizeComparison call (no `false` arg). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Webpack 5 supports `resolve.fallback: { assert: false }` natively, which
blocks the Node-core `assert` polyfill from being bundled. This is the
same effect the custom BannedModulesPlugin provided, so drop the plugin
and its supporting code from bundle-size-tools.
Also drops `webpack` from bundle-size-tools' dependencies (it was only
used by the plugin) and `@fluidframework/bundle-size-tools` from
bundle-size-tests' devDependencies (only used here for the plugin).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (398 lines, 15 files), I've queued these reviewers:
How this works
|
Contributor
🔭 PR Review Fleet ReportNote This report is generated by an experimental AI review fleet and is provided as a beta feature. Findings are a starting point for discussion, not a gate. Use your own judgement. Verdict: ❌ Request Changes 4 Spicy, 3 Pungent, 0 Smelly Findings
|
…ehavior-cleanup # Conflicts: # build-tools/packages/bundle-size-tools/src/ADO/AdoSizeComparator.ts # build-tools/packages/bundle-size-tools/src/ADO/Constants.ts
TommyBrosman
reviewed
May 6, 2026
TommyBrosman
reviewed
May 6, 2026
TommyBrosman
approved these changes
May 6, 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.
Description
Follow-up to #27224 (analyzer.json swap) and #27239 (dead-code cleanup). Part of AB#56981 (re-enable PR bundle size comparison).
Three pre-existing behaviors are removed because they don't fit the
bundleSizeDiffdesign that #27158 began (a producer that emits a structured artifact, consumed by a future GitHub Actions workflow). Each is independent; commits are split for review.1.
sizeRegressionDetectedfield onbundleSizeDiffoutput (commit 1)Background.
flub generate bundleSizeDiffruns a producer-side regression check: any non-total metric growing by more than a hardcoded 5KB threshold sets asizeRegressionDetected: booleanfield onresult.json's"changes"variant.Why remove. That threshold is a policy decision, not raw data. The broader design has the producer emit unopinionated per-bundle deltas and the consumer (the future GH Actions workflow that will post PR comments / manage labels) apply its own threshold. Producer-side hardcoding pre-commits us to one definition of "regression" that the consumer can't override.
Removed.
detectSizeRegressionfunctionsizeRegressionThresholdBytesconstantsizeRegressionDetectedfield fromBundleSizeDiffResult's"changes"variantBundleMetrictype import (only used by the removed function)Compatibility. No consumer reads
result.jsonyet — the GH workflow that will is a future PR — so this is a no-op at the seam and lets that future consumer pick its own threshold.2.
tagWaitingmechanism inADOSizeComparator(commit 2)Background. When the comparator runs against a baseline commit whose CI build hasn't completed yet, it tags the PR's own build with a marker (via
tagBuildAsWaiting) so that a downstream process could re-run the comparison once the baseline finished.Why remove. The downstream half (consuming the tag and retriggering the PR build) was never written, so the tagging is effectively no-op overhead today. The new
bundleSizeDiffdesign — and PR 3's planned scheduled re-run — replaces this need entirely with workflow-side polling.Removed.
bundle-size-tools/src/ADO/getBuildTagForCommit.ts(whole file)ADOSizeComparator.tagBuildAsWaitingprivate methodADOSizeComparatorconstructor paramadoBuildIdgetSizeComparison'stagWaitingparameterIADOConstantsfieldsprBuildDefinitionIdandprojectRepoGuid(only used by tagWaiting and the now-gone PR-comments machinery)3. Naive fallback in
ADOSizeComparator(commit 2)Background. When no CI build is found for the baseline commit (or the build has no usable artifact), the comparator walks prior commits via
getPriorCommitlooking for one with a usable build, and compares the PR against that.Why remove. The resulting comparison is incorrect-by-design: the PR is being compared against a commit on
mainthat's N commits older than the merge-base, so main-side deltas between merge-base and merge-base−N get falsely attributed to the PR.Removed.
ADOSizeComparator.naiveFallbackCommitGeneratorstatic methodADOSizeComparatorconstructor paramgetFallbackCommitutilities/gitCommands.ts'sgetPriorCommit(only used by the fallback)Cleanup side-effect. With both
tagWaitingand the fallback gone,getSizeComparisonflattens from a while-loop with continue/fallback branches into a linear sequence of early-return validations, and error messages become more specific —"No CI build found for baseline commit X"/"Baseline build did not publish bundle artifacts"instead of the generic"Could not find a usable baseline build".4.
BannedModulesPlugin(commit 3)Background. A custom Webpack plugin shipped by
bundle-size-toolsand used bybundle-size-teststo fail the build if any chunk imports a banned module. The only banned module configured today is Node-coreassert, whose polyfill is large in browser builds.Why remove. Webpack 5 supports the same effect natively via
resolve.fallback: { assert: false }, which blocks the polyfill from being bundled at all. The plugin existed because earlier Webpack versions didn't have this option. The native config is a few lines; the plugin is a ~70-line file plus the burden of being a public API export ofbundle-size-tools.Removed.
bundle-size-tools/src/bannedModulesPlugin/bannedModulesPlugin.ts(whole file)BannedModule,BannedModulesPlugin,BannedModulesPluginOptionsexportsDependency drops (consequences of the swap):
webpackremoved frombundle-size-tools/package.json(was only used by the plugin)@fluidframework/bundle-size-toolsremoved frombundle-size-tests/package.jsondevDependencies (was only used here for the plugin)Reviewer Guidance
The review process is outlined on this wiki page.
Three independent removals, each in its own commit — easy to review commit-by-commit.