Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1235 +/- ##
==========================================
+ Coverage 94.13% 94.19% +0.05%
==========================================
Files 291 292 +1
Lines 28900 29027 +127
Branches 2932 2950 +18
==========================================
+ Hits 27206 27341 +135
+ Misses 1672 1664 -8
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
|
| File | Main | PR | Change |
|---|---|---|---|
addons.html |
374.23 KB | 328.87 KB | -45.36 KB (-12.1%) |
embedding.html |
64.38 KB | 57.78 KB | -6.60 KB (-10.3%) |
async_context.html |
247.17 KB | 245.10 KB | -2.08 KB (-0.8%) |
tls.html |
297.33 KB | 298.88 KB | +1.54 KB (+0.5%) |
n-api.html |
822.59 KB | 822.23 KB | -364.00 B (-0.0%) |
module.html |
364.63 KB | 364.84 KB | +224.00 B (+0.1%) |
readline.html |
219.10 KB | 219.27 KB | +168.00 B (+0.1%) |
worker_threads.html |
417.80 KB | 417.64 KB | -168.00 B (-0.0%) |
repl.html |
226.64 KB | 226.75 KB | +112.00 B (+0.0%) |
test.html |
1009.73 KB | 1009.67 KB | -56.00 B (-0.0%) |
Performance estimate (single CI run)
- Generation time: 28.0% slower (11.52 s → 14.75 s)
- Peak memory: 7.8% lower (1.43 GB → 1.32 GB)
legacy-json Generator
Performance estimate (single CI run)
- Generation time: 40.6% faster (8.23 s → 4.89 s)
- Peak memory: 6.3% lower (1015.46 MB → 951.34 MB)
llms-txt Generator
Performance estimate (single CI run)
- Generation time: 38.5% slower (6.10 s → 8.45 s)
- Peak memory: 2.8% lower (866.38 MB → 842.02 MB)
orama-db Generator
Performance estimate (single CI run)
- Generation time: 1.2% faster (8.52 s → 8.42 s)
- Peak memory: 3.1% higher (945.88 MB → 975.28 MB)
web Generator
Output size: 46 files changed · net -108.36 KB
File size details
| File | Main | PR | Change |
|---|---|---|---|
all.html |
34.83 MB | 34.78 MB | -54.18 KB (-0.2%) |
addons.html |
389.73 KB | 361.93 KB | -27.80 KB (-7.1%) |
embedding.html |
73.02 KB | 68.39 KB | -4.63 KB (-6.3%) |
process.html |
1.20 MB | 1.19 MB | -4.16 KB (-0.3%) |
child_process.html |
706.46 KB | 704.22 KB | -2.24 KB (-0.3%) |
tls.html |
550.17 KB | 552.35 KB | +2.18 KB (+0.4%) |
fs.html |
2.36 MB | 2.35 MB | -1.32 KB (-0.1%) |
crypto.html |
2.07 MB | 2.06 MB | -1.21 KB (-0.1%) |
assert.html |
673.00 KB | 671.89 KB | -1.11 KB (-0.2%) |
http.html |
1.23 MB | 1.23 MB | -1.06 KB (-0.1%) |
util.html |
1.26 MB | 1.26 MB | -964.00 B (-0.1%) |
async_hooks.html |
293.14 KB | 292.26 KB | -898.00 B (-0.3%) |
http2.html |
1.31 MB | 1.31 MB | -788.00 B (-0.1%) |
readline.html |
380.82 KB | 380.05 KB | -788.00 B (-0.2%) |
buffer.html |
1.82 MB | 1.82 MB | -736.00 B (-0.0%) |
dgram.html |
313.49 KB | 312.78 KB | -728.00 B (-0.2%) |
vm.html |
656.77 KB | 656.11 KB | -680.00 B (-0.1%) |
webstreams.html |
565.43 KB | 564.77 KB | -674.00 B (-0.1%) |
perf_hooks.html |
910.85 KB | 910.24 KB | -620.00 B (-0.1%) |
cluster.html |
317.74 KB | 317.14 KB | -616.00 B (-0.2%) |
worker_threads.html |
662.16 KB | 661.58 KB | -588.00 B (-0.1%) |
ffi.html |
216.87 KB | 216.38 KB | -504.00 B (-0.2%) |
zlib.html |
1.00 MB | 1023.86 KB | -504.00 B (-0.0%) |
test.html |
1.47 MB | 1.47 MB | -458.00 B (-0.0%) |
globals.html |
302.35 KB | 301.96 KB | -394.00 B (-0.1%) |
vfs.html |
213.60 KB | 213.27 KB | -340.00 B (-0.2%) |
url.html |
533.89 KB | 533.56 KB | -338.00 B (-0.1%) |
stream_iter.html |
795.19 KB | 794.90 KB | -296.00 B (-0.0%) |
v8.html |
574.47 KB | 574.19 KB | -294.00 B (-0.0%) |
async_context.html |
329.94 KB | 329.71 KB | -234.00 B (-0.1%) |
n-api.html |
1.05 MB | 1.05 MB | -230.00 B (-0.0%) |
dns.html |
442.03 KB | 441.81 KB | -224.00 B (-0.0%) |
sqlite.html |
542.98 KB | 542.81 KB | -174.00 B (-0.0%) |
domain.html |
131.23 KB | 131.06 KB | -168.00 B (-0.1%) |
quic.html |
986.03 KB | 985.87 KB | -168.00 B (-0.0%) |
stream.html |
1.27 MB | 1.27 MB | -122.00 B (-0.0%) |
repl.html |
314.01 KB | 313.90 KB | -116.00 B (-0.0%) |
modules.html |
238.01 KB | 237.90 KB | -112.00 B (-0.0%) |
tty.html |
113.74 KB | 113.63 KB | -112.00 B (-0.1%) |
module.html |
533.09 KB | 533.01 KB | -84.00 B (-0.0%) |
bench.html |
213.40 KB | 213.34 KB | -60.00 B (-0.0%) |
cli.html |
679.37 KB | 679.31 KB | -56.00 B (-0.0%) |
permissions.html |
95.17 KB | 95.12 KB | -56.00 B (-0.1%) |
esm.html |
196.06 KB | 196.05 KB | -8.00 B (-0.0%) |
single-executable-applications.html |
170.83 KB | 170.83 KB | -2.00 B (-0.0%) |
wasi.html |
83.98 KB | 83.98 KB | -2.00 B (-0.0%) |
Performance estimate (single CI run)
- Generation time: 1.2% faster (14.70 s → 14.52 s)
- Peak memory: 17.1% lower (1.52 GB → 1.26 GB)
|
|
||
| assert.ok(!loaded().includes('python')); | ||
| assert.ok(!loaded().includes('javascript')); | ||
| assert.ok(!loaded().includes('rust')); |
There was a problem hiding this comment.
why is rust here? do we have this in the codebase? its not in the release note or PR
There was a problem hiding this comment.
It's just a stand-in tbh. The test checks that a bundled language gets registered the first time it's highlighted, through one of its own aliases. It used mjs before, but that goes to TypeScript now, so I picked something nothing aliases (rs). Added a comment so the next person doesn't wonder too :)
kgeminicdev
left a comment
There was a problem hiding this comment.
The alias lookup lowercases the language (aliases.has(language.toLowerCase())), but the map is built from the config as written (new Map(Object.entries(langAlias))). So a key with capitals, like { JSONC: 'json' }, never matches, which doesn't fit "match in any case". The tests and docs only use lowercase keys, so nothing catches it. Lowercasing the keys when building the map would close it:
const aliases = new Map(
Object.entries(langAlias).map(([from, to]) => [from.toLowerCase(), to])
);| ['javascript', 'typescript'], | ||
| ['js', 'typescript'], | ||
| ['mjs', 'typescript'], | ||
| ['cjs', 'typescript'], |
There was a problem hiding this comment.
Why are these being aliased, what's wrong with the JS type?
There was a problem hiding this comment.
Nothing wrong with it, it's just heavy. JavaScript's grammar is ~60MB on every thread, and TypeScript's highlights JS just fine (we already use it for types and signatures). Together with C++ going to C, that's ~190MB less peak memory on the Node.js docs and a 2-7% faster build. In the light theme JS looks the same, except for one console output block tagged as js. Nord does lose a couple of JS-only colors tho. And anyone who wants JS's own grammar back can still map it with langAlias.
2b215f2 to
ad1a970
Compare
|
Good catch on the alias casing! The keys are lowercased now, with a test for |
| let language = languageId; | ||
|
|
||
| // Each configured alias once, so circular ones end | ||
| while (aliases.has(language.toLowerCase()) && !followed.has(language)) { |
There was a problem hiding this comment.
Does this while loop have a chance of infinite recursion? e.g. if an alias -> another alias -> back to itself?
There was a problem hiding this comment.
Nope, it can't. Each alias is only followed once, so a cycle stops at the first repeat (loop → pool → loop ends up as text in the tests). It did take a second look tho, since the set of followed aliases kept the names as written while the lookup lowercased them. Both use the lowercased name now, and there's a test for a cycle that only differs in case.
269a455 to
891436d
Compare
Each grammar costs every thread its own memory, about 60MB for JavaScript's on Oniguruma, and time to register. Types and signatures are already highlighted as TypeScript, whose grammar highlights JavaScript too, so `js`, `mjs`, `cjs` and `javascript` code is now highlighted with it by default, and C++ (`cpp`, `c++`) with C's. On Node.js's docs that saves ~190MB of peak memory and 2-7% of build time. In the light theme, the default, JavaScript comes out the same but for one block of console output marked as `js`. Nord, the dark theme, has a few colors only for JavaScript's scopes. C++-only keywords lose their color. `langAlias` takes precedence, and doc-kit now resolves aliases itself: Shiki replaced configured aliases with a grammar's own as it registered. Aliases now also lead on through other aliases and are found in any case. Transformers, and the language `resolveLanguage` returns, are the one code is highlighted as. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Claude Sonnet 5.5 <noreply@anthropic.com>
The lookup lowercased the language, but the aliases kept their keys as
written, so `{ MyConf: 'ini' }` never matched. They're keyed in
lowercase now. The test also says why Rust stands in for a bundled
language registered through its own alias.
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Following aliases always ended, since each one is followed once, but the set of those followed kept the names as written while the lookup lowercased them, so it took a second look to see. Both use the lowercased name now, and the test adds a cycle that differs only in case. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
891436d to
15a06e7
Compare
Description
This PR highlights code with fewer grammars by default, as each one takes its own memory on every thread, and time to register. JavaScript (
js,mjs,cjs,javascript) now uses TypeScript's grammar, which already highlights types, and C++ (cpp,c++) uses C's. JavaScript's grammar alone is ~60MB on every thread: on Node.js's docs this saves ~190MB of peak memory and 2-7% of build time.In the light theme JavaScript comes out the same, except one block of console output marked as
js. Nord, the dark theme, loses a few colors it only gives JavaScript's scopes, and C++-only keywords lose theirs.langAliastakes precedence, so{ cpp: 'cpp', 'c++': 'cpp' }brings C++'s own grammar back.doc-kit now resolves aliases itself, since Shiki replaced configured ones with a grammar's own as it registered. Aliases also follow other aliases and match in any case.
resolveLanguage, and transformers, get the language code is highlighted as (typescriptformjs).Validation
Added
highlights JavaScript as TypeScript, and C++ as C,takes aliases over the default ones,follows configured aliases, and finds languages named in any caseandhighlights with a language oflangsan alias leads to.node --run test,lintandformat:checkare clean.The memory and time are medians on Node.js's docs on Node.js 24.
Related Issues
Split out of #1205.
Check List
node --run testand all tests passed.node --run format:check&node --run lint.