Repository navigation
perf(ui): stub unused linkify-it and lift JS ceiling to 155 kB - #358
Merged
Merged
Conversation
markdown-it (via @a2ui/react) builds a LinkifyIt but never calls it with the default preset, so alias it to an empty stub: 149,694 -> 146,898 B gzip. The size gate sums every chunk, react-dom/zod/markdown-it are outside our control, so the JS ceiling moves 150 -> 155 kB with the measured breakdown recorded in docs/engineering-practices.md. Closes #350 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Closes #350
What
linkify-it→ empty stub (ui/src/stubs/linkify-it.ts, aliased inui/vite.config.ts). markdown-it, which@a2ui/react's Text renders through, constructs aLinkifyItin its constructor but only calls it whenlinkify: true;@a2ui/reactusesnew MarkdownIt()(default preset, linkify off). Behaviour-neutral. If a future@a2ui/reactturns linkify on, Text render throws and the e2e sweep catches it.check-bundle-size.mjs, per the issue's step 3. The measured reason is indocs/engineering-practices.md§ Performance.Numbers (clean
npm ci && npm run build,node scripts/check-bundle-size.mjs)main@ 9e67ba0)CSS is unchanged (5,872 / 8,000 B).
Why the ceiling moved and the bundle didn't shrink more
I measured the bundle with sourcemaps and stub builds that aren't committed:
A2UIProvidercallsensureInitialized(), which registers the whole default catalog anyway.@a2ui/web_core's v0_8 schema, so we can't drop it.entitiesdecode table. The only way to reclaim it is to replace the markdown engine. That changes what model-authored text renders, and it changes the XSS surface behinddangerouslySetInnerHTML, so it's an owner decision, not a trim. Stubbingpunycode.jswould save about 1 kB but changes IDN link handling, so I left it alone.Follow-ups for the owner (not in this PR)
@a2ui/reactv0_9entry, which takes a pluggable markdown renderer.Verification
ui:npm run lint(0 errors; the 9 warnings were already there) ·npm run typecheck·npm test(82 passed) ·npm run build·npm run sizeall pass locally.### [Title](https://…),*caption*, the relative[Open →](?usecase=…)link and HTML escaping render as before.npm audit --omit=dev --audit-level=highfails, onmaintoo. These advisories appeared after the last greenmainrun: dompurify (critical), markdown-it (high) and zod<4.6.6(high). zod has no 3.x fix (GHSA-mrhx-c7xc-m3w5: first patched 4.6.6) and@a2ui/reactpins zod ^3, so theuijob's audit step is red on every PR (dependabot chore(deps): Bump the npm-security group across 1 directory with 2 updates #349 too) until the owner decides on zod/a2ui. This PR doesn't touchpackage*.json.vite devpath (dep pre-bundling) wasn't exercised here. The alias is root-relative and should resolve there too.Changelog entry (to be collected in the lane's docs(changelog) PR)
linkify-it(−2.8 kB gzip) and raise the JS bundle ceiling to 155 kB, with the measured reason (UI bundle has 306 B headroom under the 150 kB ceiling — trim before more UI #350).Generated with Claude noreply@anthropic.com