feat(react): emit per-component CSS token slices#132
Merged
wangdicoder merged 2 commits intomasterfrom Apr 25, 2026
Merged
Conversation
Replaces the monolithic 240KB base.css with per-tier (foundation, semantic) and per-component slice files. Each component entry now imports only the slices it actually needs, computed by closure over both var(--ty-*) references and style/index.tsx SCSS imports. Per-component CSS bundles drop ~60% raw / ~80% gzipped (Button: 261KB->103KB raw, 36KB->7.5KB gzip). Full-library bundle size is unchanged. base.css is still emitted for backward compatibility.
0c81c84 to
4b5b141
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
base.csstoken registry with per-tier (foundation.css,semantic.css) and per-component slice files (components/<name>.css).var(--ty-*)references andstyle/index.tsxSCSS imports.base.cssis still emitted for backward compatibility — no breaking change for direct importers.data-tiny-themeattribute) works identically.Bundle impact (Vite 5, esbuild minify)
JS bundle size is unchanged.
Release
@tiny-design/react,@tiny-design/tokens(fixed-version group bumps@tiny-design/iconsalong)Test plan
pnpm --filter @tiny-design/tokens testpasses (consumer contract check still validates 1283/1665 vars)pnpm --filter @tiny-design/react testpasses (98 suites, 810 tests, 81 snapshots)pnpm --filter @tiny-design/docs buildsucceeds--ty-button-*component vars (1056 declarations across light/dark/system), zero leakage from--ty-modal-*,--ty-form-*,--ty-table-*modal → [button, modal, overlay],tour → [button, popover, popup, tour],transfer → [button, checkbox, empty, input, transfer]What changed
packages/tokens/scripts/build-runtime.js— adds closure computation that scans eachpackages/react/src/<dir>forvar(--ty-*)refs and followsstyle/index.tsxSCSS imports transitively. Emits per-tier + per-component slice files plus acomponent-deps.jsonmanifest.packages/react/scripts/build-styles.js— copies the new CSS files and manifest intoes/style/andlib/style/.packages/react/scripts/inject-style-imports.js— reads the manifest and injectsfoundation.css+semantic.css+ per-component slice imports into each component's compiledindex.js. Barrel injects only foundation + semantic; component slices come through component imports.🤖 Generated with Claude Code