Bound the @scalar/api-reference-react bundle footprint with a budget test - #5821
Merged
Conversation
…udget test (#5677) Scalar powers one developer-facing route (Dev Tools -> API Explorer) but is the client's heaviest dependency by a wide margin: 261 of 599 installed packages are reachable only through it, and it contributes 3.24 MB of dist assets against ~13.0 MB of built JS -- including a second UI framework (Vue 3) and the Vercel AI SDK, reached as a hard dependency via @scalar/agent-chat. `agent: { disabled: true }` is a runtime toggle, so Rollup still emits the agent chat chunk. Nothing measured any of this, so a routine version bump could grow it without a signal. Keeps the dependency -- the surveyed alternatives are unmaintained (rapidoc, last published 2024-10) or comparably large -- and adds the measurement that was missing: a 4.0 MB budget over the Scalar-attributable dist assets, checked in CI right after the client build so it sees a fresh build rather than a stale dist/. The test skips itself when client/dist is absent, and a companion assertion fails if no ScalarReference-*.js chunk is found, so a Vite chunk-naming change cannot turn the budget into a 0-byte pass. Reclassifies the DEPS.md row from Tier 1 to Tier 2 with the measured numbers and a re-audit trigger.
…k splits (#5677) Local review flagged two ways the budget could go quiet instead of failing: resolving dist/assets from cwd alone skipped the whole suite when a runner is pointed at the client project from the repo root, and matching Vue chunks only after a dot would miss a vendor chunk if Rollup ever splits the Vue runtime or radix-vue out on its own. Try both dist paths, and match vue- at a name boundary.
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.
Summary
@scalar/api-reference-reactpowers one developer-facing route (Dev Tools → API Explorer) but is the client's heaviest dependency by a wide margin: 261 of 599 installed packages are reachable only through it, and it contributes 3.24 MB of dist assets against ~13.0 MB of built JS — including a second UI framework (Vue 3 + radix-vue + @headlessui/vue) and the Vercel AI SDK, reached as a hard dependency via@scalar/agent-chat. Nothing measured any of it, so a routine version bump could grow it with no signal.rapidoc, last published 2024-10) or comparably large — and adds the measurement that was missing.client/src/pages/ApiExplorer.bundle.test.js: a 4.0 MB budget (~23% headroom over the measured 3.24 MB) over the Scalar-attributableclient/dist/assetsfiles. It skips itself whenclient/distis absent, so the plain unit-test job stays green; CI runs it as its own step right afternpm run build --prefix client, so it sees a fresh build rather than a staledist/.ScalarReference-*.jschunk is found, so a Vite chunk-naming change cannot turn the budget into a 0-byte pass.ScalarReference.jsxgains a header note recording the footprint and the fact thatagent: { disabled: true }is a runtime toggle — Rollup cannot tree-shake on it, so the agent chat chunk is emitted regardless.docs/DEPS.md: reclassified Tier 1 → Tier 2 with a Detailed Findings entry (measured numbers, why it is kept, what guards it, re-audit trigger).Out of scope per the issue: no removal or replacement of the dependency, no
manualChunkschanges, no behaviour change to the API Explorer page.Test plan
cd client && npm test -- src/pages/ApiExplorer.bundle.test.js— 2 passed against a freshnpm run build --prefix client.3394263Bover3145728B).client/distrenamed away → suite skips (2 skipped), so the unit-test job stays green.client/and with the runner invoked from the repo root.cd client && npm run lint— clean (2428 files).cd server && npm test -- ../scripts/ci-fail-fast.test.js ../scripts/ci-base-sha.test.js ../scripts/ci-test-plan.test.js ../scripts/run-ci-lint.test.js ../scripts/pre-install-entrypoints.test.js— 63 passed; the cancellation step stays the final step of the client job.Closes #5677