Skip to content

fix(cli): mark icon-set generated calls pure so apps drop unused icons - #12441

Closed
josephfarina wants to merge 4 commits into
mainfrom
josephfarina/icon-set-pure-calls
Closed

josephfarina wants to merge 4 commits into
mainfrom
josephfarina/icon-set-pure-calls

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

An app that imports a few icons from an icon set's package also bundles the set's whole theme map, and for a set built with an adapter, every adapted icon in the set. Importing a few dozen icons through a set built from a component library cost about twice what importing the same icons from the library directly costs; through a set built from a data library with an adapter, about ten times. After this change both cost the same as importing the icons directly.

Problem and solution fit

  1. Why: the generated icons module calls functions at its top level (createElement(...) for each theme-map entry, adaptIcon(...) for each adapted icon). A bundler cannot tell those calls have no side effects, so it keeps every one of them, even when the app never reads the theme map or the icon.
  2. Why it harms the task: the icon set is how an app gets its icons, so every app that uses a set pays for icons it does not draw.
  3. Why it matters: a set exists to let a project use some or all of a library's icons; bundling all of them for a few defeats that.

The writer now marks each of those calls /* @__PURE__ */, the annotation bundlers (esbuild, Rollup, webpack's minifier) read as "drop this call when its result is unused". The calls are plain element and component construction, so the mark is true.

Expected behavior and authority

AST-084 FR13: the generated module and its declaration file "are read statement by statement however a formatter left them". A module with the marks is read the same as one without; the marks are dropped when a statement is read, the way comments and formatting are, and added back when the module is written. No record changes.

Smallest restoration

  • foundation/discovery/icon-set-writer.mjs: the written module marks each adapter export and each theme-map element; normalizedStatement drops a mark (/* @__PURE__ */ or /*#__PURE__*/) before anything compares or types a statement, so a module an older CLI wrote reads the same and the next add, map, or refresh only adds the marks. A statement that carried its own mark (one written by hand) is written back with it.
  • The guide's sample line for experimental icon add shows the mark, and says an adapter must only build the component.
  • Tests that pinned the exact written text now expect the mark.

Evidence

  • Reproduction before the change: bundle an app that imports a few icons from a set's package with esbuild (--bundle --minify, React external): the output holds every theme-map element, and for an adapter set every adapted icon.
  • Result after the change: the same bundle holds only the imported icons and is the same size as importing them from the library directly. Spreading themeIcons into a theme still draws every entry, with identical markup.
  • Representative unchanged path: a module written by the current CLI (no marks) reads to the same statements, and rewriting it changes only the marks; the declaration file is unchanged.
  • Regression test or other mutation-sensitive proof: icon-set-writer.test.mjs "generatedModuleText marks its top-level calls pure": every top-level call is marked; a module without marks, with the /*#__PURE__*/ spelling, or with the call moved to its own line by a formatter reads the same and rewrites to the marked text; a hand-written statement keeps its own mark in both spellings, and one without a mark stays unmarked; the declaration file carries no marks.
  • Independent gate: template copies are unchanged for every bundled template, with no set and with each of four real sets; refreshing a set adds only the marks, and a second refresh changes nothing.

Scope

Components: cli (icon sets)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • CI=1 pnpm vitest run packages/cli (full CLI suite).
  • The two hand-written-mark tests in icon-set-writer.test.mjs fail against the writer without the keep-the-mark change (the mark is dropped on rewrite) and pass with it.
  • Regenerated four real icon sets with the patched CLI (experimental icon map round trip): the generated modules differ only by the marks, the declaration files and data files are byte-identical, a second round changes nothing, and astryx integration check --strict passes.
  • Older CLIs: set authors must author and check a set with this release or later. An earlier CLI misreads a module written with the marks: its experimental icon add and map drop the adapter import, its new-set --from refuses, and its integration check and doctor integration validate <set package> fail loudly with icon_generated_types_mismatch. In an app on an earlier CLI (0.7.14 and 0.7.16 tried, as the app's own CLI), template copies with the set's icons, icon search and the default doctor run work as before; validating the set package itself fails until the app moves to this release. The marks change no runtime value. The changeset says so.

@vercel

vercel Bot commented Nov 17, 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 18, 2026 12:32am UTC

Request Review

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

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 1:33 AM UTC

The generated icons module writes each adapter call and theme-map element
with /* @__PURE__ */, and reads modules with or without the mark the same.

@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 pure marks work and shrink app bundles, but two fixes are needed before approval.

  • The changeset says an earlier CLI only fails integration check on a marked set, but an earlier CLI's experimental icon add and map write a generated module without its adapter import (importing the set then throws adaptIcon is not defined) and its new-set --from refuses with ERR_FILE_EXISTS, so the changeset and description should tell set authors to author, not only check, with this release or later.
  • normalizedStatement strips every pure mark but writtenStatement restores it only on adapter exports, so a statement added by hand, such as export const BrandIcon = /* @__PURE__ */ makeBrand('brand');, loses its mark on the next add, map or refresh, where it kept it before; keep each statement's mark when it is written back and add that case to the new test.

Consider warning when the set package's @astryxdesign/cli range admits an earlier CLI, as experimental icon use already does for experimental.iconVariant. The guide could also say that an adapter must only build the component, since the mark lets a bundler drop its call.

Claims and files checked

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

  • Claim: the generated module marks each adapter call and theme-map element. Verified (icon-set-writer.mjs:1816, :1845; new writer test).
  • Claim: a bundler then drops the icons an app does not use; before, it kept the theme map and every adapted icon. Verified: a bundle of an app that imports one icon keeps both adapted icons before the change and drops them after.
  • Claim: modules without marks, or with the /*#__PURE__*/ spelling, read the same. Verified (icon-set-writer.mjs:1404; new it.each cases).
  • Claim: the next add, map or refresh adds the marks and changes nothing else. False for a statement added by hand that carries a mark.
  • Claim: apps on an earlier CLI are unaffected (template copies, search, doctor). Not contradicted: those paths read modules as syntax trees.
  • Claim: only an earlier CLI's integration check fails. False: its add and map write a module that throws on import, and its refresh refuses.
  • Claim: the declaration file is unchanged and has no marks. Verified (new writer test; integration check passes on a set this release wrote).
  • Claim: spreading themeIcons draws every entry with identical markup. Verified: the mark is a comment.
  • Claim: bundles are about two and about ten times smaller. Not re-measured; the mechanism is verified.
  • Claim: no new public API and no spec change, under the icon-set spec's rule that a module is read however it is formatted. Verified.
  • File .changeset/icon-set-pure-calls.md: both findings above.
  • File packages/cli/foundation/discovery/icon-set-writer.mjs: the hand-added mark finding.
  • File packages/cli/foundation/discovery/icon-set-writer.test.mjs: clear; add the hand-statement case.
  • File packages/cli/assets/docs/tree/icon-sets.doc.mjs: clear; it matches what add writes (see the adapter note above).
  • File packages/cli/api/icon/look-theme-maps.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-authoring.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-library-looks.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-look-packages.test.mjs: clear.

Automated review (maintainer link)

Comment thread .changeset/icon-set-pure-calls.md Resolved
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5545e34

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


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 code is ready: hand-written pure marks now survive a rewrite, the changeset warns set authors about earlier CLIs, and the guide states the adapter contract. One fix is left, in the pull request description:

  • The Testing section still says that only an earlier CLI's integration check fails on a marked set and that set authors need only check with this release, but an earlier CLI's experimental icon add and map write the module without its adapter import (so importing the set throws adaptIcon is not defined) and its new-set --from refuses, as the changeset now says; please replace those two sentences with the changeset's wording.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Changeset: each adapter call and theme-map element is marked. Verified (icon-set-writer.mjs:1588-1589, :1862; writer test).
  • Changeset: a bundler then drops unused icons, where before it kept the theme map and every adapted icon. Verified (a minified bundle of an app that imports one icon: 284 bytes before, 92 after).
  • Changeset: modules without marks or with the other spelling read the same, and the next add, map or refresh adds the marks and changes nothing else. Verified (writer tests; the declaration file is unchanged).
  • Changeset: a mark written by hand is kept. Verified (the new tests fail on the previous revision and pass here).
  • Changeset: an earlier CLI's add and map drop the adapter import, its new-set --from refuses, and its integration check reports a types mismatch. Verified (the earlier writer's code and an end-to-end run).
  • Changeset: apps that only use a marked set with an earlier CLI are unaffected. Verified (template copies, icon search and doctor read only import and re-export lines, which carry no mark).
  • Description: unmarked top-level calls keep every adapted icon and the theme map in an app bundle. Verified (same bundle run).
  • Description: bundles about two and ten times smaller on real libraries. Not re-measured; the mechanism is verified.
  • Description: the result costs the same as importing the icons directly. Verified up to the external React import the bundler keeps, which a React icon library carries too.
  • Description: the marks are true because the calls only build elements and components. Verified for createElement; for the adapter it holds when the adapter has no other effect, which the guide now requires.
  • Description: marks are dropped when a statement is read and added back when the module is written, under the icon-set spec's formatter rule, with no record change. Verified.
  • Description: the guide's sample line and the pinned test text show the mark. Verified.
  • Description: spreading the theme map draws every entry with identical markup. Verified: the mark is a comment.
  • Description: the regression tests cover marked calls, three restyled modules and an unmarked declaration file. Verified (the tests pass).
  • Description: template copies are unchanged with four real sets, and a second refresh changes nothing. Not re-run (the sets are not in the repository); idempotence is verified by tests.
  • Description: the full CLI suite and four regenerated sets pass. Not re-run as stated; the 61 icon-related CLI test files pass.
  • Description: in an app on CLI 0.7.14 or 0.7.16, doctor, template copies and icon search work as before. Not re-run on those versions; consistent with the earlier code.
  • Description: no new public API and no internal context. Verified.
  • Description: only an earlier CLI's integration check fails in the set's own package. False (see above).
  • Description: set authors need only check with this release, as the changeset says. False: the changeset says author and check.
  • File .changeset/icon-set-pure-calls.md: clear.
  • File packages/cli/foundation/discovery/icon-set-writer.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-writer.test.mjs: clear.
  • File packages/cli/assets/docs/tree/icon-sets.doc.mjs: clear.
  • File packages/cli/api/icon/look-theme-maps.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-authoring.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-library-looks.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-look-packages.test.mjs: clear.

Automated review (maintainer link)

@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 code is ready, and the description now lists every earlier-CLI failure a set author meets. One claim about apps is still wrong:

  • Miss: the changeset and the description say that apps using a marked set with an earlier CLI are unaffected and pass doctor, but that CLI's astryx doctor integration validate <set package> exits 1 with icon_generated_types_mismatch for an installed marked set that passes with this release (and its fix asks the app team to rewrite a file inside the installed package), so please say that an app running that check needs this release or later, and keep template copies, icon search and plain astryx doctor as the unaffected list.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Changeset: each adapter call and theme-map element is marked. Verified (icon-set-writer.mjs:1588-1589, :1862; writer test).
  • Changeset: a bundler then drops unused icons, where before one icon pulled in the theme map and every adapted icon. Verified (a minified bundle of an app that imports one icon: 284 bytes before, 92 after).
  • Changeset: modules without marks or with the other spelling read the same. Verified (writer test).
  • Changeset: the next add, map or refresh adds the marks, keeps hand-written ones and changes nothing else. Verified (writer tests and a rewrite run; a second rewrite changes nothing).
  • Changeset: set authors author and check with this release or later. Consistent with the earlier-CLI behaviour below.
  • Changeset: an earlier CLI's add and map drop the adapter import, its new-set --from refuses, and its integration check reports a types mismatch. Verified for a set built with an adapter; an earlier add of an adapted icon keeps the import, and in a component-library set an earlier refresh succeeds, so the list errs broad, never narrow.
  • Changeset: apps that only use a marked set with an earlier CLI are unaffected (template copies, icon search, doctor). False for doctor integration validate <set package>; verified for template copies, icon search and plain astryx doctor.
  • Description: unmarked top-level calls keep every adapted icon and the theme map in an app bundle. Verified (same bundle run).
  • Description: bundles about two and ten times larger on real libraries. Not re-measured; the mechanism is verified.
  • Description: after the change, the cost matches importing the icons directly. Verified up to the external React import the bundler keeps.
  • Description: the marks are true because the calls only build elements and components. Verified for createElement; for the adapter when it has no other effect, which the guide now requires.
  • Description: marks are dropped when a statement is read and added back when the module is written, under the icon-set spec's formatter rule, with no record change. Verified.
  • Description: the reader drops either spelling before it compares or types a statement, so older modules read the same and hand-written marks survive. Verified.
  • Description: the guide's sample line shows the mark and states the adapter contract. Verified (icon-sets.doc.mjs:244).
  • Description: tests that pinned the written text now expect the mark. Verified (five test files).
  • Description: before the change a bundle holds every theme-map element and adapted icon; after it holds only the imported icons, and spreading the theme map still draws every entry. Verified (bundle runs; the mark is a comment).
  • Description: a module written by the current CLI reads the same and rewrites with only the marks; the declaration file is unchanged. Verified (writer tests).
  • Description: the regression tests cover marked calls, three restyled modules, hand-written marks and an unmarked declaration file. Verified (they pass).
  • Description: template copies are unchanged with four real sets, and a second refresh changes nothing. Not re-run (the sets are not in the repository); idempotence is verified by tests.
  • Description: the full CLI suite passes, the hand-mark tests fail without the fix, and four regenerated sets pass the strict check. Not re-run as stated; the 56 icon-related CLI test files pass.
  • Description: older CLIs fail add, map, new-set --from and integration check in a marked set's package. Verified for a set built with an adapter, as above.
  • Description: apps on an earlier CLI pass doctor, copy templates and answer icon search as before. False for doctor integration validate <set package>; the rest verified from the earlier code.
  • Description: no new public API and no internal context. Verified.
  • File .changeset/icon-set-pure-calls.md: the app claim above.
  • File packages/cli/foundation/discovery/icon-set-writer.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-writer.test.mjs: clear.
  • File packages/cli/assets/docs/tree/icon-sets.doc.mjs: clear.
  • File packages/cli/api/icon/look-theme-maps.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-authoring.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-library-looks.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-look-packages.test.mjs: clear.

Automated review (maintainer link)

Comment thread .changeset/icon-set-pure-calls.md 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.

Approved pending CI: CI has not run on this head yet, because the CI run stopped at admission with "CI is full", so it needs a re-run before merge.

The changeset and the description now name every earlier-CLI command that misreads a marked set, including doctor integration validate <set package>, so the one finding from the last review is fixed. The marks work as described: on real heroicons artwork, an app drawing 25 icons through a set now bundles what importing them directly costs.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Changeset: each adapter call and theme-map element is marked. Verified (icon-set-writer.mjs:1586-1592, :1862; writer test).
  • Changeset: a bundler then drops unused icons, where before one icon pulled in the theme map and every adapted icon. Verified (bundles of the base and head modules).
  • Changeset: modules without marks or with the other spelling read the same. Verified (writer test).
  • Changeset: the next add, map or refresh adds the marks, keeps hand-written ones and changes nothing else. Verified (writer tests; a refresh of an older set changes only the marks, and a second refresh changes nothing).
  • Changeset: set authors author and check with this release or later. Consistent with the earlier-CLI behavior below.
  • Changeset: an earlier CLI's add and map drop the adapter import, its new-set --from refuses, and its integration check and doctor integration validate report a types mismatch. Verified for a set built with an adapter; the list errs broad, never narrow.
  • Changeset: in an app on an earlier CLI, template copies, icon search and plain doctor read a marked set as before, and validating the set package fails until the app upgrades. Verified (doctor exits 0 and doctor integration validate exits 1 on the earlier CLI, both exit 0 on this release; template copies and icon search read only import and re-export lines).
  • Description: importing a few icons from a set bundled its theme map and, for an adapter set, every adapted icon. Verified.
  • Description: that cost about twice the direct cost through a component-library set and about ten times through an adapter data set. Verified on heroicons artwork: 2.1 times, and 13 times minified (9 times gzip).
  • Description: after the change both cost the same as importing directly. Verified, up to the React import the bundler keeps.
  • Description: the cause is top-level calls a bundler cannot prove free of side effects. Verified.
  • Description: the mark is true because the calls only build elements and components. Verified for createElement; for the adapter when it only builds the component, which the guide now requires.
  • Description: the icon-set spec's formatter rule covers the change, the marks are dropped on read and added on write, and no record changes. Verified.
  • Description: the reader drops either spelling before it compares or types a statement, so older modules read the same and the next write only adds the marks. Verified.
  • Description: a hand-written mark is written back. Verified.
  • Description: the guide's sample line shows the mark and the adapter contract. Verified (icon-sets.doc.mjs:244).
  • Description: tests that pinned the written text expect the mark. Verified (five test files).
  • Description: before the change a bundle holds every theme-map element and adapted icon. Verified.
  • Description: after it the bundle holds only the imported icons at the direct size, and spreading the theme map still draws every entry. Verified.
  • Description: a module the current CLI wrote reads the same and rewrites with only the marks; the declaration file is unchanged. Verified.
  • Description: the regression tests cover marked calls, three restyled modules, hand-written marks and an unmarked declaration file. Verified (they pass).
  • Description: template copies are unchanged with and without sets, a refresh adds only the marks, and a second refresh changes nothing. Verified on a probe set (132 sampled templates byte-identical; refresh run).
  • Description: one defect, no new public API, default or interaction, and no internal context. Verified.
  • Description: the full CLI suite passes. Verified as far as this environment allows: 1,230 of 1,235 files pass, and the three that fail need a git checkout, /proc or the system temp folder and fail the same way without this change.
  • Description: the two hand-mark tests fail without the keep-the-mark change. Verified (red-first run).
  • Description: real sets regenerate with only the marks changed, identical declaration and data files, an idempotent second round and a passing integration check. Verified on probe and heroicons sets; the author's own sets are not public.
  • Description: older CLIs fail add, map, new-set --from, integration check and doctor integration validate on a marked set. Verified for a set built with an adapter.
  • Description: in an app on an earlier CLI, template copies, icon search and plain doctor work, and validating the set package fails until the app upgrades. Verified with the CLI this change replaces; the two older releases named were not re-run.
  • Description: the marks change no runtime value. Verified.
  • File .changeset/icon-set-pure-calls.md: clear (the earlier app claim is fixed).
  • File packages/cli/foundation/discovery/icon-set-writer.mjs: clear.
  • File packages/cli/foundation/discovery/icon-set-writer.test.mjs: clear.
  • File packages/cli/assets/docs/tree/icon-sets.doc.mjs: clear.
  • File packages/cli/api/icon/look-theme-maps.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-authoring.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-library-looks.test.mjs: clear.
  • File packages/cli/clients/cli/commands/icon-look-packages.test.mjs: clear.

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 18, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12252 docs(cli): agent docs name the prop names that differ from other libraries
  Author: Joey Farina <[email protected]>
- #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules
  Author: Joey <[email protected]>
- #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone
  Author: Joey Farina <[email protected]>
- #12316 fix(core): a shorthand never follows its own longhand in one style merge
  Author: josephfarina <[email protected]>
- #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent
  Author: Joey Farina <[email protected]>
- #12349 fix(core): end a mouse drag a sandboxed frame never saw released
  Author: josephfarina <[email protected]>
- #12425 fix(cli): use a stored doc parse only with the zod release that made it
  Author: Joey <[email protected]>
- #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs
  Author: Joey <[email protected]>
- #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label
  Author: Joey Farina <[email protected]>
- #12448 fix(cli): upgrade outside a project names the project, not --from
  Author: Joey Farina <[email protected]>
- #12459 fix(templates): the dashboard scorecard fits a phone screen
  Author: Joey Farina <[email protected]>
- #12428 fix(core): Field labels draw in a bolder face than their description
  Author: Joey Farina <[email protected]>
- #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral
  Author: Joey <[email protected]>
- #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge
  Author: Joey Farina <[email protected]>
- #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons
  Author: Joey Farina <[email protected]>
- #12472 fix(MetadataListItem): a value breaks only a word longer than its line
  Author: Joey <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12718.

@github-actions
github-actions Bot deleted the josephfarina/icon-set-pure-calls branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 5545e345 Deployed Nov 18, 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