Repository navigation
fix(build): withAstryx keeps symlink resolution so pnpm's default layout builds - #7773
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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]
…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`).
User impact
An app that follows the documented Next.js source setup and installs with pnpm's default isolated layout fails
next build --webpackwithModule not found: Can't resolve 'intl-messageformat'(from@astryxdesign/core/src/i18n/resolve.ts) andCan't resolve 'lucide-react'(from@astryxdesign/theme-neutral). npm and pnpm's hoisted layout are not affected.Problem and solution fit
withAstryx()sets webpack'sresolve.symlinks = false. pnpm links only the app's direct dependencies into itsnode_modules, and keeps each package's own dependencies beside the package's real path in its store. Resolving from the unresolvednode_modules/@astryxdesign/core/...path searches only the app'snode_modules, where those dependencies are not.Expected behavior and authority
packages/build/README.mddocumentswithAstryx()with no package-manager restriction. The line was added in #2197 for one case: an app in a workspace that links Astryx frompackages/*, so thattranspilePackagesmatched it. That case now fails on main the same way, one level deeper:intl-messageformatcannot resolve its own@formatjs/*dependencies.Smallest restoration
resolve.symlinks = false, so webpack resolves symlinks as it does by default.sourcecondition to Astryx modules also matches each installed package's real directory. A workspace link's real path (packages/core/...) has nonode_modules/@astryxdesign/segment.Evidence
apps/example-nextjs-source) with pnpm's default layout fails with the two errors above.next.jsbuilds and prerenders, and all 226 rendered class names have a rule in the emitted CSS.next.test.mjscases pass unchanged.packages/*, main fails at resolution as above. Without the line the build passes resolution, then runs out of memory in the PostCSS plugin'snode_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 useswithAstryx().next.test.mjscases 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 thesource-condition rule.Scope
Testing
pnpm exec vitest run --project node packages/build: 5 files, 80 tests pass; the two newnext.test.mjscases 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).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 ignorespackages/build/src).