Skip to content

fix(cli): a theme family checks its compiled registries as plain Node loads them - #13358

Closed
josephfarina wants to merge 4 commits into
mainfrom
josephfarina/family-compiled-check
Closed

josephfarina wants to merge 4 commits into
mainfrom
josephfarina/family-compiled-check

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

fix(cli): a theme family checks its compiled registries as plain Node loads them

What changes

theme build --family checked each member's icon registry by importing its source file with Node's own import(). A single theme build never does that: it compiles a local registry into <name>.modules/, and the built module imports the compiled copy. So a family stopped with Cannot import family registry … and wrote nothing when a member's local registry was .tsx or .jsx, was .ts on Node before 22.18 (the CLI supports 22.13+), or imported a local file without its extension — while a single build of the same member worked.

The family build now checks what plain Node will actually load. Before it writes anything, it writes the modules it compiles to a folder beside <family-key>.modules/, at the same depth (so every relative import in them resolves exactly as it will from the modules folder), and imports each compiled registry from there with Node's own import(), as <key>.js will import it. Only when every registry passes does it write its outputs. The folder is removed whether the check passes or fails, so a failed check leaves the output untouched. The check runs after the output checks (confineOutputs, assertOutputsReplaceable), so a build refused for writing outside cwd writes nothing at all, as architecture:cli-surface INV10/DEC-3 require. --check writes nothing (spec:AST-034 FR8) and checks registries from their source, exactly as on main. A registry that is not compiled (from a package, or named by --icons-specifier) is checked from its source, as before; the static walk of the source graph (CSS imports, missing named exports) is unchanged.

Because the check runs on the compiled copy, it gives plain Node's verdict for every case at once, with no rule keyed on paths or specifiers: a local .tsx/.jsx registry and an extensionless import pass, and a registry whose imports Node cannot load — such as a workspace package whose entry is .tsx, imported directly or through a local registry — still stops the build, naming that file. This is what spec:AST-034 FR6 asks of <key>.js: one complete resolved export for every selected member, which parses and imports.

"Author a theme"'s family section gains the sentence this makes true: a member's TypeScript or JSX registry or slot module is compiled into <family-key>.modules/, as for a single build.

Testing

Size: one fix that can't be split: the code change is about 75 lines in build.mjs; the rest is the plain-Node CLI tests that prove each case (and each fails on main or on the earlier approaches).

