Skip to content

fix(build): withAstryx keeps symlink resolution so pnpm's default layout builds - #7773

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-next-pnpm-symlinks
Oct 21, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-next-pnpm-symlinks

Conversation

@vjeux

@vjeux vjeux commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

User impact

An app that follows the documented Next.js source setup and installs with pnpm's default isolated layout fails next build --webpack with Module not found: Can't resolve 'intl-messageformat' (from @astryxdesign/core/src/i18n/resolve.ts) and Can't resolve 'lucide-react' (from @astryxdesign/theme-neutral). npm and pnpm's hoisted layout are not affected.

Problem and solution fit

  • Why it fails: withAstryx() sets webpack's resolve.symlinks = false. pnpm links only the app's direct dependencies into its node_modules, and keeps each package's own dependencies beside the package's real path in its store. Resolving from the unresolved node_modules/@astryxdesign/core/... path searches only the app's node_modules, where those dependencies are not.
  • Why it harms the task: the build stops on dependencies the app never declared.
  • Why that matters: isolated is pnpm's default layout.

Expected behavior and authority

packages/build/README.md documents withAstryx() with no package-manager restriction. The line was added in #2197 for one case: an app in a workspace that links Astryx from packages/*, so that transpilePackages matched it. That case now fails on main the same way, one level deeper: intl-messageformat cannot resolve its own @formatjs/* dependencies.

Smallest restoration

  • Drop resolve.symlinks = false, so webpack resolves symlinks as it does by default.
  • The scoped rule that applies the source condition to Astryx modules also matches each installed package's real directory. A workspace link's real path (packages/core/...) has no node_modules/@astryxdesign/ segment.

