Skip to content

docs(cli): name the StyleX plugin that works under Vite - #12893

Closed
josephfarina wants to merge 1 commit into
mainfrom
josephfarina/vite-stylex-plugin-doc
Closed

josephfarina wants to merge 1 commit into
mainfrom
josephfarina/vite-stylex-plugin-doc

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

User impact

In a new Vite React app on the default prebuilt-CSS path (reset.css + astryx.css, no build plugin), a page template that uses StyleX (for example kanban-board or table-inbox) renders a blank page with Unexpected 'stylex.create' call at runtime. The template note says to add a StyleX compiler plugin and points to astryx docs styling-overview. For Vite, that doc names @stylexjs/rollup-plugin. A user who follows it gets a dev server error on every page, so the page is still blank.

Problem and solution fit

  • Why is the page blank? The template calls stylex.create() in the app's own code, and nothing compiles it.
  • Why does the documented fix not help? Under Vite, @stylexjs/rollup-plugin also receives CSS imports. It parses @astryxdesign/core/astryx.css as JavaScript and fails (Support for the experimental syntax 'decorators' isn't currently enabled), so the module graph does not load. It also writes its CSS only at bundle time, so the dev server gets none of it.
  • Why does that matter? The doc and the note are the only guidance the CLI gives for this error, so a user who follows them exactly cannot get the template to render.

StyleX's own Vite integration, @stylexjs/unplugin (stylex.vite()), compiles the template and serves its CSS in dev and in a build. The docs now name it for Vite, and keep @stylexjs/rollup-plugin for Rollup.

Expected behavior and authority

spec:AST-048 FR20: a template's notes say that the project needs a StyleX compiler and name the docs that set one up. spec:AST-080 FR5: the path for a product that compiles its own StyleX keeps loading the prebuilt stylesheets. With @stylexjs/rollup-plugin under Vite, that path cannot load astryx.css; with @stylexjs/unplugin, it can.

Smallest restoration

  • styling-overview ("StyleX for your own code"): the Vite / Rollup row becomes a Vite row (@stylexjs/unplugin, stylex.vite() in vite.config, and that the Rollup plugin fails on astryx.css under Vite) and a Rollup row (@stylexjs/rollup-plugin).
  • styling/tokens-and-setup ("StyleX Build Setup"): the same split.
  • The template note points to the section itself: astryx docs styling-overview stylex-own-code. The notes array of strings in --json keeps its shape.

No template, command, or JSON field changes.

Evidence

All in a fresh Vite react-ts app outside the repository, with the 0.7.17 CLI and Core packs, checked in headless Chromium:

  • Reproduction before the change: astryx template kanban-board src/kanban and table-inbox src/inbox, rendered with reset.css + astryx.css: both pages have an empty root and throw Unexpected 'stylex.create' call at runtime.
  • Following the current doc (@stylexjs/rollup-plugin in vite.config): the dev server returns 500 for the entry, with the astryx.css parse error above; vite build fails with the same error.
  • Result after the change (npm install -D @stylexjs/unplugin, plugins: [stylex.vite(), react()]): both pages render fully with no console errors, in the dev server and in vite build + vite preview, with and without a theme stylesheet.
  • Representative unchanged path: the other rows (Webpack, Babel, Next.js) and the plain and Tailwind paths are unchanged.
  • Regression test: the existing template-needs test still checks that the note names styling-overview. The styling-overview table gains a row, so the docs-topics golden's skeleton digest for that topic is updated (one line).

Scope

Components: packages/cli (docs, template notes)

  • 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 exec vitest run --project node --changed origin/main
  • astryx docs styling-overview stylex-own-code and astryx docs styling/tokens-and-setup stylex-setup read back the new rows.
  • Headless Chromium render of both templates in a fresh Vite app, as above.

preflight: pass 90a1dfb

@vercel

vercel Bot commented Nov 19, 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 19, 2026 9:10pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 9:18 PM UTC

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

@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.

The Vite rows now name a StyleX compiler that only transforms script modules, so a StyleX page template compiles with astryx.css still loaded, and the template note lands on the plugin table. There are no blocking findings.

  • The head commit's message ends with [skip ci], which stops GitHub from starting this pull request's CI at this head even after it is marked ready; push a commit without it so the required checks run here.
Claims and files checked

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

  • Claim: the StyleX setup docs name @stylexjs/unplugin (stylex.vite()) for Vite and keep @stylexjs/rollup-plugin for Rollup: verified (styling-overview.doc.mjs:151-155, tokens-and-setup.doc.mjs:89-91; both doc sections print the new rows).
  • Claim: under Vite, the Rollup plugin fails on astryx.css: verified by mechanism; its transform runs Babel on any module whose text contains stylex, with no file-type filter, and the published stylesheet contains stylex and opens with an @layer rule.
  • Claim: the Rollup plugin writes its CSS only at bundle time, so the dev server gets none: verified (generateBundle is its only CSS output).
  • Claim: @stylexjs/unplugin compiles the template and serves its CSS in dev and in a build: verified from its source (script modules only; dev CSS injected into the page by default).
  • Claim: a page template that uses StyleX stayed blank, and renders after the change: stated by the author from a fresh Vite app; consistent with the mechanism above, not rerun.
  • Claim: the template note points to the setup section, and notes keeps its shape: verified (template-needs.mjs:480; the note is still one string).
  • Claim: no template, command or JSON field changes, and the Webpack, Babel, Next.js, plain and Tailwind paths are unchanged: verified from the diff.
  • Claim: the existing template-needs test still checks that the note names styling-overview: verified (template-needs.test.mjs:261-274, passing).
  • Claim: public text carries no internal context: verified.
  • File .changeset/vite-stylex-plugin-doc.md: clear.
  • File packages/cli/assets/docs/styling-overview.doc.mjs: clear.
  • File packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs: clear.
  • File packages/cli/foundation/discovery/template-needs.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.

Approved pending CI: CI has not run on this head yet.

The Vite rows now name a StyleX compiler that transforms only script modules, so a StyleX page template compiles with astryx.css still loaded; the template note lands on the plugin table, and the docs-topics golden matches the new table. There are no blocking findings.

  • The head commit's message ends with [skip ci], which keeps GitHub from starting this pull request's CI at this head even after it is marked ready; push a commit without it so the required checks run here.
Claims and files checked

Review mode: full; reason: history

  • Claim (description): before the change, the template note points to the whole styling overview, and that doc names the Rollup plugin for Vite: verified (the base's note and doc output).
  • Claim (changeset, description): the StyleX setup docs name @stylexjs/unplugin (stylex.vite()) for Vite and keep @stylexjs/rollup-plugin for Rollup: verified (styling-overview.doc.mjs:151-155, tokens-and-setup.doc.mjs:90-91; both doc sections print the new rows).
  • Claim (changeset, description): under Vite, the Rollup plugin parses astryx.css and fails: verified by mechanism; its transform runs Babel on any module whose text contains stylex, with no file-type filter, and the published stylesheet contains stylex and opens with an @layer rule. The exact error text was not rerun.
  • Claim (description): the Rollup plugin writes its CSS only at bundle time, so the dev server gets none: verified (generateBundle is its only CSS output).
  • Claim (description): @stylexjs/unplugin compiles the template and serves its CSS in dev and in a build: verified from its source (script and Svelte modules only; dev CSS injected into the page by default).
  • Claim (changeset, description): a StyleX page template stayed blank, and renders after the change: stated by the author from a fresh Vite app; consistent with the mechanism above, not rerun.
  • Claim (changeset, description): the template note points to the setup section, and notes keeps its shape: verified (template-needs.mjs:480; the note is still one string).
  • Claim (description): no template, command or JSON field changes, and the Webpack, Babel, Next.js, plain and Tailwind paths are unchanged: verified from the diff.
  • Claim (description): the existing template-needs test still checks that the note names styling-overview: verified (template-needs.test.mjs:261-274, passing).
  • Claim (description): the docs-topics golden's digest for the styling overview changes in one line: verified (the docs-topics test passes at this head and leaves the file unchanged).
  • Claim (description): the template-notes and package-stylesheet requirements it cites govern the change: verified against the current records.
  • Claim (description): public text carries no internal context: verified.
  • File .changeset/vite-stylex-plugin-doc.md: clear.
  • File packages/cli/assets/docs/styling-overview.doc.mjs: clear.
  • File packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs: clear.
  • File packages/cli/foundation/discovery/template-needs.mjs: clear.
  • File packages/cli/test/__golden__/no-icon-set/docs-topics.json: clear.

Automated review (maintainer link)

@josephfarina
josephfarina marked this pull request as ready for review November 19, 2026 13:32
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
A page template that uses StyleX needs a StyleX compiler. The setup
docs named @stylexjs/rollup-plugin for Vite, but under Vite it also
reads CSS imports and fails on astryx.css, so the page stayed blank.
The docs now name @stylexjs/unplugin (stylex.vite()) for Vite, and the
template note points to the setup section.

[skip ci]
@josephfarina
josephfarina force-pushed the josephfarina/vite-stylex-plugin-doc branch from 90a1dfb to 616cf7a Compare November 19, 2026 20:57
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 616cf7a

@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.

The Vite rows now name a StyleX compiler that transforms only script modules, so a StyleX page template compiles with astryx.css still loaded; the template note lands on the plugin table, and the docs-topics golden matches the new table. There are no blocking findings.

  • The head commit's message carries [skip ci], so GitHub has not started this pull request's CI on this head; the required checks still need to pass before it merges.
Claims and files checked

Review mode: full; reason: rebase

  • Claim (description): before the change, the template note points to the whole styling overview, and that doc names the Rollup plugin for Vite: verified (the base's note and doc output).
  • Claim (changeset, description): the StyleX setup docs name @stylexjs/unplugin (stylex.vite()) for Vite and keep @stylexjs/rollup-plugin for Rollup: verified (styling-overview.doc.mjs:151-155, tokens-and-setup.doc.mjs:90-91; both doc sections print the new rows).
  • Claim (changeset, description): under Vite, the Rollup plugin parses astryx.css and fails: verified; a Vite build of a fresh page that imports the published stylesheet fails in the Rollup plugin with the decorators error at its @layer line, because its transform runs Babel on any module whose text contains stylex, with no file-type filter.
  • Claim (description): the Rollup plugin writes its CSS only at bundle time, so the dev server gets none: verified (generateBundle is its only CSS output).
  • Claim (description): @stylexjs/unplugin compiles the template and serves its CSS in dev and in a build: verified for the build (the same page builds and its StyleX rules land in the stylesheet) and from its source for dev (script and Svelte modules only; dev CSS injected into the page by default).
  • Claim (changeset, description): a StyleX page template stayed blank, and renders after the change: stated by the author from a fresh Vite app; consistent with the build result above, the browser render was not rerun.
  • Claim (changeset, description): the template note points to the setup section, and notes keeps its shape: verified (template-needs.mjs:480; the note is still one string).
  • Claim (description): no template, command or JSON field changes, and the Webpack, Babel, Next.js, plain and Tailwind paths are unchanged: verified from the diff.
  • Claim (description): the existing template-needs test still checks that the note names styling-overview: verified (template-needs.test.mjs:261-274, passing).
  • Claim (description): the docs-topics golden's digest for the styling overview changes in one line: verified (the docs-topics test passes at this head and leaves the file unchanged).
  • Claim (description): the template-notes and package-stylesheet requirements it cites govern the change: verified against the current records.
  • Claim (description): public text carries no internal context: verified.
  • File .changeset/vite-stylex-plugin-doc.md: clear.
  • File packages/cli/assets/docs/styling-overview.doc.mjs: clear.
  • File packages/cli/assets/docs/tree/tokens-and-setup.doc.mjs: clear.
  • File packages/cli/foundation/discovery/template-needs.mjs: clear.
  • File packages/cli/test/__golden__/no-icon-set/docs-topics.json: clear.

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 20, 2026
josephfarina added a commit that referenced this pull request Nov 20, 2026
- #12407 fix(cli): theme palette generate names a newer CLI's recipe and the update step
  Author: @josephfarina
- #12729 fix(cli): a padding of two to four lengths where only one works offers its sides
  Author: @josephfarina
- #12893 docs(cli): name the StyleX plugin that works under Vite
  Author: @josephfarina
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #13025.

@github-actions
github-actions Bot deleted the josephfarina/vite-stylex-plugin-doc branch November 20, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 616cf7af Deployed Nov 19, 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