New tests in build.self-contained.test.mjs run the CLI in its own process (plain Node, outside Vitest's loader, which would load .tsx itself):

  • .ts, .tsx and .jsx registries, each importing a helper without its extension: the family builds and its module imports in plain Node. All three fail on main.

  • a .tsx entry of a workspace package linked into node_modules, imported by the member directly, and through a local .ts registry that re-exports it: the build stops with Cannot import family registry, names the package file, writes neither <key>.js nor the modules folder, and leaves no check folder behind. Both pass on main (main stops too); the second fails on a loader-by-path approach.

  • --check on a family with a compiled .ts registry, with its folder read-only, passes and leaves the folder as it was; a build refused outside cwd (also on a read-only folder) fails with ERR_PATH_TRAVERSAL. Both fail on a version that writes the check folder first (EACCES from mkdtemp).

The family sentence says "registry" (not "icon registry"), so no search golden changes.

vitest run packages/cli/api/theme/build packages/cli/foundation/doc-compiler/doc-loads.test.mjs packages/cli/test/experimental-isolation.test.mjs: 813 pass, 2 skipped. pnpm -F @astryxdesign/cli typecheck:strict: only the two @astryxdesign/theme-neutral/built errors main shows on a box without that package built.

Stack: #13358 → #13388

preflight: pass d901f60

@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 21, 2026 11:39pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 21, 2026, 11:44 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d901f60

⏳ Building… Until it's ready, Storybook · Sandbox open the branch's previous preview.

Current run: Heavy CI deferred: runs when review passes and before merge. Lint, typecheck and any path-filtered checks ran on this push.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the family build now accepts local TypeScript and JSX registries as a single build does, and the new tests prove it, but --check lost a check it had on main.

  • --check no longer imports compiled registries (packages/cli/api/theme/build/build.mjs:2718), so after an installed dependency of a local .ts registry drops the export the registry imports, --check reports the family up to date (exit 0) while theme build --family refuses and the committed module throws on import; under --check, import each compiled registry from the committed <family-key>.modules/ copy when it matches this build's bytes, and add a test for that case.

Main's --check exits 1 on the same family, naming the registry. Everything else in the change checks out.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: a family builds a member's local TypeScript or JSX registry and compiles it into the family's modules folder. Verified: the new CLI-process tests pass here and fail on main.
  • Claim: the build imports each compiled copy before writing outputs, and --check only reads it. Verified (build.mjs:2712-2741, :7201-7202).
  • Claim: main stopped on .tsx and .jsx registries, on .ts before Node 22.18, and on extensionless local imports. Verified for .tsx, .jsx and extensionless imports by running the new tests on main; the Node 22.18 boundary was not run.
  • Claim: a registry whose imports plain Node cannot load still stops the build, names the file, and writes nothing. Verified (build.self-contained.test.mjs:221-300).
  • Claim: the check folder sits beside the modules folder at the same depth and is always removed. Verified (build.mjs:2720-2740).
  • Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing. Verified (build.mjs:7188-7202, test at :340-366).
  • Claim: --check writes nothing, and the comparison reports a stale or missing module. Verified; it also no longer imports compiled registries (the finding above).
  • Claim: uncompiled registries are checked from source as before, and the static walk is unchanged. Verified (build.mjs:2683-2688, :2717-2719).
  • Claim: the doc sentence is true, and the two search counts each rise by one with nothing else moving. Verified; the golden tests pass.
  • Claim: the three registry tests fail on main and the package tests pass on main. Verified by running them on main; the remarks about alternative implementations were not checked.
  • Claim: test totals and strict typecheck. Verified: the totals match, and the typecheck is clean with the theme package built.
  • File .changeset/family-build-compiled-registry-check.md: clear.
  • File packages/cli/api/theme/build/build.mjs: finding at line 2718.
  • File packages/cli/api/theme/build/build.self-contained.test.mjs: clear.
  • File packages/cli/assets/docs/author-a-theme.doc.mjs: clear.
  • Files packages/cli/test/__golden__/no-icon-set/search-icon-set.json, search-icon-set.txt, search-icon.json, search-icon.txt: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/theme/build/build.mjs Resolved

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the family build now accepts local TypeScript and JSX registries, and --check again catches a dependency that drops an export, but --check now fails on exactly the families the build newly accepts.

  • --check imports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successful family build with a local .tsx, .jsx or extensionless-import registry, theme build --family … --check exits 1 with Cannot import family registry instead of comparing the outputs as spec:AST-034 FR8 requires; under --check, import the committed <family-key>.modules/ copy when it matches this build's bytes (a read, no write), leave a stale or missing copy to the comparison, and add a CLI-process test that runs --check after a .tsx family build.

The earlier finding about a dropped dependency export is fixed. A single theme build --check of the same member reports it up to date, so family mode is the one place this check breaks.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim: the family build imported registry sources, while a single build compiles them into its modules folder. Verified.
  • Claim: main stopped on .tsx and .jsx registries, on extensionless local imports, and on .ts before Node 22.18. Verified on main for the first three; the Node 22.18 boundary was not run.
  • Claim: the build writes its compiled modules to a temporary folder beside the modules folder at the same depth, imports each compiled registry from there, writes outputs only when all pass, and always removes the folder. Verified (build.mjs:2719-2739).
  • Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing. Verified (build.mjs:7187-7201, test at build.self-contained.test.mjs:459-485).
  • Claim: --check writes nothing and checks registries from their source, as on main. Verified (build.mjs:2717); it then fails on the newly supported families (the finding above).
  • Claim: registries that are not compiled are checked from source, and the static walk is unchanged. Verified (build.mjs:2683-2688, :2715-2716).
  • Claim: local .tsx, .jsx and extensionless-import registries build, and a registry whose imports plain Node cannot load still stops the build, naming the file. Verified for the build (tests at :290-338, :340-419).
  • Claim: the docs sentence on the family's modules folder is true. Verified for the build.
  • Claim: the icon and icon set search counts each rise by one and nothing else moves. Verified; the golden tests pass.
  • Claim: the new registry tests fail on main and the package tests pass on main. Verified with the same cases on main; the remarks about alternative implementations were not checked.
  • Claim: the listed test run passes and the strict typecheck shows only errors from an unbuilt theme package. Verified: 812 pass and 2 skip, the one failure needs a git checkout, and the typecheck is clean with the themes built.
  • Claim (release note): a family builds a member's local TypeScript or JSX registry as a single build does, and --check checks registries as before. Verified for the build; --check is the finding above.
  • File .changeset/family-build-compiled-registry-check.md: clear.
  • File packages/cli/api/theme/build/build.mjs: finding at line 2717.
  • File packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs --check on a TypeScript or JSX registry family (part of the finding).
  • File packages/cli/assets/docs/author-a-theme.doc.mjs: clear.
  • Files packages/cli/test/__golden__/no-icon-set/search-icon-set.json, search-icon-set.txt, search-icon.json, search-icon.txt: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/theme/build/build.mjs Resolved

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the family build now accepts local TypeScript and JSX registries as a single build does, and the new CLI tests prove it, but --check still fails on exactly the families the build newly accepts.

  • --check imports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successful theme build --family with a local .tsx, .jsx or extensionless-import registry it exits 1 with Cannot import family registry … instead of comparing the outputs, which spec:AST-034 FR8 and FR2 require.

Next: under --check, import a compiled registry from the committed <family-key>.modules/ copy when its bytes match this build's (a read, no write), leave a stale or missing copy to the comparison, and add a CLI-process --check test after a .tsx family build. The dependency-drop case from the earlier review stays fixed.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim: The family check imported each registry's source, while a single build compiles local registries into a modules folder: verified (main's registry check imports the source file; a single --check here checks ocean-calm.modules/icons.tsx.js).
  • Claim: Main's family build stopped on a .tsx or .jsx registry, a .ts one before Node 22.18, or an extensionless local import: verified for .tsx, .jsx and the extensionless import (the three new CLI tests fail on main with Cannot import family registry); the Node 22.18 boundary was not run.
  • Claim: Before writing, the compiled modules go to a sibling folder at the same depth, each compiled registry is imported from there, outputs are written only when all pass, and the folder is always removed: verified (build.mjs:2711-2740; test :377-419 finds no folder left).
  • Claim: The check runs after the output checks, so a build refused outside cwd writes nothing: verified (build.mjs:7186-7201; test :459-485).
  • Claim: --check writes nothing and checks registries from their source, as on main: verified (build.mjs:2717, :7137; test :443-457); its consequence is the blocking finding.
  • Claim: A registry that is not compiled (a package, or --icons-specifier) is checked from its source, and the static walk is unchanged: verified (build.mjs:2715-2718, :2683-2691, :6749-6755).
  • Claim: The check gives plain Node's verdict: local .tsx/.jsx and extensionless imports pass, and imports Node cannot load still stop the build, naming the file: verified for the build (tests :290-419); false for --check (the finding).
  • Claim: "Author a theme" gains a sentence on the family's modules folder: verified (author-a-theme.doc.mjs:158), accurate for the build.
  • Claim: The icon and icon set goldens each count one more match and nothing else moves: verified (the diff, and the golden tests pass).
  • Claim: The three registry tests fail on main and the two package tests pass on main: verified by running this head's test file on main's code (3 fail, the rest pass).
  • Claim: The second package test fails on a loader-by-path approach, and the --check and outside-cwd tests fail on a version that writes the check folder first: not checked; they describe other implementations, not this code.
  • Claim: The release note's account of the build, the compiled-copy check and main's failures: verified for the build; --check differs (the finding).
  • Claim: The named suites give 813 passing and 2 skipped: 812 pass and 2 skip here; the one other test fails only because it lists files with git in a tree that has no git history.
  • Claim: The strict CLI typecheck shows only the two errors main shows when the neutral theme is unbuilt: consistent; it passes with 0 errors once the themes are built.
  • File: .changeset/family-build-compiled-registry-check.md: clear.
  • File: packages/cli/api/theme/build/build.mjs: blocking finding at :2717.
  • File: packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs --check on a TypeScript or JSX registry family (part of the finding).
  • File: packages/cli/assets/docs/author-a-theme.doc.mjs: clear.
  • File: packages/cli/test/__golden__/no-icon-set/search-icon.json, search-icon.txt, search-icon-set.json, search-icon-set.txt: clear.

Automated review (maintainer link)

// from its source, as before.
const written = new Set(writes.map(write => write.dest));
registries = registries.map(({compiledCopy, ...registry}) => (compiledCopy && written.has(compiledCopy) ? {...registry, compiledCopy} : registry));
if (check) return validateRegistryGraphs(registries.map(({specifier, exportName}) => ({specifier, exportName})), aggregatePath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under --check each registry reaches validateRegistryGraphs without its compiled copy, so its source is imported with Node. Right after a successful family build with a local icons.tsx (or .jsx, or a .ts that imports ./size), --check exits 1 with Cannot import family registry …: Unknown file extension ".tsx" and never compares the outputs, while a single build's --check reports the same member up to date (spec:AST-034 FR8). Import the committed <family-key>.modules/ copy when it matches this build's bytes (a read, no write), and leave a stale or missing copy to the comparison.

… loads them

theme build --family checked each member's registry by importing its source
with Node, so a family stopped on a local .tsx or .jsx registry, on a .ts one
before Node 22.18, or on a local import without its extension, while a single
build of the same member compiles it. A family build now writes the modules it
compiles to a folder beside the modules folder, at the same depth, imports
each compiled registry from there with Node, as the family module will, and
only then writes its outputs; the folder is always removed. The check runs
after the output checks, so a build refused for writing outside cwd writes
nothing, and --check writes nothing: it reads a compiled registry, and the
comparison of the committed modules reports any stale or missing one. A
registry whose imports plain Node cannot load still stops the build, naming
the file.

Tests build families through the CLI in its own process: .ts, .tsx and .jsx
registries that import a helper without its extension build, and the family
module loads in plain Node (all three fail on main); a .tsx entry of a linked
workspace package stops the build, naming the package file and writing
nothing, whether the member imports the package or a local registry
re-exports it; --check on a read-only folder and a build refused outside cwd
make no write. Author a theme's family section says a member's TypeScript or
JSX registry or slot module is compiled as for a single build; the icon and
icon set search counts each rise by one.
Astracat's first review found that --check, by only reading a compiled
registry, no longer caught a registry whose installed dependency drops an
export. --check now checks each registry from its source, exactly as on main,
and writes nothing; checking the committed compiled copies under --check
follows as its own change. [skip ci]
…s on main

The family section's sentence named an icon registry, which added one match
to the icon and icon set searches; main has since moved those snapshots, so
the counts no longer lined up. It now says a member's registry or slot module,
and no search golden changes.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: family builds now accept local TypeScript and JSX registries the way a single build does, and the new CLI tests prove it, but --check still fails on exactly those families.

  • --check still imports each registry's source (packages/cli/api/theme/build/build.mjs:2717), so right after a successful theme build --family with a local .tsx, .jsx or extensionless-import registry it exits 1 with Cannot import family registry … instead of comparing the outputs, which spec:AST-034 FR8 and FR2 require.

Next: bring the --check change described in #13388 (which targets this branch) into this pull request, with a CLI-process test that runs --check after a .tsx family build. Everything else checked out, including byte-identical output for the published themes.

Claims and files checked

Review mode: full; reason: rebase

  • Claim: main's family check imported each registry's source, while a single build compiles local registries into a modules folder: verified (main's check imports the source file; a single build here writes and checks ocean-calm.modules/icons.tsx.js).
  • Claim: main's family build stopped on a .tsx or .jsx registry, a .ts one before Node 22.18, or an extensionless local import, while a single build worked: verified for .tsx, .jsx and the extensionless import (the three new CLI tests fail on main's code); the Node 22.18 boundary was not run.
  • Claim: before writing, the compiled modules go to a sibling folder at the same depth, each compiled registry is imported from there, outputs are written only when all pass, and the folder is always removed: verified (build.mjs:2719-2739, :7201 before :7271; test :377-419 finds no folder left).
  • Claim: the check runs after the output checks, so a build refused outside the working directory writes nothing: verified (build.mjs:7187-7201; test :459-485).
  • Claim: --check writes nothing and checks registries from their source, as on main: verified (build.mjs:2717, :7137; test :443-457); its consequence is the blocking finding.
  • Claim: a registry that is not compiled (a package, or --icons-specifier) is checked from its source, and the static walk is unchanged: verified (build.mjs:2683-2688, :6750, :7081).
  • Claim: the compiled check gives plain Node's verdict, so local .tsx/.jsx and extensionless imports pass and a registry Node cannot load still stops the build, naming the file: verified for the build (tests :290-419); false for --check (the finding).
  • Claim: the family spec asks for one complete resolved export per member that parses and imports: verified (the FR6 text).
  • Claim: "Author a theme" gains a sentence on the family's modules folder: verified (author-a-theme.doc.mjs:158).
  • Claim: the new tests run the CLI in its own process: verified (test :100-107).
  • Claim: the three registry tests fail on main: verified (3 fail on main's code with this test file).
  • Claim: the two package tests pass on main, and the second fails on a loader-by-path approach: passing on main verified; the other approach was not checked, since it describes different code.
  • Claim: the read-only --check test and the outside-working-directory test pass, and fail on a version that writes the check folder first: passing verified (also on main); the other version was not checked.
  • Claim: no search golden changes: verified (no golden in the patch; the golden tests pass).
  • Claim: the named suites give 813 passing and 2 skipped: 812 pass and 2 skip here; the one other test fails only because it lists files with git in a tree with no git history.
  • Claim: the strict CLI typecheck shows only the two errors main shows when the neutral theme is unbuilt: consistent; it passes with 0 errors once the themes are built.
  • Claim: the release note's account of the build, the compiled-copy check, main's failures and the unchanged --check: verified; the unchanged --check is the finding.
  • File: .changeset/family-build-compiled-registry-check.md: clear.
  • File: packages/cli/api/theme/build/build.mjs: blocking finding at :2717.
  • File: packages/cli/api/theme/build/build.self-contained.test.mjs: clear; no test runs --check on a TypeScript or JSX registry family (part of the finding).
  • File: packages/cli/assets/docs/author-a-theme.doc.mjs: clear.

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 22, 2026
- #13358 fix(cli): a theme family checks its compiled registries as plain Node loads them
  Author: @josephfarina
- #13388 fix(cli): --check reads a theme family's committed compiled registries
  Author: @josephfarina
- #13464 experimental theme: a resting background color, outline or shadow keeps a part's hover and keyboard focus visible
  Author: @josephfarina
- #13433 cli(icons): icon response types say "icon meaning" and "variant"
  Author: @josephfarina
- #13456 feat(templates): dashboard-scorecard shows two headline numbers per row on a phone when they fit
  Author: @josephfarina
- #13473 docs(icons): icon-set guide's relatives line; template icons say icon component
  Author: @josephfarina
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #13542.

@github-actions
github-actions Bot deleted the josephfarina/family-compiled-check branch November 23, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — d901f606 Deployed Nov 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant