feat(config): pass more configuration to components#737
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 #737 +/- ##
==========================================
+ Coverage 76.50% 77.17% +0.67%
==========================================
Files 155 153 -2
Lines 13779 13771 -8
Branches 1100 1114 +14
==========================================
+ Hits 10541 10628 +87
+ Misses 3233 3139 -94
+ Partials 5 4 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
| File | Base | Head | Diff |
|---|---|---|---|
orama-db.json |
8.26 MB | 8.26 MB | -1.41 KB (-0.02%) |
web Generator
| File | Base | Head | Diff |
|---|---|---|---|
string_decoder.js |
30.90 KB | 26.60 KB | -4.31 KB (-13.93%) |
documentation.js |
9.14 KB | 4.84 KB | -4.30 KB (-47.08%) |
child_process.js |
462.02 KB | 457.74 KB | -4.28 KB (-0.93%) |
querystring.js |
30.32 KB | 26.11 KB | -4.22 KB (-13.91%) |
debugger.js |
29.81 KB | 25.63 KB | -4.18 KB (-14.03%) |
synopsis.js |
15.57 KB | 11.39 KB | -4.18 KB (-26.86%) |
readline.js |
221.44 KB | 217.28 KB | -4.17 KB (-1.88%) |
globals.js |
126.88 KB | 122.72 KB | -4.16 KB (-3.28%) |
modules.js |
148.17 KB | 144.02 KB | -4.16 KB (-2.81%) |
punycode.js |
27.48 KB | 23.34 KB | -4.15 KB (-15.08%) |
cluster.js |
194.34 KB | 190.20 KB | -4.14 KB (-2.13%) |
console.js |
105.81 KB | 101.67 KB | -4.14 KB (-3.91%) |
addons.js |
292.95 KB | 288.81 KB | -4.13 KB (-1.41%) |
process.js |
702.89 KB | 698.76 KB | -4.13 KB (-0.59%) |
index.js |
9.85 KB | 5.73 KB | -4.12 KB (-41.82%) |
assert.js |
453.06 KB | 448.94 KB | -4.12 KB (-0.91%) |
buffer.js |
1.08 MB | 1.08 MB | -4.12 KB (-0.37%) |
crypto.js |
1.21 MB | 1.21 MB | -4.12 KB (-0.33%) |
stream.js |
848.22 KB | 844.10 KB | -4.12 KB (-0.49%) |
timers.js |
97.38 KB | 93.27 KB | -4.12 KB (-4.23%) |
events.js |
543.39 KB | 539.28 KB | -4.10 KB (-0.76%) |
domain.js |
89.71 KB | 85.61 KB | -4.10 KB (-4.57%) |
https.js |
159.29 KB | 155.20 KB | -4.09 KB (-2.57%) |
dgram.js |
169.72 KB | 165.64 KB | -4.08 KB (-2.41%) |
path.js |
95.96 KB | 91.88 KB | -4.07 KB (-4.24%) |
repl.js |
209.03 KB | 204.96 KB | -4.07 KB (-1.95%) |
util.js |
739.58 KB | 735.51 KB | -4.07 KB (-0.55%) |
zlib.js |
311.49 KB | 307.42 KB | -4.07 KB (-1.31%) |
dns.js |
262.44 KB | 258.40 KB | -4.05 KB (-1.54%) |
tls.js |
312.20 KB | 308.16 KB | -4.05 KB (-1.30%) |
tty.js |
46.97 KB | 42.92 KB | -4.05 KB (-8.62%) |
url.js |
334.69 KB | 330.64 KB | -4.05 KB (-1.21%) |
http.js |
670.73 KB | 666.71 KB | -4.03 KB (-0.60%) |
os.js |
104.52 KB | 100.49 KB | -4.02 KB (-3.85%) |
fs.js |
1.22 MB | 1.22 MB | -4.01 KB (-0.32%) |
vm.js |
436.07 KB | 432.06 KB | -4.01 KB (-0.92%) |
net.js |
275.24 KB | 271.24 KB | -4.01 KB (-1.46%) |
errors.js |
350.73 KB | 346.76 KB | -3.98 KB (-1.13%) |
v8.js |
329.81 KB | 325.94 KB | -3.87 KB (-1.17%) |
deprecations.js |
289.39 KB | 285.51 KB | -3.87 KB (-1.34%) |
cli.js |
300.88 KB | 297.04 KB | -3.84 KB (-1.28%) |
async_hooks.js |
195.24 KB | 191.48 KB | -3.75 KB (-1.92%) |
tracing.js |
76.74 KB | 72.99 KB | -3.75 KB (-4.89%) |
perf_hooks.js |
358.81 KB | 355.07 KB | -3.74 KB (-1.04%) |
inspector.js |
118.46 KB | 114.74 KB | -3.72 KB (-3.14%) |
n-api.js |
710.42 KB | 706.75 KB | -3.66 KB (-0.52%) |
intl.js |
36.06 KB | 32.41 KB | -3.65 KB (-10.11%) |
worker_threads.js |
393.61 KB | 389.96 KB | -3.65 KB (-0.93%) |
http2.js |
799.63 KB | 795.99 KB | -3.63 KB (-0.45%) |
esm.js |
135.04 KB | 131.43 KB | -3.61 KB (-2.68%) |
report.js |
188.15 KB | 184.70 KB | -3.45 KB (-1.83%) |
embedding.js |
36.84 KB | 33.39 KB | -3.44 KB (-9.34%) |
packages.js |
122.31 KB | 118.89 KB | -3.42 KB (-2.79%) |
module.js |
334.12 KB | 330.73 KB | -3.38 KB (-1.01%) |
wasi.js |
41.34 KB | 38.00 KB | -3.34 KB (-8.09%) |
diagnostics_channel.js |
305.97 KB | 302.70 KB | -3.27 KB (-1.07%) |
webcrypto.js |
389.28 KB | 386.08 KB | -3.21 KB (-0.82%) |
async_context.js |
216.54 KB | 213.40 KB | -3.14 KB (-1.45%) |
webstreams.js |
282.23 KB | 279.10 KB | -3.12 KB (-1.11%) |
single-executable-applications.js |
83.12 KB | 80.10 KB | -3.01 KB (-3.63%) |
environment_variables.js |
14.60 KB | 11.70 KB | -2.90 KB (-19.85%) |
test.js |
861.54 KB | 858.65 KB | -2.89 KB (-0.34%) |
permissions.js |
28.44 KB | 25.61 KB | -2.83 KB (-9.95%) |
typescript.js |
24.22 KB | 21.56 KB | -2.66 KB (-10.98%) |
sqlite.js |
227.83 KB | 225.23 KB | -2.60 KB (-1.14%) |
quic.js |
150.59 KB | 148.08 KB | -2.51 KB (-1.67%) |
stream_iter.js |
396.17 KB | 393.79 KB | -2.38 KB (-0.60%) |
zlib_iter.js |
56.07 KB | 53.69 KB | -2.38 KB (-4.24%) |
There was a problem hiding this comment.
Pull request overview
This PR increases configurability of the web and jsx-ast generators by moving build-time/static values into a tree-shakeable #theme/config virtual module and by passing serialized per-page metadata into the consumer-supplied #theme/Layout.
Changes:
- Introduces
#theme/config(virtual module) and migrates UI components away from the__STATIC_DATA__global. - Passes serialized page
metadata(primitives + arrays of primitives) plusheadingsandreadingTimeintoLayout, and simplifiesjsx-astprocessing accordingly. - Consolidates URL/file/network loading utilities into
src/utils/loaders.mjsand removes older parser/json loader modules.
Reviewed changes
Copilot reviewed 33 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/url.mjs | Removes URL/file loader helpers; keeps relative() utility. |
| src/utils/parser.mjs | Removed; loader responsibilities moved to src/utils/loaders.mjs. |
| src/utils/misc.mjs | Adds extractPrimitives() helper for serializing metadata. |
| src/utils/loaders.mjs | New shared helpers: toParsedURL, loadFromURL, importFromURL. |
| src/utils/configuration/index.mjs | Switches config import loader to importFromURL from loaders.mjs. |
| src/utils/configuration/tests/index.test.mjs | Updates module mock target from url.mjs to loaders.mjs. |
| src/utils/tests/parser.test.mjs | Removed; superseded by loaders tests. |
| src/utils/tests/loaders.test.mjs | Updates tests to import from loaders.mjs. |
| src/parsers/markdown.mjs | Uses loadFromURL from loaders.mjs. |
| src/parsers/json.mjs | Removed; JSON parsing is now in the metadata generator. |
| src/parsers/tests/markdown.test.mjs | Updates module mock target from parser.mjs to loaders.mjs. |
| src/parsers/tests/json.test.mjs | Removed along with src/parsers/json.mjs. |
| src/generators/web/utils/processing.mjs | Builds #theme/config virtual import; internalizes config/require/builder setup. |
| src/generators/web/utils/data.mjs | Removed; replaced by #theme/config virtual module approach. |
| src/generators/web/utils/config.mjs | New generator for #theme/config virtual module source. |
| src/generators/web/utils/bundle.mjs | Adds virtualImports support to the virtual plugin; removes __STATIC_DATA__ define. |
| src/generators/web/ui/types.d.ts | Declares #theme/config module typings and SerializedMetadata type. |
| src/generators/web/ui/constants.mjs | Removed; STATIC_DATA no longer used. |
| src/generators/web/ui/components/SideBar/index.jsx | Migrates to #theme/config + metadata props for navigation/versioning. |
| src/generators/web/ui/components/NavBar.jsx | Migrates to #theme/config for title/repository. |
| src/generators/web/ui/components/MetaBar/index.jsx | Uses metadata + #theme/config.editURL for “Edit this page” and page info. |
| src/generators/web/ui/components/Layout/index.jsx | Updates Layout prop contract to metadata/headings/readingTime. |
| src/generators/web/ui/components/CodeBox.jsx | Uses #theme/config.languageDisplayNameMap. |
| src/generators/web/README.md | Documents new config options and the #theme/config virtual module + layout props. |
| src/generators/web/index.mjs | Adds default editURL and pageURL templates for web generator config. |
| src/generators/web/generate.mjs | Simplifies call into processJSXEntries() (now self-configuring). |
| src/generators/metadata/generate.mjs | Inlines typeMap loading/parsing via loadFromURL. |
| src/generators/jsx-ast/utils/buildContent.mjs | Passes metadata/headings/readingTime directly to Layout; uses extractPrimitives. |
| src/generators/jsx-ast/utils/buildBarProps.mjs | Removes sidebar/meta prop builders; keeps ToC extraction helpers. |
| src/generators/jsx-ast/utils/tests/buildBarProps.test.mjs | Updates tests to reflect removed APIs and keep coverage for heading/text extraction. |
| src/generators/jsx-ast/types.d.ts | Updates generator chunk processor signature (removes docPages arg). |
| src/generators/jsx-ast/README.md | Removes pageURL/editURL options from documented config. |
| src/generators/jsx-ast/index.mjs | Removes default pageURL/editURL (now sourced elsewhere). |
| src/generators/jsx-ast/generate.mjs | Removes sidebar/docPages computation and passes fewer args to worker processing. |
| scripts/update-type-map.mjs | Switches loader import to loadFromURL from loaders.mjs. |
Comments suppressed due to low confidence (1)
src/utils/url.mjs:8
- The JSDoc for
relativelists params as(from, to)but the function signature is(to, from). After moving this to the top of the file, the mismatch is easier to trip over; update the doc (or rename parameters) to reflect the real argument order.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ovflowd
left a comment
There was a problem hiding this comment.
This is really neat. I love how it shifts certain priorities from jsx-ast to the respective components. I feel some fns within the components can be extracted either as Hooks, and certain things outside (for example the config gen) can also have extracted fns.
Would like som extra unit testing, ensure ESLint/IntelliSense recognizes these globals/types and that's it.
But this is really really good.
They aren't global, they are imported from a module ( |
4840d37 to
1d8cc57
Compare
Yeah, just saying whatever they are, ensure IDEs are happy. And ESLint. |
canerakdas
left a comment
There was a problem hiding this comment.
LGTM! It simplifies things quite a bit 🙌
|
@avivkeller rebase and merge right away to unblock other PRs! |
|
cc @nodejs/web-infra requesting fast-track due to being work that can unblock other work, 👍 / 👎 |
1d8cc57 to
537e100
Compare
|
Rebased! |
537e100 to
1b0892f
Compare
|
cc @canerakdas feel free to continue your work 🙇 |
Ref: https://openjs-foundation.slack.com/archives/C09EXEEHFKP/p1775009710266389
This PR changes the way the
webandjsx-astgenerator work slightly in order to make them more configurable for non-Node.js Core consumers.Now, all static properties are passed to all components, and can be accessed via a
#theme/configimport. This import will tree-shake all unused imports, so bundle size should actually be smaller.Additionally, the
#theme/Layoutcomponent, supply-able by the consumer, now receives ametadataobject, consisting of a serializedMetadataEntry(all non-primitives or non-array-primitives removed), which it can then use to create it's own layout and/or sidebar.This'll allow users to, for instance, supply
authorsin the frontmatter for a markdown file, and then access that data in theirLayoutcomponent.Note: A bit of loading logic had to be changed, as we can't import files that import
node:*on the clientCloses?: #332 (cc @ovflowd wdyt?)