feat(ui): bump microlighter to 2.2.0 and map its new grammars - #135
Merged
Conversation
2.2.0 makes the highlight scan linear rather than quadratic — a 64 kB TypeScript block measures 14.5 ms against 2592.8 ms on 2.1.0, 71.6x aggregate across five grammars and five sizes, with identical range counts. It also ships astro, ini and nginx. check-grammars asserts the map and the grammar directory against each other in both directions, so the bump fails build:lib until all three are reachable: astro and ini by extension, nginx by filename since no extension names it. Co-Authored-By: Claude Opus 5 (1M context) <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.
What
microlighter2.1.0 → 2.2.0, and the three grammars it adds —astro,ini,nginx— mapped so filenames reach them. Releases as 3.7.0:.astro,.iniandnginx.confblocks that rendered plain monospace now highlight.Why the bump and the map entries are one commit
check-grammars.jsasserts the map and microlighter's grammar directory against each other in both directions, and runs insidebuild:lib. So the bump alone fails the build:After:
Checked 40 mapped grammars against 40 shipped.The mapping
astroastroGRAMMAR_BY_EXTENSIONiniiniGRAMMAR_BY_EXTENSIONnginxnginx.confGRAMMAR_BY_FILENAMEnginxgoes by filename because no extension names it. I deliberately did not mapconf→nginx:.confbelongs to far more than nginx, and this map's stated policy is that an absent extension renders plain because "a wrong grammar colours worse than none".GRAMMAR_BY_FILENAMEis consulted first, songinx.confwins regardless of whatconfever maps to.Same reasoning for not adding
cfgtoini.Upstream performance, measured
2.2.0 replaces microlighter's
O(n²)scan with a monotonic per-pattern match cache. Measured here in Chromium through the real::highlight()path, synthetic samples, one block per run:71.6× aggregate across 5 grammars × 5 sizes (9305 ms → 130 ms), and range counts are identical on all 25 rows — the cache changed no output. Scaling is now linear and holds to 1 MB (typescript 14.9 ms → 202.9 ms over 16× the data).
Note on the lockfile diff
pnpm-lock.yamlshows ~5980 changed lines. It is 6 semantic changes, all microlighter — I diffed the parsed YAML to confirm:The rest is pnpm re-serialising the file. An install on untouched
mainis a byte-for-byte no-op, but any dependency change triggers a full rewrite, and both the pinned pnpm 9.12.3 and 11.24.0 produce the same churn — so whatever originally wrote that lockfile reproduces in neither. Nothing else moved.Also ignoring
pnpm-lock.yaml/package-lock.json/yarn.lockin.prettierignore.*.locknever covered them, so aprettier --write .would have reformatted the lockfile. Unrelated to the churn above, just a latent hazard worth closing.Follow-on
@eqtylab/explorerandguardian's studio both consume this map, so they pick the new grammars up on their next bump. Explorer can separately drop itshtmlhighlight exclusion and 64 kB cap — both were sized against the quadratic scan.