Repository navigation
Keep component icon slots in built themes - #7131
rubyycheung wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
The generated theme module now inlines the normalized componentIcons map, so a built theme and its source expose the same slot mappings, including null entries, and a theme extending a built theme inherits the same map it inherits from source. The map adds no CSS. Removes the resolved built-theme gap note from architecture:theme-compilation and the matching caveat from the icons docs.
145c589 to
f1eb2f6
Compare
8038d36 to
43a4fe9
Compare
There was a problem hiding this comment.
Built themes now keep their component icon slot mappings, so a built theme resolves each slot the same way its source theme does — including slots intentionally hidden — and a theme extending a built theme inherits the same mappings. Themes without a slot map produce unchanged output, and the map adds nothing to the generated CSS.
I checked the serializer against theme definition's own normalization (names and hidden slots kept, unmapped entries dropped, key order preserved) and ran the build test file locally: all 60 tests pass, including the new parity, inheritance, staleness, and family-build fixtures. No changes are needed.
One sequencing note for maintainers: the detailed parity wording for this behavior is still landing in the stacked spec change beneath this stack. The preservation direction is already in the current icon-resolution architecture record, so this does not block the fix, but if that stacked wording is amended, the parity details are worth a final recheck against it.
[Automated review]
|
Closing this PR because its build support belongs to the superseded static-only #7117 → #7122 direction. Source/built-theme parity remains mandatory and is moving into the first focused replacement implementation PR, so no theme field can silently disappear during a build. The corrected AST-054 model is in #6891 and its authority projection is in #7116. This PR remains available as historical context; none of it landed. Replacement links will be added to #6891 and #7116 as each focused PR opens. |
User need
A theme author who maps component icon slots with
defineTheme({componentIcons})and ships the theme throughastryx theme buildgets a built module without the map. When the built theme is passed to<Theme>, every slot falls back to its component default. A theme thatextendsthe built module, which is how the shipped./builtsubpaths are consumed, inherits no slot mappings either. The same theme then behaves differently depending on whether it is used from source or from its build.Problem and solution fit
The generated theme module now inlines the normalized
componentIconsmap, the same way it already carriescomponents, media surfaces, and adaptation metadata for extending themes. The map holds only shared icon names andnull, so JSON serialization reproduces it exactly:IconNamevalues;nullkept;undefinedentries left out, matchingdefineThemenormalization, including for a raw theme object that skipsdefineTheme.The map contributes nothing to the generated CSS. Family builds serialize each member's flattened map.
Stacked on the static
componentIconsCore implementation, which is stacked on #7117.Current specification
architecture:theme-compilationINV15: component icon slot maps pass through to the built module unchanged, with the same keys and values includingnull, and a theme extending a built theme inherits the same map it inherits from source.architecture:theme-authoring-contractINV3/INV13 own the normalized map this build saves.architecture:icon-resolution-and-component-slotsowns what an entry means; this PR does not change resolution.Public delta and caller burden
astryx theme buildJavaScript output gains acomponentIconsfield whenever the resolved source theme has one. It is absent when the source has none, and{}when the source map is empty..d.tsoutput are unchanged. The declaration already types the theme asDefinedTheme, which includescomponentIcons.componentIconsproduce byte-identical output.Design and alternatives
The map is serialized inline, not imported, because it is plain data, unlike the icon registry, which holds React elements. The serializer follows
defineThemenormalization rather than copying the field blindly, so a raw theme object and itsdefineThemeform produce the same built map.Evidence
New fixtures in
packages/cli/api/theme/build/build.test.mjs(themeBuild() — componentIcons) build real theme files, import the generated module, and compare it with the runtime result of the same source:null; the CSS carries no slot data;nullreplacement, name replacement, andundefinedinheritance);undefinedentry is saved asdefineThemewould normalize it;{}when the source map is empty;Disabling the serializer makes all seven new tests fail.
Scope
Writing rubric results
This PR edits one knowledge record,
docs/architecture/theme-compilation.md: it deletes the paragraph under "Known conformance and verification gaps" that describedcomponentIconspreservation as unshipped.build.test.mjscomponent-icon and runtime/build comparison fixtures, which now exist.Testing
pnpm exec vitest run packages/cli/api/theme/build/build.test.mjs: 60 tests passed, including the 7 new ones;packages/cli/api/theme,packages/cli/clients/cli/commands,packages/core/src/theme,packages/core/src/Icon,scripts/check-theme-template.test.mjs, andscripts/check-knowledge.test.mjs: 136 files, 3,284 tests passed;packages/cli/api/build/build.test.mjsandpackages/cli/clients/cli/commands/search.test.mjs, which this PR does not touch, and both files pass when rerun on their own (77 tests);typecheck; CLItypecheck:json-api,typecheck:template-docs, andtypecheck:authoring;.mjs,.md, and changeset files;pnpm check:repo, includingcheck:sync,check:knowledge, andcheck:changesets;git diff --check.CLI
typecheck:strictreports the same two errors with and without this change: unchanged page templates import@astryxdesign/theme-neutral/built, which is not built in this checkout.icons.doc.mjshas four pre-existingcategory:indentation lines that Prettier would reformat; they are left untouched to keep the diff focused.