Skip to content

build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) - #3691

Closed
imdreamrunner wants to merge 1 commit into
mainfrom
fix/stylex-runtime-yarn
Closed

imdreamrunner wants to merge 1 commit into
mainfrom
fix/stylex-runtime-yarn

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

@astryxdesign/core currently declares @stylexjs/stylex as peer-only (since #3313, released in
0.1.3 / 0.1.4). This PR also declares it in dependencies (keeping the peer) — the "combo":

   "peerDependencies": {
     "@stylexjs/stylex": "^0.18.3",
     "react": ">=19.0.0",
     "react-dom": ">=19.0.0"
   },
+  "dependencies": {
+    "@stylexjs/stylex": "^0.18.3"
+  },

Whether to add it is a genuine trade-off. This PR takes the support-Yarn side; the alternative (keep
peer-only) is equally coherent if the priorities differ.

The trade-off

Option A — keep peer-only (don't merge this): the npm-style, strict-single-runtime choice.

  • Values a strict single shared runtime: an incompatible StyleX version is blocked at install
    (npm ERESOLVE), never silently duplicated.
  • Relies on the package manager auto-installing the peer — which npm 7+, Bun, and pnpm ≥8.4 do.
    pnpm ≤8.0 and all of 7.x default auto-install-peers to false, so peer-only leaves the runtime
    absent there too — the failure mode isn't Yarn-exclusive.
  • Cost: Yarn (1 and Berry) does not auto-install peers, so the runtime is absent on Yarn → a
    hard render crash (every astryx component calls stylex.props()).

Option B — also declare it in dependencies (this PR): the support-Yarn choice.

  • Guarantees the runtime is present on every package manager, including Yarn.
  • Keeps the peer range, so an incompatible version is still flagged on pnpm, Yarn, and older npm.
  • Cost: on npm 7–11 and Bun, the dependencies entry self-satisfies the peer, so an incompatible
    version is silent (a nested 2nd copy; our components run their own compatible copy).

How to choose: if the consumer base were npm / pnpm / Bun and you value the strict single-runtime
guarantee, keep peer-only (A). Because the astryx consumer base is predominantly Yarn — where
peer-only leaves the runtime absent — this PR chooses B.

Behavior by package-manager version (verified)

1. Consumer authors no StyleX — is the runtime present?

🟢 present · 🔴 absent (runtime missing → hard render crash). Peer-only presence tracks whether the
manager auto-installs peers; the combo is always present.

Package manager peer-only combo (this PR)
npm 6.14 🔴 absent 🟢 present
npm 7.24 🟢 present 🟢 present
npm 8.19 🟢 present 🟢 present
npm 9.9 🟢 present 🟢 present
npm 10.9 🟢 present 🟢 present
npm 11.13 🟢 present 🟢 present
pnpm 7.x – 8.0 🔴 absent¹ 🟢 present
pnpm 8.4 – 11.13 🟢 present 🟢 present
Bun 1.3.14 🟢 present 🟢 present
Yarn 1.22 🔴 absent 🟢 present
Yarn Berry 4.9 🔴 absent 🟢 present

¹ auto-install-peers (added in pnpm 7.0.0) defaulted to false until the 8.x line, where it flipped
to true. Verified locally on Node 22: peer absent on 7.12.1 / 7.13.0 / 8.0.0, present from
8.4.0 through 11.13.0. So on older pnpm, peer-only crashes exactly like Yarn.

2. Consumer pins an incompatible StyleX version (out of range)

🟢 caught (install blocked) · 🟡 warned · 🔴 silent (no signal). "runs own" = our components resolve
their own nested compatible copy (2 copies total); "runs theirs" = single shared copy at the consumer's
(out-of-range) version.

Package manager peer-only combo (this PR)
npm 6.14 🟡 warns; runs theirs (1 copy) 🟡 warns; runs own (2 copies)
npm 7.24 🟢 blocked (ERESOLVE) 🔴 silent; runs own (2 copies)
npm 8.19 🟢 blocked (ERESOLVE) 🔴 silent; runs own (2 copies)
npm 9.9 🟢 blocked (ERESOLVE) 🔴 silent; runs own (2 copies)
npm 10.9 🟢 blocked (ERESOLVE) 🔴 silent; runs own (2 copies)
npm 11.13 🟢 blocked (ERESOLVE) 🔴 silent; runs own (2 copies)
pnpm 10.22 🟡 warns; runs theirs (1 copy) 🟡 warns; runs theirs (1 copy)
Bun 1.3.14 🟡 warns; runs theirs (1 copy) 🔴 silent; runs own (2 copies)
Yarn 1.22 🟡 warns; runs theirs (1 copy) 🟡 warns; runs own (2 copies)
Yarn Berry 4.9 🟡 warns; runs theirs (1 copy) 🟡 warns; runs theirs (1 copy)

On npm 7–11 the combo is fully silent — no install warning, and npm ls reports a valid tree, so the
incompatibility is invisible to npm tooling.

3. Consumer pins a compatible StyleX version

Both methods, every manager → one shared copy = the consumer's install (same realpath, browser +
Node). Verified on npm, pnpm, Bun, Yarn 1, Yarn 4.

Edge case: Yarn 1 only leaves 2 copies if the consumer pins an exact, older-but-compatible
version (e.g. 0.18.1 while 0.18.3 is latest) — its classic hoister resolves our range to latest
independently. npm, pnpm, Bun, and Yarn 4 dedupe even that. Benign for XDS regardless (props() is
pure).

pnpm presence is version- and config-dependent

