Upgrade web-vitals to 6.2.3
What does this MR do and why?
Upgrades web-vitals from 0.2.4 (July 2020) to 6.2.3. Its only user is the performance bar's console log in app/assets/javascripts/performance_bar/performance_bar_log.js.
- INP replaces FID. FID is no longer a Core Web Vital, and v5 removed
onFID. CLS now uses the session-window definition that Chrome and CrUX use, so its values are lower than before on long-lived pages. - webpack 4 needs Babel for it. v6 ships untranspiled class fields,
?.and??. GDK's webpack mode still uses webpack 4, and without a rule theperformance_barbundle fails withModule parse failed: Unexpected token (1:168)and the bar doesn't render.web-vitalsjoins the existing@github/arianotify-polyfillrule. Production builds (yarn build) use Rspack, which has its own loader rules and doesn't use this one. Vite and Jest need no change. - Metrics log live.
reportAllChangeslogs each metric whenever it changes, so values show up without switching tabs. CLS is the exception: it changes on every layout shift, so it still logs once when the tab is hidden. FCP and TTFB are logged too, since the library already provides them. yarn.lockchanges only theweb-vitalsentry. Danger's duplicate-dependency warning lists duplicates that are already on master. Don't run the dedupe it suggests: it removes thebrowserslist4.28.5 pin from c086cc49, and Rspack then fails withunknown version '157' of browser 'chrome'.
Why each part is needed
- 0.2.4 → 6.2.3 breaking changes that touch this file:
getXXX()renamed toonXXX()(v3, old names removed in v4),onFID()removed (v5). The metric object lostisFinal(v1) and gainedratingandnavigationType. The log prints the whole object, so nothing reads those fields. - webpack resolves the package's
modulefield todist/web-vitals.js. Parsing it with webpack 4's acorn 6.4.2 atecmaVersion: 11fails at 1:168 (the??in(o??0)). After the project'sbabel.config.jsit parses with no?.or??left. I confirmed the failure and the fix with GDK switched to webpack. - The merged rule still matches
node_modules/@github/arianotify-polyfill/arianotify-polyfill.js, with the same loader and options. I checked the polyfill still installs and announces into its live regions after removing Chrome's nativeariaNotify. - Jest resolves the package's
requireexport,dist/web-vitals.umd.cjs, which Node runs natively.yjs,zod,markedandgraphql-wsalready load as.cjsthe same way. - The bundle grows by about 2 KB gzipped, only in the
performance_barentry, which loads only when the performance bar is on. - No changelog trailer: this only changes the performance bar's console output.
References
- web-vitals changelog
- Upgrade guides: v4, v5, v6
- Frontend performance guide: Core Web Vitals
Screenshots or screen recordings
| Before | After |
|---|---|
| Not captured. 0.2.4 logged only CLS, FID and LCP. FID and LCP waited for the first input, and CLS waited for a tab switch. | ![]() |
The console panel in the screenshot is the page's console.log output from one load in GDK, rendered on the page so it fits in one image. FCP, LCP and TTFB logged on load, and INP after one key press. CLS logged after a tab hide, which I had to simulate with a visibilitychange event because the test browser can't hide a tab.
How to set up and validate locally
-
On any page in GDK, press p then b to turn on the performance bar.
-
Open the browser console and reload. FCP, LCP and TTFB log on load. Press a key or click to log INP, then switch to another tab and back to log CLS.
-
To check webpack 4, switch GDK from Vite to webpack, disabling Vite first, then repeat step 2:
gdk config set vite.enabled false gdk config set webpack.enabled true gdk reconfigure gdk restartTo switch back, run
gdk config set webpack.enabled false, thengdk config set vite.enabled true,gdk reconfigureandgdk restart. -
Optional: to check
@github/arianotify-polyfill, open a page in a browser without nativeariaNotify(for example Firefox), rundocument.body.ariaNotify('hello')in the console, and check that apolite-live-region-…element appears at the end of<body>.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
