Skip to content

chore(deps): make node_modules strict, declare what each package imports - #5327

Merged
cixzhang merged 7 commits into
meta:mainfrom
sangwook-dev:chore/drop-node-linker-hoisted
Sep 14, 2026
Merged

cixzhang merged 7 commits into
meta:mainfrom
sangwook-dev:chore/drop-node-linker-hoisted

Conversation

@sangwook-dev

@sangwook-dev sangwook-dev commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5328

What

Removes both hoisting settings from pnpm-workspace.yaml and declares the dependencies that were only resolving because of them. linkWorkspacePackages: true stays.

Rebased onto current main. That brought in code which relies on the hoisted layout, so a second commit fixes it — see After the rebase.

Why

Both lines came over verbatim from the pre-pnpm-11 .npmrc (#3700).

nodeLinker: hoisted was annotated there as "Use the Node-modules linker (default), not pnpm's PnP." That is wrong on its own terms — pnpm's default is the node-modules linker, but its default mode is isolated, not hoisted. It also paired badly: nodeLinker: hoisted together with shamefullyHoist: true is pnpm/pnpm#6620, spurious ModuleNotFoundErrors that only clear after toggling the setting off and on.

shamefullyHoist: true is publicHoistPattern: '*' — it republishes every transitive package at the root of node_modules, so a package can import a module it never declared and nothing complains.

Benefits

  • Undeclared imports become errors, permanently. Nine of them were live in this repo (below). After this, CI catches the next one instead of it riding on a hoisted copy.
  • Dedup is restored. isolated hardlinks each package once into the .pnpm store instead of writing a flat npm-style tree.
  • Version conflicts resolve correctly. Each importer gets its own exact version, instead of one winner hoisted to the workspace root when two projects disagree.

What was hiding behind the flag

Package Undeclared Symptom
root scripts @babel/core, glob, chokidar, @testing-library/jest-dom, @stylexjs/babel-plugin pnpm build fails at @astryxdesign/core
lab, charts, richtext @babel/cli, @babel/core, @babel/preset-react, @babel/preset-typescript, @stylexjs/babel-plugin build:esm → babel: command not found
lab, charts, richtext @testing-library/react 27 test files load 0 tests
core @types/babel__core TS7016
core @heroicons/react storybook typecheck TS2307; Button.a11y.test.tsx fails to resolve
storybook @heroicons/react, @stylexjs/stylex, @lexical/react, lexical build fails to resolve
docsite @babel/parser type error after a clean compile
cli @heroicons/react, @stylexjs/stylex, lucide-react, recharts assets/templates/** is in tsconfig.strict.json, which CI runs

All are devDependencies — nothing changes for consumers of the published packages. Every version matches what the workspace already resolved, so the lockfile gains importer entries and zero new package versions.

After the rebase onto current main

The branch was green before the rebase. Three jobs then failed, all on code that landed on main in the meantime and quietly relied on the flat root node_modules.

@heroicons/react in packages/core — #6131 added Button/__tests__/Button.a11y.renders.tsx, which imports it. packages/core never declared it. Broke build-storybook (TS2307) and test-ui (Vite resolve). Fixed by declaring it, the ninth row above.

build.packed-old-core.test.mjs — #5543 added a test that stages the packed CLI's runtime dependencies by reading <repo root>/node_modules/{commander,jiti,jscodeshift,zod}. Only a hoisted layout puts a package's own dependencies at the workspace root. It now looks from packages/cli.

build.adaptation-core-compat.test.mjs — also #5543. core-interception's patchCommonJs requires @astryxdesign/core from the theme file to check whether it can wrap defineTheme for .cjs dependencies. require folds NODE_PATH in, the isolated layout exposes every package under node_modules/.pnpm/node_modules, and Vitest points NODE_PATH at exactly that directory. So a core no dependency of the theme could reach answered the lookup. Wrapping it fails on a require(esm) namespace, and the coverage gap that failure reported then rejected every theme whose lineage was unobserved.

This is the same trap the doctor fix in this PR already addresses, so the resolution is shared rather than duplicated: findInstalledPackage moves from api/doctor/doctor.mjs to foundation/fs/paths.mjs, and doctor, core-interception, and the packed-CLI test all use it. It walks only the caller's own node_modules chain and never answers from the ambient environment.

Second commit: 68 insertions, 28 deletions across 7 files — 27 of those lines are the helper moving between files.

Rebased again, onto ae9ccef

Same class, three more instances from code that landed since:

The walk-up helpers the earlier rounds introduced are gone along with them. Node already walks up from the module doing the asking, so resolveFromDocsite('<pkg>/package.json') replaces the hand-rolled walk, and a missing dependency now throws instead of emitting a bundle that is quietly short a package. shadcn does not export ./package.json, but its bin is its entry, so it resolves as shadcn and runs through process.execPath — no path assumption, no NODE_PATH.

That leaves no walk-up helper in the repo outside findInstalledPackage, which stays: it reads a consumer's project, where there is no module of ours to resolve from and NODE_PATH must not count as installed. Net for the two files against main: −8 lines in the generator, +14 in the test.

Risks, and how each was closed

Risk Resolution
Build tools that walk node_modules break — the original stated reason for the flag, naming Storybook and the StyleX babel plugin pnpm build, storybook:build, docsite build and sandbox build all pass
A CI typecheck gate breaks Every typecheck CI runs passes, including cli typecheck:strict — the one that compiles the 145-error template assets
Tests regress Full node and ui vitest projects pass; ui is 10190/10190
Symlink-hostile environment (Docker, serverless, React Native) None in this repo; all CI runners are Ubuntu, no Dockerfile, no react-native
Workspace packages silently resolving from the registry linkWorkspacePackages: true untouched — required, since 64 internal deps are bare "*" (only 4 use workspace:*) and pnpm ≥ 10 defaults it to false

Every CI job passed on the previous head. On this one, verified locally: install --frozen-lockfile, build, lint, all ten typecheck gates, docsite generate + docsite test, the registry contract scripts, and both vitest projects.

Pre-existing, left untouched

  • lab typecheck — relative .doc.mjs imports plus a Drawer onClose prop error. Unrelated to module resolution; CI runs lab typecheck:docs, which passes.
  • template-viewer build — fails identically with hoisting restored. packages/build aliases the @astryxdesign/core prefix to core/src, so core/locales/*.json rewrites to a path that does not exist. CI does not build this app.
  • internal/vibe-tests/setup-test/setup-workspace.test.mjs — fails on macOS only, because it shells out to cp -a --reflink=auto, which BSD cp rejects. The file is byte-identical to main and the test passes on the Linux runners.

Note for reviewers pulling this branch

Changing hoisting makes pnpm recreate node_modules wholesale. Interactively it prompts; in a non-TTY shell it aborts with ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY unless CI=true is set. GitHub Actions sets CI itself, so CI is unaffected.

@vercel

vercel Bot commented Aug 22, 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 Sep 13, 2026 10:59am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 22, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 22, 2026
@github-actions

github-actions Bot commented Aug 22, 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

No component packages changed.

Accessibility Audit

Status: 36 accessibility violation(s) found — 2 critical, 34 serious.

Button pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatComposer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatComposerInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/14 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatReasoning - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatToolCalls - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 10/11 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Checkbox pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/33 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CheckboxList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/17 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ClickableCard - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditor - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/7 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditorPerf - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/2 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditorTheme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 13/14 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeTheme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 14/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
DateRangeInput - 1 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/20 stories · Learn more
    • WCAG: 4.1.2 (Level A)
FileInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/15 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
GridMasonry - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/3 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Heading - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Icon - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
LogStream - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/3 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
MediaTheme Auto - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
PowerSearch - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ProgressBar - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Radio group pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
RadioList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/13 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
RichTextEditor - 2 issue(s)
  • 🟠 serious: Ensure every ARIA input field has an accessible name
    • Rule: aria-input-field-name · Affects 2/18 stories · Learn more
    • WCAG: 4.1.2 (Level A)
  • 🔴 critical: Ensure every form element has a label
    • Rule: label · Affects 1/18 stories · Learn more
    • WCAG: 4.1.2 (Level A)
SelectableCard - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/4 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Stepper - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/30 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
TableGroupedRows - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 3/3 stories · Learn more
    • WCAG: 4.1.2 (Level A)
TableTree - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 8/9 stories · Learn more
    • WCAG: 4.1.2 (Level A)
Text - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/23 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Theme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
PopArt - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/6 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Thumbnail - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/12 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Timestamp - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/20 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Token - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/10 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Tokenizer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/24 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

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

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

Thanks—making the dependency graph explicit is the right direction. Right now the head cannot pass CI, and the shipped CLI fix would miss the next release:

  1. internal/vibe-tests/setup-test/public-artifact-cli.test.mjs still hard-codes the root node_modules/.bin/tsx, but the root manifest does not declare tsx. Exact-head test-node now fails because both subprocesses never start. Please make that launcher resolve the package-local declared binary (or declare the root dependency) and get the Node suite green.
  2. This also changes the published CLI's doctor peer-resolution behavior, but no Changeset covers @astryxdesign/cli. Please add the required patch Changeset so users receive the fix.

[Reviewed by Robohands]

@sangwook-dev

sangwook-dev commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@cixzhang

Both addressed.

  1. test-node — fixed in 6da1de7; the review landed against 4e6d7c7, one commit earlier. Took your first option: the launcher now resolves the bin of internal/vibe-tests, the package that declares tsx. test-node is green on that head.

  2. Changeset — added in 115b529: .changeset/doctor-peer-resolution.md, patch on @astryxdesign/cli, [fix]. pnpm check:changesets passes.

One heads-up: the branch is rebased onto current main, and the rebase surfaced the same class of undeclared import in code that landed meanwhile — packages/vega, internal/eslint-plugin-astryx, and yaml at the root.

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

Thanks—both earlier asks are fixed: the package-local tsx launcher now matches its declaration, and the CLI behavior has a patch Changeset.

One compatibility gap remains. Astryx documents Yarn installs and the CLI explicitly supports Yarn, but modern Yarn uses PnP by default and has no node_modules. The new filesystem-only lookup at packages/cli/api/doctor/doctor.mjs:112 therefore tells a healthy Yarn PnP project that every Core peer is missing. Please keep resolution project-local without accepting ambient NODE_PATH, and add regression coverage for both cases.

If you'd rather talk it through with someone, we're in Discord.

[Reviewed by Robohands]

github-actions Bot added a commit that referenced this pull request Sep 6, 2026
@sangwook-dev

sangwook-dev commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@cixzhang

I was heading to Discord with this, but it turns out to be about this PR's diff specifically, so it seems more useful here.

I couldn't reproduce the PnP failure as described, so I built a real one to check against. Yarn 4.18, PnP — no node_modules, .pnp.cjs and .pnp.loader.mjs on disk — with @astryxdesign/[email protected] genuinely installed (yarn why confirms it). Running runChecks() against that project from each checkout gives byte-identical output on main and on this branch:

[FAIL] core-installed:  @astryxdesign/core could not be resolved from this project.
[WARN] themes:          No @astryxdesign/theme-* packages are installed.
[INFO] peer-deps:       Skipped — @astryxdesign/core is not installed.
[INFO] package-manager: Detected package manager: yarn (declared in package.json).

Two things follow from that.

peer-deps reports "Skipped", not missing peers. checkPeerDeps returns on its first line because ctx.coreDir is null, so doctor.mjs:112 — the lookup this PR adds — never executes under PnP. It has no way to report every peer as missing there.

What does break predates this PR. findCoreDir in packages/cli/foundation/fs/paths.mjs and findNodeModules in doctor.mjs both answer with fs.existsSync on a node_modules path, and resolvePackageDir in foundation/integrations/integrations.mjs carries the same assumption. This PR touches none of them — git diff main...HEAD -- packages/cli/foundation/ is empty.

So doctor appears to have never worked under Yarn PnP. My guess at why it went unnoticed: Yarn classic and Berry with nodeLinker: node-modules both have a real node_modules, and a diagnostic that answers wrongly fails quietly rather than breaking a build. There's also no PnP coverage anywhere in the repo — no .pnp.cjs or pnpapi reference in any file.

I'd rather not fix it in this PR. Making resolution PnP-aware means first deciding how the CLI reaches the project's PnP map at all: pnpapi only exists in-process when the CLI is launched through Yarn, so an npx astryx invocation would have to read .pnp.cjs directly or shell out to Yarn. That's a design change to CLI resolution, which is a different thing from the dependency declarations this PR is making.

Happy to open a separate issue with this repro attached. If you'd rather it land here instead, say so and I'll take it on in this branch.

@sangwook-dev
sangwook-dev force-pushed the chore/drop-node-linker-hoisted branch from 115b529 to 351fd59 Compare September 10, 2026 00:45
@sangwook-dev
sangwook-dev force-pushed the chore/drop-node-linker-hoisted branch from 4f10755 to 1ad034b Compare September 10, 2026 14:51
github-actions Bot added a commit that referenced this pull request Sep 10, 2026
@sangwook-dev
sangwook-dev force-pushed the chore/drop-node-linker-hoisted branch from 1ad034b to 3c320df Compare September 11, 2026 03:58
@sangwook-dev
sangwook-dev force-pushed the chore/drop-node-linker-hoisted branch from 3c320df to 2bb962e Compare September 11, 2026 04:14
github-actions Bot added a commit that referenced this pull request Sep 11, 2026
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 11, 2026
…o walk

Addresses the review on meta#5327. `findInstalledPackage` walked the node_modules
chain and stopped there, so a Yarn Plug'n'Play project — which has no
node_modules at all — read as missing every Core peer.

It now asks the PnP runtime when the walk comes up empty. PnP resolves from the
project's own dependency graph and ignores NODE_PATH, so the lookup stays
project-local, which is the property the filesystem walk was introduced for.

Verified against a real Yarn 4 PnP project with @astryxdesign/core installed:
declared packages resolve and their versions read off disk, an undeclared one
is still reported missing, and poisoning NODE_PATH changes nothing. That is
strictly better than the previous `require.resolve`, which could confirm a peer
was present under PnP but never read its version, because Core does not export
`./package.json`.

Covers both layouts in paths.test.mjs, including a case pinning that a package
reachable only from NODE_PATH is not accepted.
github-actions Bot added a commit that referenced this pull request Sep 11, 2026
Drops `nodeLinker: hoisted` and `shamefullyHoist: true`, both inherited
verbatim from the pre-pnpm-11 .npmrc (meta#3700). nodeLinker was annotated there
as pnpm's default, which it is not -- the default is `isolated` -- and pairing
it with shamefullyHoist is pnpm/pnpm#6620. shamefullyHoist is
`publicHoistPattern: '*'`, which let eleven packages import modules they never
declared; all eleven are now declared, at the versions the workspace already
resolved. The Babel toolchain and Testing Library move into the catalog, each
having been duplicated across 4-6 packages.

Consolidating them surfaced an incoherent Babel pin: Dependabot had raised
`@babel/cli` (meta#4067) and `@babel/preset-react` (meta#3839) to 8.x on their own
while `@babel/core` and `@babel/preset-typescript` stayed on 7.x, and the 8.x
releases peer on `@babel/core: ^8.0.0` -- a set no single core version can
satisfy. All four now sit on ^7.29.7, matching the core that actually runs;
`pnpm peers check` drops from 4 unmet peers to 2 unrelated ones. Moving to
Babel 8 is a migration of its own.

Also fixes a latent `astryx doctor` bug the linker change exposed:
checkPeerDeps resolved peers with `require.resolve(name, {paths: [cwd]})`, but
Node folds NODE_PATH in regardless, so a peer merely reachable from the ambient
environment read as installed and doctor stayed silent about a missing one. It
now walks the project's own node_modules and reads package.json off disk, so
every peer gets range-checked. The existing test caught this unmodified.

One test read a bin the same way. public-artifact-cli.test.mjs spawns tsx by
absolute path out of the repo root's node_modules/.bin, which only ever held
one because shamefullyHoist published every bin there; tsx is declared by
internal/vibe-tests, so it now spawns that package's own bin. Scripts were
never at risk -- pnpm puts both bin directories on PATH -- and the repo's only
other hardcoded root bin, tsc in cli-api-types-verify.mjs, resolves because
typescript is a root devDependency.

Verified on a recreated node_modules: build, test, storybook:build, docsite and
sandbox builds, check:repo, verify-exports, eslint, and every typecheck CI gates
all pass. The local test failures that remain reproduce on main from a clean
worktree -- BSD `cp` has no `--reflink`, and two story titles predate the story
tree's shape rule -- and CI reported none of them.
…ion fix

The linker change also alters published behavior in `astryx doctor`, so the
fix needs a changeset to reach users in the next release.
Dropping the hoisted layout removes the flat root copy that three
resolutions quietly relied on. Each landed on main after this branch's
previous rebase, so CI met them for the first time here.

- packages/core used @heroicons/react in its Button accessibility
  fixtures without declaring it (meta#6131). Storybook's typecheck and the
  Button a11y suite could not resolve it.
- build.packed-old-core.test.mjs staged the packed CLI's runtime
  dependencies from the repo root, where only a hoisted node_modules puts
  a package's own dependencies (meta#5543).
- core-interception's CommonJS probe reached a core through NODE_PATH,
  which is where pnpm's isolated layout exposes every package and where
  Vitest points it. Wrapping that core fails on a require(esm) namespace,
  and the coverage gap it then reported rejected every theme whose
  lineage was unobserved (meta#5543).

doctor's findInstalledPackage moves to foundation/fs/paths.mjs and is now
the single chain walk all three share. It answers only from the caller's
own node_modules, never from the ambient environment.
The shadcn registry (meta#5973, meta#6228, meta#6231) landed against the hoisted layout and
reaches for three things the workspace root only carries when hoisted.

- apps/docsite's generate-data.mjs requires `recharts/package.json` to pin the
  registry's external dependency specs. docsite declares the other three of
  that list; recharts was missing, so `pnpm generate` failed and 14 docsite
  test files could not load.
- generate-shadcn-registry.mjs named `@babel/preset-typescript` as a string.
  Babel resolves a string preset from `cwd`, and the registry-contract job runs
  the script from the repo root. It is now imported, the way the StyleX plugin
  beside it already was, so it resolves through docsite's own node_modules.
- generate-shadcn-registry.test.mjs spawned `node_modules/.bin/shadcn` from the
  repo root, at four call sites. shadcn is a docsite dependency, so its bin
  lives beside that package. The test now walks up from apps/docsite to find it.
…o walk

Addresses the review on meta#5327. `findInstalledPackage` walked the node_modules
chain and stopped there, so a Yarn Plug'n'Play project — which has no
node_modules at all — read as missing every Core peer.

It now asks the PnP runtime when the walk comes up empty. PnP resolves from the
project's own dependency graph and ignores NODE_PATH, so the lookup stays
project-local, which is the property the filesystem walk was introduced for.

Verified against a real Yarn 4 PnP project with @astryxdesign/core installed:
declared packages resolve and their versions read off disk, an undeclared one
is still reported missing, and poisoning NODE_PATH changes nothing. That is
strictly better than the previous `require.resolve`, which could confirm a peer
was present under PnP but never read its version, because Core does not export
`./package.json`.

Covers both layouts in paths.test.mjs, including a case pinning that a package
reachable only from NODE_PATH is not accepted.
meta#6246 landed against the hoisted layout after this branch was last rebased,
and reaches for two things the workspace root only carries when hoisted.

- packages/cli/authoring/shadcn/source-variants.mjs imports `@babel/core`.
  cli declares the runtime package but not its types, so `sync:api-types`
  failed with TS7016 on two lines and took `pnpm build` down with it.
  `@types/babel__core` is now declared beside it, as packages/core already
  does for the same import.
- generate-shadcn-registry.test.mjs gained a fifth call site spawning
  `node_modules/.bin/shadcn` from the repo root. The other four already go
  through shadcnBin(), which walks up from apps/docsite — the package that
  declares shadcn, and so the only place its bin lives. The new one now does
  too, and the suite is back to 24 passing.
Two places computed a path into the repo root instead of resolving a package,
which only works when node_modules is hoisted. Node already walks up from the
module doing the asking, so both now let it.

- generate-playground-types.mjs read @heroicons/react and recharts off the
  root. Both degraded in silence — the heroicon loop `continue`d and the
  Recharts builder returned {} — so the playground shipped without the types
  rather than failing. Recharts arrived with meta#6264 and is covered by
  playground-scope.test.ts, which is how it surfaced; the heroicon path has
  been there since meta#2535 and nothing asserts on it, so it was quietly
  producing zero variants. Resolving now throws if either is missing.
- generate-shadcn-registry.test.mjs spawned node_modules/.bin/shadcn. shadcn
  does not export ./package.json, but its bin *is* its entry, so resolving
  `shadcn` from apps/docsite and running it through process.execPath needs no
  path assumption and no NODE_PATH.

Net -8 lines in the generator. findInstalledPackage is unchanged: it reads a
consumer project, where there is no module of ours to resolve from and
NODE_PATH must not count as installed.
@sangwook-dev
sangwook-dev force-pushed the chore/drop-node-linker-hoisted branch from b28875c to 80d432a Compare September 13, 2026 10:54
@sangwook-dev

sangwook-dev commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto ae9ccef. Only pnpm-lock.yaml conflicted — main had picked up @babel/{parser,traverse}@8 from the bumps this PR unifies back to 7.x — so it was regenerated rather than hand-merged.

Three things that landed since relied on the hoisted root: packages/cli imports @babel/core without declaring @types/babel__core (#6246), generate-playground-types.mjs reads recharts (#6264) and @heroicons/react off the repo root, and generate-shadcn-registry.test.mjs gained a fifth .bin/shadcn call site (#6246). The first broke pnpm build; the second failed silently, which is why the heroicon path had been emitting zero variants since #2535 unnoticed.

While fixing them I dropped the two walk-up helpers earlier rounds added — they reimplemented Node's own resolution. Anchoring a createRequire at the declaring package does the same in one line and throws instead of returning empty. findInstalledPackage stays, since it reads a consumer's project where there is no module of ours to anchor to.

Verified locally on this head: install --frozen-lockfile, build, lint, all ten typecheck gates, docsite (498), the registry contract scripts, ui 10190/10190, node 6786 passing. node's two remaining failures reproduce identically on ae9ccef with hoisting in place — setup-workspace shells out to cp --reflink (BSD cp rejects it, macOS only) and story-tree has the same stray titles on main.

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

Thanks—this substantially reduces dependency-layout risk, and the earlier review asks are addressed. Approving. The Yarn PnP path remains follow-up debt rather than a blocker.

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

Thanks! This substantially reduces dependency-layout risk. The earlier review asks are addressed; Yarn PnP remains follow-up debt rather than a blocker.

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 14, 2026
@cixzhang
cixzhang merged commit bf896f3 into meta:main Sep 14, 2026
39 checks passed
@sangwook-dev
sangwook-dev deleted the chore/drop-node-linker-hoisted branch September 14, 2026 21:46
sangwook-dev added a commit to sangwook-dev/astryx that referenced this pull request Sep 25, 2026
…DE_PATH

After meta#5327 made node_modules strict, packages/build/src/next.test.mjs kept
resolving enhanced-resolve (meta#5932) without a declaration: it arrives only
transitively through next, and pnpm's vitest shim puts
node_modules/.pnpm/node_modules on NODE_PATH, which require folds in. Run
without it, the test fails with MODULE_NOT_FOUND.

Declare it as a build dev dependency at the version the lockfile already
carries, so the lockfile gains an importer entry and no new package
versions.

The other two requires this commit first declared are covered elsewhere:
meta#6605 has ./postcss let the host's postcss parse its CSS, and meta#6627
removed the sandbox's next.config.mjs.

This branch was successfully deployed

1 active deployment
Preview — 80d432ac Deployed Sep 13, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Infra] shamefullyHoist hides undeclared imports; nodeLinker: hoisted is redundant

2 participants