Skip to content

feat(ui): bump microlighter to 2.2.0 and map its new grammars - #135

Merged
tmccoy14 merged 1 commit into
mainfrom
chore/microlighter-2.2.0
Sep 11, 2026
Merged

feat(ui): bump microlighter to 2.2.0 and map its new grammars#135
tmccoy14 merged 1 commit into
mainfrom
chore/microlighter-2.2.0

Conversation

@tmccoy14

Copy link
Copy Markdown
Contributor

What

microlighter 2.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, .ini and nginx.conf blocks that rendered plain monospace now highlight.

Why the bump and the map entries are one commit

check-grammars.js asserts the map and microlighter's grammar directory against each other in both directions, and runs inside build:lib. So the bump alone fails the build:

syntax-language map is out of step with the bundled highlighter:
- The highlighter ships 3 grammar(s) no filename reaches: astro, ini, nginx.

After: Checked 40 mapped grammars against 40 shipped.

The mapping

grammar key map
astro astro GRAMMAR_BY_EXTENSION
ini ini GRAMMAR_BY_EXTENSION
nginx nginx.conf GRAMMAR_BY_FILENAME

nginx goes by filename because no extension names it. I deliberately did not map confnginx: .conf belongs 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_FILENAME is consulted first, so nginx.conf wins regardless of what conf ever maps to.

Same reasoning for not adding cfg to ini.

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:

grammar @64 kB 2.1.0 2.2.0 speedup
typescript 2592.8 ms 14.5 ms 179×
sql 1836.8 ms 8.7 ms 211×
css 1390.9 ms 14.0 ms 99×
html 1051.4 ms 20.2 ms 52×
json 39.0 ms 6.4 ms 6.1×

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.yaml shows ~5980 changed lines. It is 6 semantic changes, all microlighter — I diffed the parsed YAML to confirm:

/importers/packages/ui/dependencies/microlighter/specifier: '^2.1.0' -> '^2.2.0'
/importers/packages/ui/dependencies/microlighter/version:   '2.1.0' -> '2.2.0'
/packages/microlighter@2.1.0:  REMOVED      /packages/microlighter@2.2.0:  ADDED
/snapshots/microlighter@2.1.0: REMOVED      /snapshots/microlighter@2.2.0: ADDED

The rest is pnpm re-serialising the file. An install on untouched main is 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.lock in .prettierignore. *.lock never covered them, so a prettier --write . would have reformatted the lockfile. Unrelated to the churn above, just a latent hazard worth closing.

Follow-on

@eqtylab/explorer and guardian's studio both consume this map, so they pick the new grammars up on their next bump. Explorer can separately drop its html highlight exclusion and 64 kB cap — both were sized against the quadratic scan.

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>
@tmccoy14 tmccoy14 self-assigned this Sep 11, 2026
@tmccoy14
tmccoy14 merged commit c53e5ed into main Sep 11, 2026
1 check passed
@tmccoy14
tmccoy14 deleted the chore/microlighter-2.2.0 branch September 11, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant