Repository navigation
Conversation
Nothing after `metadata` reads where a node came from in the source: the type warnings that print positions run while it parses. Dropping them shrinks every entry the main thread holds and copies to and from the workers. On Node.js's docs that is ~480k position objects, about 80MB, and builds are ~5% faster. `json-simple`, which writes the metadata as it is, no longer has them either, and is about a third of its size. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com> Assisted-by: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1236 +/- ##
==========================================
- Coverage 94.14% 94.14% -0.01%
==========================================
Files 291 291
Lines 28950 28993 +43
Branches 2944 2953 +9
==========================================
+ Hits 27256 27296 +40
- Misses 1672 1675 +3
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
kgeminicdev
left a comment
There was a problem hiding this comment.
Checked the "nothing after metadata reads it" claim: the only reader is the invalid-type warning in resolveTypes.mjs, which parseApiDoc runs before this loop, and callIfBefore in utils/unist.mjs is only called from tests. So nothing downstream loses anything.
Nit: heading and stability are both inside content already. The subtree slice starts at the heading's index, and the stability blockquote is found in that same subtree and mutated in place, never removed. So visit(content, …) alone covers all three and skips two extra walks per entry.
| // Nothing after this reads where a node came from: letting it go saves | ||
| // memory, and copying it to and from the worker threads | ||
| for (const { content, heading, stability } of metadataCollection) { | ||
| for (const root of [content, heading, stability]) { | ||
| if (root) { | ||
| visit(root, node => { | ||
| delete node.position; | ||
| }); | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
is there a more intuitive way to do this (a double for loop w/ an if seems annoying, iMO)
Description
This PR drops
positionfrom every node ofmetadata's entries once they're parsed. Nothing aftermetadatareads where a node came from in the source: the type warnings that print positions run while it parses. On Node.js's docs that's ~480k objects, about 80MB, that the main thread no longer holds or copies to and from the workers, and builds are ~5% faster.json-simplewrites the metadata as it is, so it no longer has them either, and is about a third of its size.Validation
Added
drops where each node of an entry came from, which checks that no node of a parsed entry has aposition.json-simpleis the only target whose output changes, and the<api>.jsonfilesjsonandlegacy-jsonboth write already race onmain.Related Issues
Split out of #1205.
Check List
node --run testand all tests passed.node --run format:check&node --run lint.