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 #729 +/- ##
==========================================
+ Coverage 76.37% 76.42% +0.04%
==========================================
Files 155 155
Lines 13766 13734 -32
Branches 1093 1095 +2
==========================================
- Hits 10514 10496 -18
+ Misses 3247 3233 -14
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
Pull request overview
This PR refactors how remark/unified processors are accessed by turning the getRemark* exports into memoized lazy factories and updating downstream code to call them directly instead of threading processor instances through multiple function layers.
Changes:
- Convert
getRemark,getRemarkRehype,getRemarkRehypeWithShiki, andgetRemarkRecmaintolazy()-memoized factories. - Update generators/utilities to call
remark()(aliasedgetRemark*) at point-of-use rather than passing processors through function parameters. - Update JSX AST utility tests to mock the remark module via
node:testmodule mocking.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/utils/remark.mjs | Wrap remark processor constructors in lazy() for memoized access. |
| src/generators/metadata/utils/visitors.mjs | Stop lazily wrapping getRemark; call memoized getRemark directly. |
| src/generators/metadata/utils/parse.mjs | Replace per-module processor instance with remark().runSync(...) calls. |
| src/generators/legacy-json/utils/buildSection.mjs | Remove stored processor instance; call remark() when rendering HTML. |
| src/generators/legacy-html/utils/buildContent.mjs | Remove threaded processor param; use imported remark() inside helpers. |
| src/generators/legacy-html/generate.mjs | Remove eager processor instance; use remark() for ToC generation and drop param passing. |
| src/generators/legacy-html-all/generate.mjs | Remove eager processor instance; use remark() for navigation generation. |
| src/generators/jsx-ast/utils/types.mjs | Stop requiring a processor param; import and use getRemarkRecma factory. |
| src/generators/jsx-ast/utils/signature.mjs | Stop passing remark into signature table creation. |
| src/generators/jsx-ast/utils/buildContent.mjs | Stop threading remark through content pipeline; use imported remark() factory. |
| src/generators/jsx-ast/utils/tests/types.test.mjs | Switch tests to module-mock remark.mjs instead of passing a fake processor. |
| src/generators/jsx-ast/utils/tests/buildContent.test.mjs | Update calls to new transformHeadingNode signature (no remark arg). |
| src/generators/ast/generate.mjs | Use remark().parse(...) instead of a pre-created processor instance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
What are the benefits here? |
|
There's a few benefits:
|
Next time, could you write that on the PR description? Makes it easier for me as a reviewer to understand the trade-offs and motivation behind the change 🙇 |
AugustinMauroy
left a comment
There was a problem hiding this comment.
LGMT ! did you have/know if there are perf impact (I guess it's a win)
Changes the loading of remark to be a lazy-loaded function, rather than passed down the chain of function to function
There's a few benefits:
In some generators, we loading remark on both the parent and child thread, when it's only used on the child thread.
In cases where multiple generators are using the same remark, currently, that remark will be re-loaded for each generator
It makes our function signatures smaller, and therefore more readable