Skip to content

chore: migrate to monosize v0.10 and add scoped bundle-size threshold - #36499

Open
Hotell wants to merge 1 commit into
microsoft:masterfrom
Hotell:feat/monosize-v0.10-migration
Open

chore: migrate to monosize v0.10 and add scoped bundle-size threshold#36499
Hotell wants to merge 1 commit into
microsoft:masterfrom
Hotell:feat/monosize-v0.10-migration

Conversation

@Hotell

@Hotell Hotell commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Previous Behavior

monosize pinned at 0.9.0. Bundle-size thresholds were global-only, so a single package couldn't get its own budget without re-budgeting all 235 fixtures. react-headless-components-preview was gated by the default 10%.

New Behavior

Bumps monosize 0.9.00.10.0 plus both adapters (monosize-bundler-webpack 0.4.00.4.1, monosize-storage-git 0.3.40.3.5). All three move together — the adapters require monosize: ^0.10.0.

Uses the 0.10 feature — per-package thresholds baked into the report at measure time — to give react-headless-components-preview a scoped 10kB budget via a new library/monosize.config.mjs. No other fixture is affected.

Why the webpack resolution

monosize-bundler-webpack@0.4.1 widened its range to webpack@^5.108.3. That descriptor wasn't in the lockfile, so yarn resolved it fresh to 5.109.2 instead of reusing the repo's pinned 5.108.4.

webpack 5.109 flips experiments.typescript from undefined to "auto", which self-enables when Node has module.stripTypeScriptTypes and no .ts loader is registered — true for the monosize config, which declares no module.rules. That sets resolve.tsconfig = true, so tsconfig paths redirect @fluentui/* into src/, where .tsx is absent from the TS-enabled extension list. Every fixture broke.

"monosize-bundler-webpack/webpack": "5.108.4" keeps the adapter on the known-good version without constraining webpack elsewhere. Verified yarn dedupe --strategy highest can't move it.

Alternative considered and rejected

Setting experiments: { typescript: false } in the root monosize.config.mjs enhancer fixes the root cause, but packages/react and global-context replace bundler wholesale rather than merging it, so the opt-out never reaches them — global-context:bundle-size still failed a full sweep.

Beachball

Adds **/monosize.config.mjs to ignorePatterns (matching the existing **/bundle-size/**) so build tooling doesn't drive releases; without it the new file flags @fluentui/react-headless-components-preview for a version bump.

Verification

  • nx run-many -t bundle-size --nxBail → 60 projects, 99 dependent tasks, all green
  • react-headless-components-preview report carries "threshold": { "size": 10240, "type": "size" }; react-spinner's has none — scoping confirmed
  • react:bundle-size and global-context:bundle-size (existing per-package configs) still pass
  • yarn why monosize → single resolution at 0.10.0, no nested webpack
  • yarn check:change → no change files needed

compare-reports needs GITHUB_TOKEN + a master base ref, so it's only verifiable on the PR comment.

Notes for reviewers

  1. The budget won't bite until the next cycle. The base report on master was written by 0.9 and carries no per-entry threshold, so compare falls back to 10% until bundle-size-base.yml re-runs on master under 0.10.
  2. 10kB is ~2.5× tighter than the default, not looser — the fixture is 251.914 kB minified, so 10% would be ~25.2 kB. For calibration, fix: Escape in an open Combobox or Dropdown does not trigger tabster actions #36275 grew this fixture by +37.043 kB (+18.7%); the new budget would have blocked it. (threshold first shipped in monosize 0.9.0 — the repo was on 0.6.3 back then, so nothing gated it.)
  3. Unit quirk: parseThreshold treats kB as 1024 bytes while the report renders 1000-based kB, so '10kB' gates at a displayed ~10.24 kB.
  4. Don't bump webpack to 5.109+ without prep. I tested it on a scratch branch: apps/public-docsite, apps/ssr-tests and apps/theming-designer all break (they extend tsconfig.base.v8.json, which carries the src path mappings). v8 package bundles survive — their tsconfigs are standalone with no paths. One line in createConfig() would cover all three. Separately, public-docsite and ssr-tests exit 0 despite 100 module build errors each and emit a truncated bundle — a pre-existing error-propagation gap in the just-scripts webpack task that's worth fixing before any webpack bump.

Related Issue(s)

  • n/a

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

📊 Bundle size report

✅ No changes found

@Hotell
Hotell force-pushed the feat/monosize-v0.10-migration branch from a51419e to 103075e Compare August 3, 2026 16:37
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Pull request demo site: URL

Comment thread package.json
Bumps monosize 0.9.0 -> 0.10.0 with its two adapters, and uses the headline
0.10 feature (per-package thresholds resolved at measure time) to give
react-headless-components-preview a scoped 10kB budget.

Pins webpack for the bundler adapter. monosize-bundler-webpack@0.4.1 widened
its range to webpack@^5.108.3, a descriptor not previously in the lockfile, so
yarn resolved it fresh to 5.109.2 instead of reusing the repo's 5.108.4.
webpack 5.109 flips experiments.typescript from undefined to "auto", which
self-enables whenever Node exposes module.stripTypeScriptTypes and no .ts rule
is registered -- true for the monosize config, which declares no module.rules.
That sets resolve.tsconfig = true, so tsconfig paths redirect @fluentui/*
imports into src/, where .tsx is absent from the TS-enabled extension list and
resolution fails. Every fixture broke.

Fixing this in the bundler enhancer instead was tried and rejected: the
global-context and react configs replace `bundler` wholesale rather than
merging it, so a root-level opt-out silently does not reach them.

Also ignores monosize.config.mjs in beachball, matching the existing
**/bundle-size/** entry, so build-tooling config does not drive releases.
@Hotell
Hotell force-pushed the feat/monosize-v0.10-migration branch from 103075e to d3aef75 Compare August 4, 2026 10:59
@Hotell
Hotell marked this pull request as ready for review August 4, 2026 11:16
@Hotell
Hotell requested a review from a team as a code owner August 4, 2026 11:16
/** @type {import('monosize').MonoSizeConfig} */
const monosizeConfig = {
...baseConfig,
threshold: '10kB',

@Hotell Hotell Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should we stay with 10kb (default) or leave default 10% ? I'd tighten this down maybe to 5% to have very low breathing room when increasing. when we introduce new control that will be admin merged only after proper review/approvals . wdyt @dmytrokirpa

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.

Anything up to ~20kb (Griffel) should be fine. I’d rather use an absolute number than a percentage, since it will grow over time

@tudorpopams
tudorpopams requested a review from mainframev August 4, 2026 12:10
@Hotell
Hotell requested a review from dmytrokirpa August 4, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants