Skip to content

fix(themes): add tsup build to produce proper JS/TS module output - #541

Merged
cixzhang merged 1 commit into
mainfrom
navi/fix/theme-package-builds
Mar 8, 2026
Merged

fix(themes): add tsup build to produce proper JS/TS module output#541
cixzhang merged 1 commit into
mainfrom
navi/fix/theme-package-builds

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Theme packages (@xds/theme-default, @xds/theme-neutral, @xds/theme-brutalist) only ran xds build-theme which produces CSS and theme-named JS files (e.g. default.js, neutral.js). But package.json exports point to index.js/index.mjs/index.d.ts which didn't exist.

The v0.0.2 release manually patched package.json to point to default.js/neutral.js, but the underlying build was still broken — those files reference ./icons which doesn't exist in dist/.

Fix

Each theme package now runs both build steps:

  1. xds build-theme — produces theme.css (the CSS custom properties)
  2. tsup — compiles src/index.ts to proper CJS/ESM/DTS output

Changes

  • Added tsup.config.ts to each theme package (default, neutral, brutalist)

    • Entry: src/index.ts
    • Formats: CJS + ESM
    • DTS generation enabled
    • clean: false to preserve theme.css from the prior build step
    • External: @xds/core, @stylexjs/stylex, react, and theme-specific icon libraries
  • Updated build scripts to chain both commands and clean up stale artifacts:

    xds build-theme src/defaultTheme.ts -o dist/theme.css && tsup && rm -f dist/default.js dist/default.d.ts
    
  • Fixed brutalist package.json — was pointing main/types/exports at ./src/index.ts instead of dist/ output

  • Fixed exports condition orderingtypes now comes before import/require (matches @xds/core convention, avoids esbuild warnings)

Output

Each theme now produces:

dist/
  index.js      # CJS
  index.mjs     # ESM
  index.d.ts    # TypeScript declarations
  index.d.mts   # TypeScript declarations (ESM)
  theme.css     # CSS custom properties

Verification

  • yarn build ✅ — all packages build successfully
  • yarn test ✅ — 89 test files, 1428 tests pass
  • yarn lint ✅ — 0 errors (pre-existing warnings only)
  • All theme dist/ directories contain the expected files
  • No stale default.js/neutral.js/brutalist.js artifacts remain

Theme packages only ran `xds build-theme` which produces CSS and
theme-named JS files (e.g. default.js, neutral.js). But package.json
exports point to index.js/index.mjs/index.d.ts which didn't exist.

Changes:
- Add tsup.config.ts to each theme package (default, neutral, brutalist)
- Update build scripts to run both `xds build-theme` (CSS) and `tsup` (JS/TS modules)
- Clean up stale theme-named JS/DTS files after build
- Fix brutalist package.json exports to use dist/ instead of src/
- Fix exports condition ordering: types before import/require

Each theme now produces:
  dist/index.js     (CJS)
  dist/index.mjs    (ESM)
  dist/index.d.ts   (types)
  dist/index.d.mts  (types)
  dist/theme.css    (CSS theme)

Co-authored-by: Navi <navi@navibot.dev>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 8, 2026
@github-actions

github-actions Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 9.1KB 14.7KB 2.3KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 8b0ead8 into main Mar 8, 2026
14 checks passed
@cixzhang
cixzhang deleted the navi/fix/theme-package-builds branch March 13, 2026 10:51
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