The pnpm "present" result above is not a property of pnpm — it's the current default of
auto-install-peers, and it's consumer-overridable:

  • Config knob: setting autoInstallPeers: false makes peer-only absent again (verified on pnpm
    11.13.0 — runtime absent + a peer-deps warning). So even on modern pnpm, a consumer can opt back into
    the missing-runtime crash. The combo (this PR) is present regardless of this setting.
  • Config location moved: in pnpm 10+ this lives in pnpm-workspace.yaml (autoInstallPeers: false). Legacy .npmrc (auto-install-peers=false) and the npm_config_auto_install_peers env var
    are silently ignored by pnpm 11 — verified.
  • Strict flag affects table Implement Fractal Documentation Standard across codebase #2: the pnpm "🟡 warns" cells for an incompatible version are the
    strict-peer-dependencies=false default; a consumer with strict-peer-dependencies=true gets a hard
    block instead.

Net: peer-only's "single shared runtime" guarantee on pnpm depends on both a version default and two
consumer-flippable settings — another point in favor of the combo.

Recommendation

Declare @stylexjs/stylex in both peerDependencies and dependencies — keep the peer (version
guardrail) and add it to dependencies (runtime guarantee), i.e. ship this PR.

Why:

  • It fixes a hard crash. Yarn 1/Berry and pnpm ≤8.0 don't auto-install peers, so peer-only leaves
    the runtime absent → every component crashes on stylex.props(). Adding it to dependencies
    guarantees it's present on every package manager.
  • The cost: on npm 7–11 and Bun, an incompatible consumer-pinned StyleX version no longer errors at
    install — it installs silently (no ERESOLVE, no warning, a clean npm ls) and our components run a
    second nested copy. We lose npm's strict single-runtime block on those managers.
  • Where it's contained: that loss is npm/Bun-only. The peer range still flags mismatches on pnpm,
    Yarn, and npm 6, and on pnpm an incompatible version can still fail the install via
    strict-peer-dependencies=true (verified on 11.13.0).

Net: we trade npm/Bun's install-time block on incompatible versions for a runtime that's guaranteed
present everywhere. For a mostly-Yarn consumer base — where peer-only is a guaranteed crash — that's the
right call.

Test plan

  • pnpm install → @stylexjs/[email protected] resolved; pnpm -F @astryxdesign/core build → green
    (babel ESM + tsc declarations + StyleX CSS + UMD).
  • Verified installs across npm 6–11, pnpm 10.22, Yarn 1.22, Yarn Berry 4.9.2, and Bun 1.3.14 — the
    three tables above.
  • Verified pnpm version/config matrix on Node 22: auto-install-peers default is false on pnpm
    7.12–8.0 (runtime absent, like Yarn) and true from 8.4 onward; autoInstallPeers: false in
    pnpm-workspace.yaml reproduces the absent runtime on pnpm 11.13.0.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: astryx.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 8, 2026
@imdreamrunner
imdreamrunner marked this pull request as ready for review July 8, 2026 15:28
@github-actions

github-actions Bot commented Jul 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
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: No accessibility violations detected.


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

github-actions Bot added a commit that referenced this pull request Jul 8, 2026
@imdreamrunner imdreamrunner changed the title build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] Jul 9, 2026
@imdreamrunner imdreamrunner changed the title build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] [DO_NOT_MERGE] build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] Jul 9, 2026
@imdreamrunner
imdreamrunner force-pushed the fix/stylex-runtime-yarn branch from 66c5453 to 91559d0 Compare July 28, 2026 18:32
@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 29, 2026 5:49pm

Request Review

github-actions Bot added a commit that referenced this pull request Jul 28, 2026
@imdreamrunner imdreamrunner changed the title [DO_NOT_MERGE] build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] Jul 29, 2026
@imdreamrunner imdreamrunner changed the title build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) [DO_NOT_MERGE] build(core): re-add @stylexjs/stylex to dependencies (Yarn runtime presence) Jul 29, 2026
Comment thread packages/core/package.json Resolved
Follow-up to #3313, which moved @stylexjs/stylex to a peer-only
declaration. Consumer research shows the astryx base predominantly uses
Yarn, and neither Yarn 1 nor Yarn Berry auto-installs peer dependencies
(verified) — so peer-only leaves the StyleX runtime ABSENT for those
consumers, a hard render failure since every component calls
stylex.props().

Declare @stylexjs/stylex in BOTH dependencies and peerDependencies
(^0.18.3): dependencies guarantees the runtime is present on every
package manager (incl. Yarn 1/Berry); peerDependencies keeps the version
guardrail and dedupes a StyleX-authoring consumer to a single shared
runtime (browser + Node).

Test plan:
- pnpm install + pnpm -F @astryxdesign/core build: green.
- Verified: peer-only leaves the runtime absent on Yarn 1 and Yarn Berry
  4.9.2 (warning only); adding dependencies restores presence.
@imdreamrunner

Copy link
Copy Markdown
Contributor Author

We decided to not go with this approach and I will create a separate PR to update the docs.

For context:

  • Decision: The team opted against the dual-dependency approach to avoid silent failures and potential version conflicts [8, 13, 14].
  • Documentation: The "Getting Started" documentation will be updated to explicitly instruct users to install @stylexjs/stylex, ensuring a clearer setup process [4, 39].
  • Diagnostics: A doctor command will be investigated to help users identify and troubleshoot missing or mismatched dependencies [32, 39].
  • Context: These measures address external users on legacy package managers, as internal workflows are migrating to stricter, modern standards that handle these dependencies more effectively [21, 33].

@github-actions
github-actions Bot deleted the fix/stylex-runtime-yarn branch July 30, 2026 06:57

This branch was successfully deployed

1 active deployment
Preview — 5bf31037 Deployed Jul 29, 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.

2 participants