Skip to content

fix(core): bundle StyleX runtime — remove consumer dependency - #545

Merged
cixzhang merged 2 commits into
mainfrom
navi/fix/bundle-stylex-runtime
Mar 9, 2026
Merged

fix(core): bundle StyleX runtime — remove consumer dependency#545
cixzhang merged 2 commits into
mainfrom
navi/fix/bundle-stylex-runtime

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

What

Bundle the StyleX runtime (styleq, ~5KB) into @xds/core dist so consumers don't need to install @stylexjs/stylex.

Why

The compiled output only calls stylex.props() at runtime — which is just styleq (a deduplicating class name merger). There's no reason to leak this as a consumer dependency. It blocks CDN/script-tag usage and adds friction for anyone who doesn't use StyleX in their own build.

Changes

packages/core/tsup.config.ts

  • Add noExternal: ['@stylexjs/stylex', 'styleq'] to bundle the runtime into dist

packages/core/package.json

  • Move @stylexjs/stylex from dependenciesdevDependencies (still needed at build time for the Babel plugin)

packages/themes/*/tsup.config.ts

  • Remove stale @stylexjs/stylex from externals — theme packages don't import it anymore (they use defineTheme from @xds/core)

Impact

  • ESM: +5.2KB (inlined styleq runtime)
  • CJS: -10.7KB (esbuild optimizes better without the external boundary)
  • Net: -5.5KB total — bundle actually got smaller
  • Zero external @stylexjs/stylex imports in dist
  • React remains the only peer dependency

cixzhang and others added 2 commits March 9, 2026 01:16
…eeded

Bundle @stylexjs/stylex and styleq into the @xds/core dist output
instead of requiring consumers to install them separately.

The compiled output only uses stylex.props() at runtime, which is
just styleq (a ~5KB deduplicating class name merger). By inlining it:

- Consumers no longer need @stylexjs/stylex as a dependency
- CDN/script-tag usage works without shimming the StyleX runtime
- Net bundle size actually decreased by ~5KB (esbuild optimizes
  better without the external boundary)

Moves @stylexjs/stylex from dependencies to devDependencies since
it's still needed at build time (Babel plugin) but no longer at runtime.

Co-authored-by: Navi <navi@navibot.dev>
Theme packages no longer import @stylexjs/stylex — they use
defineTheme from @xds/core instead. Remove the dead external
declaration from all three theme tsup configs.

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 9, 2026
@github-actions

github-actions Bot commented Mar 9, 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 f44287a into main Mar 9, 2026
14 checks passed
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