Skip to content

Commit 0e3b098

Browse files
authored
chore(misc): declare lazy-loaded @nx/* packages as optional peers for storybook, web, vitest, and vue (#35393)
## Current Behavior Several `ensurePackage('@nx/X', nxVersion)` and `ensurePackage<typeof import('@nx/X')>(...)` references are invisible to Nx's project-graph source analysis, so the corresponding workspace edges are missing today: - `packages/storybook/src/generators/configuration/lib/util-functions.ts` lazy-loads `@nx/web` - `packages/web/src/generators/application/application.ts` lazy-loads `@nx/cypress`, `@nx/eslint`, `@nx/jest`, `@nx/playwright`, `@nx/vite`, `@nx/webpack` - `packages/vitest/src/utils/ignore-vitest-temp-files.ts` lazy-loads `@nx/eslint` - `packages/vue/src/**` lazy-loads `@nx/cypress`, `@nx/playwright`, `@nx/rsbuild`, `@nx/storybook` This means tasks in those packages read files from their lazy-loaded dependencies at module-load time without declaring them as inputs — the motivation behind the sandbox-violation work in #35377. ## Expected Behavior Declares each lazy-loaded package as an optional `peerDependency` with `peerDependenciesMeta.*.optional: true`. `explicit-package-json-dependencies` walks `peerDependencies` alongside `dependencies`, materializing the edges in the graph. `optional: true` keeps them off the user's install surface — package managers don't auto-install optional peers and don't warn when they're missing. `@nx/vitest` is already declared as a `devDependency` of `@nx/web`, so the `web → vitest` edge is already present; no change needed there. Follows the pattern established in #35377 (`@nx/eslint → @nx/jest`). ### Scope Narrower subset of #35392, scoped to `@nx/storybook`, `@nx/web`, `@nx/vitest`, and `@nx/vue`. Those four close the most commonly hit transitive lazy-load chains (`storybook → web → jest`, `vue → storybook → web → jest`, `web → vitest → eslint`, etc.) without needing the `implicitDependencies: ["!name", ...]` cycle negations that `@nx/workspace` and `@nx/js` require in #35392. Note: `@nx/vitest` is not covered by #35392 at all, so this PR adds at least one edge that isn't in the broader PR. ### Verification - Regenerated project graph locally — all new edges appear as `static` type: - `storybook → web` - `web → {cypress, eslint, jest, playwright, vite, webpack}` - `vitest → eslint` - `vue → {cypress, playwright, rsbuild, storybook}` - Full cycle scan: **0 cycles introduced**. - `nx prepush` passes cleanly. ## Related Issue(s) <!-- No open issue; follow-up to #35377 and narrower alternative to #35392 -->
1 parent 7a8d23b commit 0e3b098

9 files changed

Lines changed: 133 additions & 4 deletions

File tree

packages/storybook/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
"storybook": "9.0.6"
4848
},
4949
"peerDependencies": {
50+
"@nx/web": "workspace:*",
5051
"storybook": ">=7.0.0 <11.0.0"
5152
},
53+
"peerDependenciesMeta": {
54+
"@nx/web": {
55+
"optional": true
56+
}
57+
},
5258
"publishConfig": {
5359
"access": "public"
5460
}

packages/storybook/tsconfig.lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
},
3131
{
3232
"path": "../devkit/tsconfig.lib.json"
33+
},
34+
{
35+
"path": "../web/tsconfig.lib.json"
3336
}
3437
]
3538
}

packages/vitest/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@
5959
"@phenomnomnominal/tsquery": "catalog:typescript"
6060
},
6161
"peerDependencies": {
62+
"@nx/eslint": "workspace:*",
6263
"vitest": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0",
6364
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
6465
},
6566
"peerDependenciesMeta": {
67+
"@nx/eslint": {
68+
"optional": true
69+
},
6670
"vitest": {
6771
"optional": true
6872
},

packages/vitest/tsconfig.lib.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
},
1616
{
1717
"path": "../nx/tsconfig.lib.json"
18+
},
19+
{
20+
"path": "../eslint/tsconfig.lib.json"
1821
}
1922
]
2023
}

packages/vue/package.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,24 @@
4646
"publishConfig": {
4747
"access": "public"
4848
},
49-
"peerDependencies": {}
49+
"peerDependencies": {
50+
"@nx/cypress": "workspace:*",
51+
"@nx/playwright": "workspace:*",
52+
"@nx/rsbuild": "workspace:*",
53+
"@nx/storybook": "workspace:*"
54+
},
55+
"peerDependenciesMeta": {
56+
"@nx/cypress": {
57+
"optional": true
58+
},
59+
"@nx/playwright": {
60+
"optional": true
61+
},
62+
"@nx/rsbuild": {
63+
"optional": true
64+
},
65+
"@nx/storybook": {
66+
"optional": true
67+
}
68+
}
5069
}

packages/vue/tsconfig.lib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
},
2929
{
3030
"path": "../nx/tsconfig.lib.json"
31+
},
32+
{
33+
"path": "../storybook/tsconfig.lib.json"
34+
},
35+
{
36+
"path": "../rsbuild/tsconfig.lib.json"
37+
},
38+
{
39+
"path": "../playwright/tsconfig.lib.json"
40+
},
41+
{
42+
"path": "../cypress/tsconfig.lib.json"
3143
}
3244
]
3345
}

packages/web/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@
4343
"nx": "workspace:*",
4444
"@nx/vitest": "workspace:*"
4545
},
46+
"peerDependencies": {
47+
"@nx/cypress": "workspace:*",
48+
"@nx/eslint": "workspace:*",
49+
"@nx/jest": "workspace:*",
50+
"@nx/playwright": "workspace:*",
51+
"@nx/vite": "workspace:*",
52+
"@nx/webpack": "workspace:*"
53+
},
54+
"peerDependenciesMeta": {
55+
"@nx/cypress": {
56+
"optional": true
57+
},
58+
"@nx/eslint": {
59+
"optional": true
60+
},
61+
"@nx/jest": {
62+
"optional": true
63+
},
64+
"@nx/playwright": {
65+
"optional": true
66+
},
67+
"@nx/vite": {
68+
"optional": true
69+
},
70+
"@nx/webpack": {
71+
"optional": true
72+
}
73+
},
4674
"publishConfig": {
4775
"access": "public"
4876
}

packages/web/tsconfig.lib.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,35 @@
1515
],
1616
"include": ["**/*.ts"],
1717
"references": [
18-
{
19-
"path": "../vitest/tsconfig.lib.json"
20-
},
2118
{
2219
"path": "../js/tsconfig.lib.json"
2320
},
2421
{
2522
"path": "../devkit/tsconfig.lib.json"
2623
},
24+
{
25+
"path": "../vitest/tsconfig.lib.json"
26+
},
2727
{
2828
"path": "../nx/tsconfig.lib.json"
29+
},
30+
{
31+
"path": "../webpack/tsconfig.lib.json"
32+
},
33+
{
34+
"path": "../vite/tsconfig.lib.json"
35+
},
36+
{
37+
"path": "../playwright/tsconfig.lib.json"
38+
},
39+
{
40+
"path": "../jest/tsconfig.lib.json"
41+
},
42+
{
43+
"path": "../eslint/tsconfig.lib.json"
44+
},
45+
{
46+
"path": "../cypress/tsconfig.lib.json"
2947
}
3048
]
3149
}

pnpm-lock.yaml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)