Skip to content

Add icons subpath export for individual icon imports - #48

Open
AKnassa wants to merge 1 commit into
openai:mainfrom
AKnassa:feat/icon-subpath-exports-46
Open

Add icons subpath export for individual icon imports#48
AKnassa wants to merge 1 commit into
openai:mainfrom
AKnassa:feat/icon-subpath-exports-46

Conversation

@AKnassa

@AKnassa AKnassa commented Jul 8, 2026

Copy link
Copy Markdown

What this does

Adds a ./icons/* subpath to the package exports so consumers can import a single icon directly:

import Calendar from "@openai/apps-sdk-ui/icons/Calendar"

instead of pulling in the full components/Icon barrel.

Why

Importing from @openai/apps-sdk-ui/components/Icon resolves the ~745-export barrel, which adds real overhead in tooling like Vite/Vitest even when only a few icons are used (see #46). Each icon is a self-contained, side-effect-free module, so a direct subpath import resolves only what's actually used. Measured in a real installed consumer, a single-icon import took ~8 ms vs ~960 ms for the barrel — roughly 124x faster.

What changed

  • package.json — one new exports entry, "./icons/*", mirroring the existing ./hooks/* wildcard shape (types before default). No build changes: tsc already emits one ESM module and one .d.ts per icon under dist/{es,types}/components/Icon/svg/, and the existing files globs already ship them.
  • Tests (src/components/Icon/Icon.test.tsx) — exports-map shape and condition order, a pre-existing-exports regression guard, svg-dir purity, a case-collision guard, a "no runtime imports" invariant (keeps each icon module barrel-free), a default-export invariant, a barrel↔disk drift guard, and render smoke tests.
  • Docs — a short usage note in Icons.mdx, README.md, and Installation.mdx showing the individual-import form (plus the one naming exception: the Object icon is imported as icons/ObjectIcon).
  • @types/node added to devDependencies — the new test reads the manifest and icon directory via node:fs/node:path/node:url; it was previously only a transitive dependency.

Notes for reviewers

  • This follows the exact proposal in Expose icon subpath exports to avoid loading the full Icon barrel in Vite/Vitest #46. Because it's a wildcard, it also makes importable the ~10 brand icons that exist under svg/ but aren't in the Icon barrel (Instagram, Youtube, etc.). They already ship in dist; if you'd rather keep them out of the public surface, I'm happy to exclude them as a follow-up — just say the word.
  • Two touched files live outside src/ (contrary to the AGENTS.md guideline): package.json, because subpath exports can only be declared there, and README.md, to keep it in sync with its src/Installation.mdx twin.
  • Verified end-to-end from a packed tarball: single-icon import renders, the barrel import still works (backward compatible), missing names reject cleanly, and types resolve under bundler and node16/nodenext. npm run format / lint / types / test all pass.

Closes #46

Expose a `./icons/*` subpath in the package exports so consumers can
import a single icon (`import Calendar from "@openai/apps-sdk-ui/icons/Calendar"`)
instead of the full Icon barrel. Each icon is a self-contained, side-effect-free
module, so tools like Vite and Vitest resolve only the icons in use — measured
~124x faster than importing the barrel in a real consumer.

The build already emits one ESM module and one declaration file per icon, so
this is a package.json exports addition with no build changes. Adds tests
covering the exports shape, the barrel/svg drift guard, per-icon module
invariants, and rendering, plus a short usage note in the icons docs.

Closes openai#46

Claude-Session: https://claude.ai/code/session_0161i4JkZ3RTQVY3XhtdN1hJ
@ellismarkf

Copy link
Copy Markdown

@AKnassa how were you able to open this PR? I was blocked by permissions checks from pushing my branch up to origin. 😞

@AKnassa
AKnassa marked this pull request as ready for review July 8, 2026 22:00
@AKnassa

AKnassa commented Jul 8, 2026

Copy link
Copy Markdown
Author

Hey @ellismarkf 👋 Yeah, direct pushes to openai/apps-sdk-ui are blocked for non-collaborators — that's the permissions wall you hit. The trick is to go through a fork instead, which doesn't need any write access to this repo:

  1. Fork the repo to your own account (the "Fork" button up top, or gh repo fork openai/apps-sdk-ui).
  2. Push your branch to your fork rather than to origin — e.g. git push -u <your-fork-remote> <your-branch>.
  3. Open the PR from your fork into openai:main (gh pr create --repo openai/apps-sdk-ui --head <your-username>:<your-branch>, or just click "Compare & pull request" on your fork).

That cross-repo flow is the standard way to contribute here, so you never touch origin directly. Happy to help if you hit any snags!

@ellismarkf

Copy link
Copy Markdown

@moustafa-openai @tylersmith-openai

Tagging some OpenAI contributors.

Are there any plans to review and merge open PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose icon subpath exports to avoid loading the full Icon barrel in Vite/Vitest

2 participants