[docs-infra] Support metadata declared as named constants - #1713
Conversation
Deploy previewBundle sizeTotal Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%) Show details for 69 more bundles@mui/internal-docs-infra/abstractCreateDemo parsed: 0B(0.00%) gzip: 0B(0.00%) PerformanceTotal duration: 15.17 ms -0.20 ms(-1.3%) | Renders: 5 (+0) | Paint: 59.27 ms +0.32 ms(+0.5%)
5 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
|
@claude review |
This comment has been minimized.
This comment has been minimized.
3b8b486 to
6a1faf9
Compare
d37ff26 to
97e8235
Compare
|
@claude review |
This comment was marked as resolved.
This comment was marked as resolved.
Metadata files declared their data attributes and CSS variables as a string enum named after the file. Recognize named literal constants as an equivalent form so application bundlers can inline and tree-shake the values, and normalize both to a single constant group named after its file.
Replace the console.warn with a thrown error when a metadata file mixes non-constant exports with constants — the group replaces the file's exports wholesale, so a stray export (including a constant widened off its literal type) would be documented nowhere. Failing the build is better than dropping it silently. Inline parseSources into transformConstantGroup.test.ts and drop parseSources.testUtils.ts, so the PR doesn't introduce a .testUtils.ts file that the build ships as dead code.
4964da8 to
725e9cd
Compare
The demo test added here still used the path.dirname(...).split('/app') snippet
that #1795 replaced everywhere with appRoute(import.meta.url); bring it in line.
This comment has been minimized.
This comment has been minimized.
|
Fixed the architecture wording in a9b7274. The two silent misclassification cases are real, but the root cause sits in the extractor: it emits identical literal nodes for |
Metadata files (
*DataAttributes.ts,*CssVars.ts) had to declare their members as a string enum named after the file. This adds named literal constants as an equivalent form, so application bundlers can inline and tree-shake the values instead of retaining a runtime enum object. Both forms are normalized to a single constant group named after its file, so everything downstream — component matching, table rendering, markdown generation — is untouched.Unblocks mui/base-ui#5248, which converts every Base UI metadata file to constants. Verified with a new
data-attr-esmdemo whose generatedtypes.mdtable is byte-identical to the enum demo's, and a fulldocs:validatethat regenerated nothing across the existing 62 types files.