feat(syntax-language): own the extension-to-grammar map - #133
Merged
Conversation
CodeBlock highlights through microlighter, so which grammar handles which file is a fact about this package's own dependency. Guardian Studio and Explorer each kept a byte-identical copy of that map, and each declared microlighter as a devDependency purely to test it — reaching past equality to inspect its transitive dependency, with independently pinned ranges that could resolve to a version equality does not ship. Owning the map here lets both drop that devDependency. Exposed at '@eqtylab/equality/syntax-language' rather than from the root barrel: it is data, not a component, and reaching it through the barrel pulls every CSS module into a plain Node consumer, which breaks a test runner outside a browser environment. The subpath bundle has no imports. Only grammars the current release ships are named, so the map describes what a file will actually look like rather than what it might look like after some future upgrade. check-grammars.js enforces that exactly, in both directions: no mapped grammar the highlighter does not ship, and no shipped grammar no filename reaches. It runs inside build:lib, so a drifting map fails the build and the release rather than shipping code blocks that render plain. The map stays hand-written because nothing upstream can generate it: the grammar modules carry no file-type metadata and the highlighter's own alias list covers fence tags rather than filenames. When upstream adds a grammar, the unreachable check names it and the extension is added then. Additive, so nothing that imports from the root barrel changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
tmccoy14
force-pushed
the
feat/syntax-language-map
branch
from
September 11, 2026 13:30
3908ca7 to
f9c2a17
Compare
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.
CodeBlockhighlights through microlighter, so which grammar handles which file is a fact about this package's own dependency. Guardian Studio and Explorer each kept a byte-identical copy of that map, and each declaredmicrolighteras a devDependency purely to test it — reaching past equality to inspect its transitive dependency, with independently pinned ranges that could resolve to a version equality does not ship. Copilot flagged that as critical on eqtylab/explorer#62.Owning the map here lets both consumers drop that devDependency.
Surface
New subpath,
@eqtylab/equality/syntax-language:Deliberately not re-exported from the root barrel. It is data, not a component, and reaching it through the barrel pulls every CSS module into a plain Node consumer — which fails outright in a test runner with
Unknown file extension ".css". The subpath bundle has no imports at all.This is purely additive: nothing importing from the root barrel changes.
Only what this release ships
The map names only grammars microlighter 2.1.0 actually ships, so it describes what a file will really look like. An earlier draft pre-named grammars that exist upstream but are unreleased (
astro,ini,nginx,nix,ron); that was dropped, because a.inifile rendering plain while the map saysini: 'ini'reads as a bug to anyone debugging it.Nothing is lost by waiting: the check below reports a newly shipped grammar as unreachable and names it, so the build tells you what to add — and the extension stays a deliberate choice (
.cfg → iniis a judgement call, not a given).Why a build check instead of tests
Nothing upstream can generate this map. The grammar modules carry no file-type metadata (0 of 37 declare
fileTypes), and microlighter's own alias list covers markdown fence tags rather than filenames — it has nothing forcc,hpp,h,m,ps1,patch, and nothing for extensionless names likeDockerfile. Some entries are also editorial:xml → htmlis a substitute, since the HTML grammar already describes its tag-and-attribute shape.So the data stays hand-written, and what gets automated is keeping it honest.
src/scripts/check-grammars.jsruns insidebuild:lib, which meanscode-quality.yamlgates it on every PR andpublish.yamlgates it on every release — a drifting map fails the build rather than shipping code blocks that silently render plain.Because nothing is pre-named, the invariant is now an exact correspondence in both directions:
and when it drifts:
Verification
check:grammarspasses against 2.1.0 — 37 mapped, 37 shipped, exact correspondencebuild:libsucceeds;dist/lib/syntax-language.{js,cjs,d.ts}emitted and the subpath resolves with no importsConsumers are ready and waiting on this release: they move to the subpath, delete their copies, and drop the
microlighterdevDependency. Verified locally against this build — Explorer 36 tests green across 3 builds, Studio CI green at 138 tests.🤖 Generated with Claude Code