Repository navigation
Conversation
|
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.13% -0.01%
==========================================
Files 291 291
Lines 28908 28950 +42
Branches 2936 2943 +7
==========================================
+ Hits 27214 27253 +39
- 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)
There was a problem hiding this comment.
Yeah, that was clunky. It's a single visit(content) per entry now, since the heading and stability are already part of the content. The test checks those two as well.
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>
An entry's heading and stability are nodes of its content, so walking the content alone covers them, without a loop over the three of them and a check for a missing one. The test now checks the heading and the stability too. Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
b65c0b7 to
b88b1d5
Compare
|
Thanks for double checking who reads positions! Went with your nit, it's one walk over each entry's content now. |
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.