Evidence

  • Reproduction before the change: a clean registry install of main's documented example (apps/example-nextjs-source) with pnpm's default layout fails with the two errors above.
  • Result after the change: the same install with this next.js builds and prerenders, and all 226 rendered class names have a rule in the emitted CSS.
  • Representative unchanged path: the existing next.test.mjs cases pass unchanged.
  • Workspace case: with Astryx linked from packages/*, main fails at resolution as above. Without the line the build passes resolution, then runs out of memory in the PostCSS plugin's node_modules/@astryxdesign/** glob, which follows the workspace's symlink cycles: a separate defect in the library glob, fixed separately. No workspace app or CI job uses withAstryx().
  • Regression test or other mutation-sensitive proof: two new next.test.mjs cases fail on main and pass here: a pnpm-style store resolves Core's own dependency from its source, and a workspace link's real path matches the source-condition rule.

Scope

  • 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

  • pnpm exec vitest run --project node packages/build: 5 files, 80 tests pass; the two new next.test.mjs cases fail on main.
  • next build --webpack, clean registry install of the documented example, pnpm's default layout: fails on main as above; builds with this change (226 of 226 rendered classes have a rule).
  • Workspace copy with the example linked to packages/*: main fails at resolution (@formatjs/fast-memoize); this change passes resolution, then hits the separate glob defect.
  • pnpm -F @astryxdesign/core typecheck, Prettier, pnpm check:repo, changeset coverage: pass (ESLint ignores packages/build/src).

…out builds

withAstryx() set webpack's `resolve.symlinks = false`. Under pnpm's
default isolated layout each package's own dependencies sit beside its
real path in the store, so resolving from the symlink path failed with
"Can't resolve 'intl-messageformat'" (Core) and "'lucide-react'" (the
neutral theme).

Leave symlink resolution at webpack's default, and match the scoped
`source`-condition rule against each installed package's real directory
too, so a workspace link (packages/core/...) keeps the condition.
@vercel

vercel Bot commented Oct 20, 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 Oct 20, 2026 11:31pm UTC

Request Review

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

astracat-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 21, 2026, 12:01 AM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

40 of 486 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 20 more.


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

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

This looks ready to merge. With webpack's symlink resolution left on, Core's and the neutral theme's own dependencies resolve from their real paths under pnpm's isolated layout. The two new tests fail on main and pass here, and builds that already worked emit the same CSS.

One optional wording fix. On main, the documented example already compiles through pnpm build: pnpm's .bin/next shim adds node_modules/.pnpm/node_modules to NODE_PATH, and Next appends that to webpack's resolve.modules. The failure only appears when Next starts outside that shim (for example node node_modules/next/dist/bin/next build, or a custom server) or with hoisting turned off, so consider narrowing "builds again under pnpm's default isolated layout" in the Changeset and the description.

[Automated review]

cixzhang pushed a commit that referenced this pull request Oct 21, 2026
…space builds (#7775)

<!-- template: bug-fix.md -->

## User impact

An app that builds Astryx from source with the packages linked from a pnpm workspace (`packages/core` linked into its `node_modules`) cannot finish `next build --webpack`. The PostCSS plugin scans `node_modules/@astryxdesign/**/*.{ts,tsx}`, so it walks everything a linked package carries, not what it publishes:

- its own `node_modules`, whose workspace links cycle (core → its dev dependency `@astryxdesign/cli` → core): in this repository's workspace the build runs out of memory at 4 GB after about eight minutes;
- its unpublished files, such as `@astryxdesign/build`'s test fixtures, one of them invalid on purpose.

## Problem and solution fit

- Why it fails: a workspace link exposes a package's whole directory, while a registry install holds only its `files`; the scan treats both alike.
- Why it harms the task: each level of links multiplies the paths walked and the modules compiled again.
- Why that matters: linking is how an app builds against a local Astryx checkout.

## Expected behavior and authority

`spec:AST-080` FR7 (current) requires a source build to produce the rules of the package's modules; this one never completes. A package's `files` field defines what it publishes; #7754 likewise keeps `node_modules` out of its Turbopack globs.

## Smallest restoration

The library scan lists `node_modules/@astryxdesign/*` once per real directory and reads each package's `files`: a directory brings the `.ts`/`.tsx` files below it, a file itself,, and a glob or `!` entry fails the build, naming the package and entry, rather than approximating `npm pack` (no Astryx package lists one). Without `files`, the whole package minus nested `node_modules`.

## Evidence

- Reproduction before the change: `apps/example-nextjs-source` added to this workspace (Astryx linked from `packages/*`), with #7773 applied, runs out of memory as above.
- Result after the change: the same build completes and prerenders, and all 226 rendered class names have a rule. The workspace scan is the 1,317 files a registry install holds.
- Representative unchanged path: on registry installs of the documented example the scanned list is identical: 1,317 files isolated, 1,317 hoisted, 1,562 hoisted with Lab.
- Regression test or other mutation-sensitive proof: `postcss.workspace-links.test.mjs` builds a workspace whose links cycle. On main two cases compile 60 files each, fixtures included; here only the published module, or a `files`-less package's source. Two more expect a glob and a `!` entry to be refused.

## Scope

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- `pnpm exec vitest run --project node packages/build`: 6 files, 82 tests pass; every `postcss.workspace-links.test.mjs` case fails on main.
- Scanned-file parity on fresh registry installs, re-run on this head: identical lists (1,317 / 1,317 / 1,562).
- `next build --webpack` in the workspace copy with #7773 and this change: completes (226 of 226 rendered classes have a rule); with #7773 alone it runs out of memory.
- `pnpm -F @astryxdesign/core typecheck`, Prettier, `pnpm check:repo`, changeset coverage: pass (ESLint ignores `packages/build/src`).
@cixzhang
cixzhang merged commit 3f837b3 into meta:main Oct 21, 2026
50 checks passed
@vjeux
vjeux deleted the build-next-pnpm-symlinks branch October 21, 2026 14:31

This branch was successfully deployed

1 active deployment
Preview — 0a82ff46 Deployed Oct 20, 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