Repository navigation
Conversation
tokens.ts imported tokenDefaults from defineTheme, the theme builder. A build that keeps whole modules then loaded defineTheme and the 16 modules that only it loads, such as resolveThemeValues, themeAdaptations, localTokens and themeRegistry. tokens.ts now imports tokenDefaults from its own module and takes the defineTheme types as a type-only import. The token import tests get a theme/tokens case in the source walk and in the compiled-entry walk. Each has a control that finds the builder modules from defineTheme or from the theme entry.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
|
/approve-spec 518b109 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The pull request is a draft, and it already has the ci:run label, so CI runs once it is marked ready for review.
theme/tokens.ts now reads tokenDefaults from its own module, so a tokens-only app whose build keeps whole modules no longer loads defineTheme and the modules it brings in. Resolved tokens and the public API are unchanged, and the two new boundary tests fail on main and pass on this head.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claims
- Title and changeset: a tokens-only app no longer loads the theme builder when its build keeps whole modules. Verified: the new source-walk and compiled-walk cases fail on
mainand pass here, and a whole-module bundle drops from 31 to 14 modules. - Changeset: token resolution reads the defaults from their own module. Verified:
tokens.ts:27. - Changeset: every resolved token stays the same. Verified:
defineTheme.ts:720re-exports the same binding, and the theme suite passes 1,922 tests in 36 files. - Changeset and description: no API changes. Verified: Core's and the seven themes' API surfaces are identical with this change.
- Description: about 11.7 kB gzip (35 kB minified) less for whole-module builds. Verified: 78,581 to 43,465 B minified and 23,846 to 12,128 B gzip, with
reacttreated as external, which the table assumes but does not state. - Description: a tree-shaken build changes by 1 B less minified and 16 B more gzip. Verified within a byte (1 B less, 17 B more).
- Description:
tokens.tsimported the defaults fromdefineTheme.ts, which already re-exports them from a module that holds only token data. Verified:tokens.ts:25onmain,defineTheme.ts:720,tokenDefaults.ts:11-26. - Description: the token architecture record makes
tokens.tsthe server-safe resolver anddefineTheme.tsthe authoring aggregate. Verified. - Description: the existing tests already keep the theme-rule generator out of token resolution. Verified: those cases pass on
main. - Description: no other source changes. Verified: the diff touches one source file.
- Description: 2 of 18 tests fail on
main, both list the same five modules, and all 18 pass here. Verified. - Description: preflight passes, and the full Node and jsdom runs show the same failures and flakes on both sides. Not reproduced (local runs, and CI has not run on this head); the verdict does not depend on them.
- Commit message: the builder brings in 16 modules besides itself. Verified: 31 modules on
main, 14 here.
- Title and changeset: a tokens-only app no longer loads the theme builder when its build keeps whole modules. Verified: the new source-walk and compiled-walk cases fail on
- Files
.changeset/theme-tokens-no-builder.md: clear.packages/core/src/theme/tokens.ts: clear.packages/core/src/theme/tokensImports.test.ts: clear.packages/core/src/theme/tokensImports.dist.test.mjs: clear; it names the same five modules as the source test.
|
/approve-spec 35c9c5f |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The pull request is a draft and already has the ci:run label, so CI runs once it is marked ready for review.
theme/tokens.ts now reads tokenDefaults from its own module, so a tokens-only app whose build keeps whole modules no longer loads defineTheme and the modules it brings in. The merge of main leaves the change itself untouched, resolved tokens and the public API stay the same, and the two new boundary tests pass on this head.
Claims and files checked
Review mode: carry-forward; reason: none
- Claims
- Title and changeset: a tokens-only app no longer loads the theme builder when its build keeps whole modules. Verified: the new source-walk and compiled-walk cases fail on
mainand pass here, and a whole-module bundle drops from 31 to 14 modules. - Changeset: token resolution reads the defaults from their own module. Verified:
tokens.ts:27. - Changeset: every resolved token stays the same. Verified:
defineTheme.ts:720re-exports the same binding, and the theme suite passes 1,945 tests in 36 files. - Changeset and description: no API changes. Verified: Core's and the seven themes' API surfaces are identical with this change.
- Description: about 11.7 kB gzip (35 kB minified) less for whole-module builds. Verified: 35,116 B minified and 11,718 B gzip less with
reacttreated as external; the table's absolute sizes sit 25 B above that build on every row, and its differences match within 3 B. - Description: a tree-shaken build changes by 1 B less minified and 16 B more gzip. Verified within a byte (1 B less, 17 B more).
- Description:
tokens.tsimported the defaults fromdefineTheme.ts, which already re-exports them from a module that holds only token data. Verified:tokens.ts:25onmain,defineTheme.ts:720,tokenDefaults.ts:11-26. - Description: the token architecture record makes
tokens.tsthe server-safe resolver anddefineTheme.tsthe authoring aggregate. Verified. - Description: the existing tests already keep the theme-rule generator out of token resolution. Verified: those cases pass on
mainand here. - Description: no other source changes, and
defineThemestill exportstokenDefaults. Verified: the diff touches one source file;defineTheme.ts:720. - Description: 2 of 18 tests fail on
main, both walks list the same five modules, their controls still find them, and all 18 pass here. Verified. - Description: after the merge of
main, the quick preflight passes, and the full Node and jsdom runs show the same failures and flakes on both sides. Not reproduced (local runs, and CI has not run on this head); the verdict does not depend on them. - Commit message: the builder brings in 16 modules besides itself. Verified: 31 modules on
main, 14 here.
- Title and changeset: a tokens-only app no longer loads the theme builder when its build keeps whole modules. Verified: the new source-walk and compiled-walk cases fail on
- Files
.changeset/theme-tokens-no-builder.md: clear.packages/core/src/theme/tokens.ts: clear.packages/core/src/theme/tokensImports.test.ts: clear.packages/core/src/theme/tokensImports.dist.test.mjs: clear; it names the same five modules as the source test.
User impact
An app can import only
@astryxdesign/core/theme/tokens, for example to resolve token values on a server. When its build keeps whole modules, that app loads the theme builder on first load. The builder isdefineThemeand the modules that only it loads, such asresolveThemeValues,themeAdaptations,localTokensandthemeRegistry. With this change that app loads about 11.7 kB gzip (35 kB minified) less JavaScript. A build that removes unused code statement by statement already leaves most of it out. Its output shrinks by 1 B minified and grows by 16 B gzip.Problem and solution fit
tokens.tsimportstokenDefaultsfromdefineTheme.ts. A bundler that keeps a module's own code then keeps all ofdefineTheme.tsand what it imports.tokenDefaults.ts, which imports only token data, anddefineTheme.tsalready re-exports it.Expected behavior and authority
architecture:theme-tokensmakestokens.tsthe owner of server-safe references and resolution, and keepsdefineTheme.tsas the authoring aggregate. The token import tests already keep the theme-rule generator out of token resolution. This change keeps the builder out as well.Smallest restoration
tokens.tsimportstokenDefaultsfrom./tokenDefaultsand takesDefinedThemeandTokenNameas a type-only import from./defineTheme. No other source changes.defineThemestill exportstokenDefaults, so every caller and every resolved token stays the same.Evidence
theme/tokenscases fail onmain. Both walks listdefineTheme,resolveThemeValues,themeAdaptations,localTokensandthemeRegistry.defineThemeand from thethemeentry.tokensImports.test.tsandtokensImports.dist.test.mjs.Scope
Components: theme (tokens)
Testing
pnpm exec vitest run packages/core/src/theme/tokensImports.test.ts packages/core/src/theme/tokensImports.dist.test.mjs: 2 of 18 tests fail onmain; all 18 pass with this change.pnpm exec vitest run packages/core/src/theme: 1,945 tests in 36 files pass.Merge main,pnpm preflight --quickpasses: review:pre, typecheck, lint, changed tests, knowledge and changesets.pnpm preflightran on the branch before that merge. Its review:pre, build, typecheck, lint, knowledge and changesets passed.mainand here. 54 pass on both.theme-cut-short.test.mjs(4 tests) andtheme-pictures-broken-words.test.mjs(1 test) fail on both sides with the same assertions.Switch/useSwitchTouch.test.ts.mainand four more times here. Two flakes show on both sides.semanticFence.shared.test.tsxtimed out at 30 s in 2 of 3 runs onmainand in 4 of 5 runs here.useSwitchTouchtimer error appeared in 1 of 3 runs onmainand in 3 of 5 runs here.import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens', is bundled with esbuild 0.28.2 (minified, ESM, browser) against Core's builtdist. Gzip is level 9.maintreeShaking: false)