Skip to content

Swizzled components emit StyleX source, but no docs explain the required StyleX build/compiler setup (breaks silently; Next.js/SWC has no guidance) #3373

Closed

Description

@josephfarina

Summary

astryx swizzle <Component> copies the component's raw StyleX source into your app. That source requires a build-time StyleX compiler to produce atomic CSS — but nothing in the CLI output or docs tells you this, and there's no framework-specific setup guidance. The result: a freshly swizzled component compiles but renders unstyled, with no error, and it's non-obvious why.

Versions: @astryxdesign/[email protected], @astryxdesign/[email protected]

Repro

npx astryx swizzle Button --output ./components/astryx

The emitted Button/Button.tsx uses StyleX directly:

import * as stylex from '@stylexjs/stylex';
const styles = stylex.create({ /* ... */ });
stylex.keyframes({ /* ... */ });
// ...
stylex.props(styles.base, /* ... */)

Drop <Button> into an app that has no StyleX compiler wired into its build and it renders with no styles — stylex.props() returns nothing usable because stylex.create(...) was never compiled to atomic CSS. No build error, no runtime warning.

The docs gap

astryx docs styling, astryx docs styling-libraries, and astryx docs swizzle all explain how to author StyleX using system tokens (tokens.stylex, colorVars, xstyle, etc.), but none of them mention that:

  1. Consuming swizzled components (or authoring any StyleX) requires a StyleX compiler in your app's build, and
  2. How to actually set that compiler up per framework.

Grepping the docs for babel, swc, next.config, compiler, transform, plugin returns nothing.

Next.js App Router specifically (the painful case)

StyleX's canonical compiler is a Babel plugin (@stylexjs/babel-plugin). In Next.js, introducing a Babel config disables the SWC compiler, which in turn breaks SWC-dependent features like next/font. So the "obvious" StyleX setup is actively incompatible with a standard Next 15 App Router app.

The working path is an SWC-based StyleX transform (e.g. the community @stylexswc/nextjs-plugin), but a first-time user has no way to discover this from Astryx — they hit swizzle → unstyled component → try the babel plugin → break next/font → dead end.

Suggestions

  • Have astryx swizzle print a post-copy note: "These components use StyleX and require a StyleX compiler in your build — see ."
  • Add a docs section (e.g. under swizzle or styling) covering the StyleX build requirement with per-bundler setup: Webpack, Vite, Next.js (SWC vs Babel, and the next/font conflict).
  • Consider warning at build/dev time when StyleX source is present but no compiler is detected.

Context

Discovered while building a themed marketing surface on Astryx in a Next 15 App Router app. Pure theme + defineTheme needs no StyleX compilation, which is great — but the moment you swizzle, you fall off a cliff with no signposting. (Companion type-safety bug filed separately: custom-variant augmentation naming — #3371.)

Activity

  1. self-assigned this
    on Jul 2, 2026
  2. added
    bug
    documentation
    on Jul 2, 2026
  3. added a commit that references this issue on Jul 3, 2026
    702fc54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdocumentation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions