[docs-infra] Replace handwritten source parsing with TypeScript - #1764
[docs-infra] Replace handwritten source parsing with TypeScript#1764brijeshb42 wants to merge 2 commits into
Conversation
Deploy previewBundle sizeTotal Size Change: ▼-7.05KB(-0.21%) - Total Gzip Change: ▼-1.87KB(-0.20%) Show details for 69 more bundles@mui/internal-docs-infra/useCode parsed: 🔺+13B(+0.01%) gzip: 🔺+71B(+0.20%) PerformanceTotal duration: 16.74 ms +0.69 ms(+4.3%) | Renders: 5 (+0) | Paint: 57.74 ms -1.11 ms(-1.9%)
5 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
4adce95 to
be5d612
Compare
8990172 to
8dc4603
Compare
8dc4603 to
d8164b0
Compare
|
Mainly because typescript is already installed and initialized. So there's no overhead there. It'll work till we have the lighter version with lezer based parsing.
There's a very slight impact in perf (in 40ms range) here, mainly because a ts project is already initialized (for type generation). But nothing significant. We still get same build times but with less code. |
d8164b0 to
1196891
Compare
|
tbh, I'd be very careful relying on typescript API if all we do is parsing. It's really unstable, and non-existent in v7. There is barely an ecosystem for ts as a transpiler platform. I guess we could tolerate it if it's temporary |
Part of #1762
Summary
Replace handwritten JavaScript/TypeScript parsing with the TypeScript syntax tree for:
create*factory discovery and source rangesThe existing structured output and legacy generic factory syntax remain supported. CSS and comment processing are unchanged. Direct utility imports keep the TypeScript parser out of unrelated Base UI bundles.
This reduces production code by 1,046 SLOC (
+531 / -1,577). All 133 factory results and 520 import results in the Base UI demo corpus are byte-for-byte equivalent tomaster.The corpus microbenchmark increases from 23 ms to 82 ms. The cold Base UI docs build still compiled in 37.8 seconds, generated all 193 pages, and reported no broken links or HTML issues. Across three alternating cold builds, median aggregate peak RSS was 4.32 GB on
masterand 4.24 GB on this branch—no measurable memory regression.Validation