Repository navigation
chore(deps): make node_modules strict, declare what each package imports - #5327
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: 36 accessibility violation(s) found — 2 critical, 34 serious. Button pattern - 1 issue(s)
ChatComposer - 1 issue(s)
ChatComposerInput - 1 issue(s)
ChatReasoning - 1 issue(s)
ChatToolCalls - 1 issue(s)
Checkbox pattern - 1 issue(s)
CheckboxList - 1 issue(s)
ClickableCard - 1 issue(s)
CodeEditor - 1 issue(s)
CodeEditorPerf - 1 issue(s)
CodeEditorTheme - 1 issue(s)
CodeTheme - 1 issue(s)
DateRangeInput - 1 issue(s)
FileInput - 1 issue(s)
GridMasonry - 1 issue(s)
Heading - 1 issue(s)
Icon - 1 issue(s)
LogStream - 1 issue(s)
MediaTheme Auto - 1 issue(s)
PowerSearch - 1 issue(s)
ProgressBar - 1 issue(s)
Radio group pattern - 1 issue(s)
RadioList - 1 issue(s)
RichTextEditor - 2 issue(s)
SelectableCard - 1 issue(s)
Stepper - 1 issue(s)
TableGroupedRows - 1 issue(s)
TableTree - 1 issue(s)
Text - 1 issue(s)
Theme - 1 issue(s)
PopArt - 1 issue(s)
Thumbnail - 1 issue(s)
Timestamp - 1 issue(s)
Token - 1 issue(s)
Tokenizer - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
6808c5a to
17d3051
Compare
17d3051 to
d682d67
Compare
d682d67 to
4e6d7c7
Compare
cixzhang
left a comment
There was a problem hiding this comment.
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:
internal/vibe-tests/setup-test/public-artifact-cli.test.mjsstill hard-codes the rootnode_modules/.bin/tsx, but the root manifest does not declaretsx. Exact-headtest-nodenow 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.- This also changes the published CLI's
doctorpeer-resolution behavior, but no Changeset covers@astryxdesign/cli. Please add the required patch Changeset so users receive the fix.
[Reviewed by Robohands]
4e6d7c7 to
6da1de7
Compare
|
Both addressed.
One heads-up: the branch is rebased onto current |
cixzhang
left a comment
There was a problem hiding this comment.
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]
|
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 Two things follow from that.
What does break predates this PR. So doctor appears to have never worked under Yarn PnP. My guess at why it went unnoticed: Yarn classic and Berry with 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: 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. |
115b529 to
351fd59
Compare
4f10755 to
1ad034b
Compare
1ad034b to
3c320df
Compare
3c320df to
2bb962e
Compare
…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.
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.
b28875c to
80d432a
Compare
|
Rebased onto Three things that landed since relied on the hoisted root: While fixing them I dropped the two walk-up helpers earlier rounds added — they reimplemented Node's own resolution. Anchoring a Verified locally on this head: |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks! This substantially reduces dependency-layout risk. The earlier review asks are addressed; Yarn PnP remains follow-up debt rather than a blocker.
…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.
Closes #5328
What
Removes both hoisting settings from
pnpm-workspace.yamland declares the dependencies that were only resolving because of them.linkWorkspacePackages: truestays.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: hoistedwas 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 isisolated, nothoisted. It also paired badly:nodeLinker: hoistedtogether withshamefullyHoist: trueis pnpm/pnpm#6620, spuriousModuleNotFoundErrors that only clear after toggling the setting off and on.shamefullyHoist: trueispublicHoistPattern: '*'— it republishes every transitive package at the root ofnode_modules, so a package can import a module it never declared and nothing complains.Benefits
isolatedhardlinks each package once into the.pnpmstore instead of writing a flat npm-style tree.What was hiding behind the flag
@babel/core,glob,chokidar,@testing-library/jest-dom,@stylexjs/babel-pluginpnpm buildfails at@astryxdesign/corelab,charts,richtext@babel/cli,@babel/core,@babel/preset-react,@babel/preset-typescript,@stylexjs/babel-pluginbuild:esm→babel: command not foundlab,charts,richtext@testing-library/reactcore@types/babel__corecore@heroicons/reactstorybook typecheckTS2307;Button.a11y.test.tsxfails to resolvestorybook@heroicons/react,@stylexjs/stylex,@lexical/react,lexicaldocsite@babel/parsercli@heroicons/react,@stylexjs/stylex,lucide-react,rechartsassets/templates/**is intsconfig.strict.json, which CI runsAll 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
mainin the meantime and quietly relied on the flat rootnode_modules.@heroicons/reactinpackages/core— #6131 addedButton/__tests__/Button.a11y.renders.tsx, which imports it.packages/corenever declared it. Brokebuild-storybook(TS2307) andtest-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 frompackages/cli.build.adaptation-core-compat.test.mjs— also #5543.core-interception'spatchCommonJsrequires@astryxdesign/corefrom the theme file to check whether it can wrapdefineThemefor.cjsdependencies.requirefoldsNODE_PATHin, the isolated layout exposes every package undernode_modules/.pnpm/node_modules, and Vitest pointsNODE_PATHat exactly that directory. So a core no dependency of the theme could reach answered the lookup. Wrapping it fails on arequire(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:
findInstalledPackagemoves fromapi/doctor/doctor.mjstofoundation/fs/paths.mjs, anddoctor,core-interception, and the packed-CLI test all use it. It walks only the caller's ownnode_moduleschain 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
ae9ccefSame class, three more instances from code that landed since:
@types/babel__coreinpackages/cli— fix(shadcn): preserve JavaScript composition upgrades #6246 addedauthoring/shadcn/source-variants.mjs, which imports@babel/core.clideclared the runtime package but not its types, sosync:api-typesfailed with TS7016 and tookpnpm builddown with it.@heroicons/reactandrechartsingenerate-playground-types.mjs— it read both off the repo root. Recharts arrived with fix(docsite): render dashboard templates in gallery and playground #6264 and is covered byplayground-scope.test.ts, which is how it surfaced; the heroicon path has been there since fix(docsite): resolve heroicons imports in playground editor #2535, nothing asserts on it, and it was quietly emitting zero variants on this branch.node_modules/.bin/shadcn— fix(shadcn): preserve JavaScript composition upgrades #6246 added a fifth call site ingenerate-shadcn-registry.test.mjs.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.shadcndoes not export./package.json, but its bin is its entry, so it resolves asshadcnand runs throughprocess.execPath— no path assumption, noNODE_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 andNODE_PATHmust not count as installed. Net for the two files againstmain: −8 lines in the generator, +14 in the test.Risks, and how each was closed
node_modulesbreak — the original stated reason for the flag, naming Storybook and the StyleX babel pluginpnpm build,storybook:build,docsite buildandsandbox buildall passcli typecheck:strict— the one that compiles the 145-error template assetsnodeanduivitest projects pass;uiis 10190/10190linkWorkspacePackages: trueuntouched — required, since 64 internal deps are bare"*"(only 4 useworkspace:*) and pnpm ≥ 10 defaults it tofalseEvery 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.mjsimports plus aDraweronCloseprop error. Unrelated to module resolution; CI runslab typecheck:docs, which passes.template-viewerbuild — fails identically with hoisting restored.packages/buildaliases the@astryxdesign/coreprefix tocore/src, socore/locales/*.jsonrewrites 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 tocp -a --reflink=auto, which BSDcprejects. The file is byte-identical tomainand the test passes on the Linux runners.Note for reviewers pulling this branch
Changing hoisting makes pnpm recreate
node_moduleswholesale. Interactively it prompts; in a non-TTY shell it aborts withERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTYunlessCI=trueis set. GitHub Actions setsCIitself, so CI is unaffected.