create-stencil-components 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/templates/base/.agents/skills/link-workspace-packages/SKILL.md +127 -0
- package/dist/templates/base/.agents/skills/monitor-ci/SKILL.md +301 -0
- package/dist/templates/base/.agents/skills/monitor-ci/references/fix-flows.md +108 -0
- package/dist/templates/base/.agents/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
- package/dist/templates/base/.agents/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
- package/dist/templates/base/.agents/skills/nx-generate/SKILL.md +166 -0
- package/dist/templates/base/.agents/skills/nx-import/SKILL.md +238 -0
- package/dist/templates/base/.agents/skills/nx-import/references/ESLINT.md +109 -0
- package/dist/templates/base/.agents/skills/nx-import/references/GRADLE.md +12 -0
- package/dist/templates/base/.agents/skills/nx-import/references/JEST.md +223 -0
- package/dist/templates/base/.agents/skills/nx-import/references/NEXT.md +214 -0
- package/dist/templates/base/.agents/skills/nx-import/references/TURBOREPO.md +62 -0
- package/dist/templates/base/.agents/skills/nx-import/references/VITE.md +393 -0
- package/dist/templates/base/.agents/skills/nx-plugins/SKILL.md +9 -0
- package/dist/templates/base/.agents/skills/nx-run-tasks/SKILL.md +58 -0
- package/dist/templates/base/.agents/skills/nx-workspace/SKILL.md +284 -0
- package/dist/templates/base/.agents/skills/nx-workspace/references/AFFECTED.md +27 -0
- package/dist/templates/base/.claude/settings.json +13 -0
- package/dist/templates/base/.codex/agents/ci-monitor-subagent.toml +46 -0
- package/dist/templates/base/.codex/config.toml +10 -0
- package/dist/templates/base/.cursor/agents/ci-monitor-subagent.md +51 -0
- package/dist/templates/base/.gemini/commands/monitor-ci.toml +298 -0
- package/dist/templates/base/.gemini/settings.json +8 -11
- package/dist/templates/base/.github/agents/ci-monitor-subagent.agent.md +49 -0
- package/dist/templates/base/.github/prompts/monitor-ci.prompt.md +301 -0
- package/dist/templates/base/.github/skills/link-workspace-packages/SKILL.md +127 -0
- package/dist/templates/base/.github/skills/monitor-ci/SKILL.md +301 -0
- package/dist/templates/base/.github/skills/monitor-ci/references/fix-flows.md +108 -0
- package/dist/templates/base/.github/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
- package/dist/templates/base/.github/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
- package/dist/templates/base/.github/skills/nx-generate/SKILL.md +166 -0
- package/dist/templates/base/.github/skills/nx-import/SKILL.md +238 -0
- package/dist/templates/base/.github/skills/nx-import/references/ESLINT.md +109 -0
- package/dist/templates/base/.github/skills/nx-import/references/GRADLE.md +12 -0
- package/dist/templates/base/.github/skills/nx-import/references/JEST.md +223 -0
- package/dist/templates/base/.github/skills/nx-import/references/NEXT.md +214 -0
- package/dist/templates/base/.github/skills/nx-import/references/TURBOREPO.md +62 -0
- package/dist/templates/base/.github/skills/nx-import/references/VITE.md +393 -0
- package/dist/templates/base/.github/skills/nx-plugins/SKILL.md +9 -0
- package/dist/templates/base/.github/skills/nx-run-tasks/SKILL.md +58 -0
- package/dist/templates/base/.github/skills/nx-workspace/SKILL.md +284 -0
- package/dist/templates/base/.github/skills/nx-workspace/references/AFFECTED.md +27 -0
- package/dist/templates/base/.opencode/agents/ci-monitor-subagent.md +50 -0
- package/dist/templates/base/.opencode/commands/monitor-ci.md +301 -0
- package/dist/templates/base/.opencode/skills/link-workspace-packages/SKILL.md +127 -0
- package/dist/templates/base/.opencode/skills/monitor-ci/SKILL.md +301 -0
- package/dist/templates/base/.opencode/skills/monitor-ci/references/fix-flows.md +108 -0
- package/dist/templates/base/.opencode/skills/monitor-ci/scripts/ci-poll-decide.mjs +356 -0
- package/dist/templates/base/.opencode/skills/monitor-ci/scripts/ci-state-update.mjs +152 -0
- package/dist/templates/base/.opencode/skills/nx-generate/SKILL.md +166 -0
- package/dist/templates/base/.opencode/skills/nx-import/SKILL.md +238 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/ESLINT.md +109 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/GRADLE.md +12 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/JEST.md +223 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/NEXT.md +214 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/TURBOREPO.md +62 -0
- package/dist/templates/base/.opencode/skills/nx-import/references/VITE.md +393 -0
- package/dist/templates/base/.opencode/skills/nx-plugins/SKILL.md +9 -0
- package/dist/templates/base/.opencode/skills/nx-run-tasks/SKILL.md +58 -0
- package/dist/templates/base/.opencode/skills/nx-workspace/SKILL.md +284 -0
- package/dist/templates/base/.opencode/skills/nx-workspace/references/AFFECTED.md +27 -0
- package/dist/templates/base/AGENTS.md +46 -36
- package/dist/templates/base/CLAUDE.md +15 -5
- package/dist/templates/base/package.json +3 -3
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +3 -3
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +2 -2
- package/dist/templates/variants/all/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +5 -1
- package/dist/templates/variants/angular/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +2 -2
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +2 -2
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/package.json +2 -2
- package/dist/templates/variants/react/packages/components-{{PROJECT_NAME_KEBAB}}-react/tsconfig.json +5 -1
- package/dist/templates/variants/vue/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +1 -1
- package/dist/templates/variants/web-components/packages/components-{{PROJECT_NAME_KEBAB}}-core/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
## Next.js
|
|
2
|
+
|
|
3
|
+
Next.js-specific guidance for `nx import`. For generic import issues (pnpm globs, root deps, project references, name collisions, ESLint, frontend tsconfig base settings, `@nx/react` typings, Jest preset, target name prefixing, non-Nx source handling), see `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### `@nx/next/plugin` Inferred Targets
|
|
8
|
+
|
|
9
|
+
`@nx/next/plugin` detects `next.config.{ts,js,cjs,mjs}` and creates these targets:
|
|
10
|
+
|
|
11
|
+
- `build` → `next build` (with `dependsOn: ['^build']`)
|
|
12
|
+
- `dev` → `next dev`
|
|
13
|
+
- `start` → `next start` (depends on `build`)
|
|
14
|
+
- `serve-static` → same as `start`
|
|
15
|
+
- `build-deps` / `watch-deps` — for TS solution setup
|
|
16
|
+
|
|
17
|
+
**No separate typecheck target** — Next.js runs TypeScript checking as part of `next build`. The `@nx/js/typescript` plugin provides a standalone `typecheck` target for non-Next libraries in the workspace.
|
|
18
|
+
|
|
19
|
+
**Build target conflict**: Both `@nx/next/plugin` and `@nx/js/typescript` define a `build` target. `@nx/next/plugin` wins for Next.js projects (it detects `next.config.*`), while `@nx/js/typescript` handles libraries with `tsconfig.lib.json`. No rename needed — they coexist.
|
|
20
|
+
|
|
21
|
+
### `withNx` in `next.config.js`
|
|
22
|
+
|
|
23
|
+
Nx-generated Next.js projects use `composePlugins(withNx)` from `@nx/next`. This wrapper is optional for `next build` via the inferred plugin (which just runs `next build`), but it provides Nx-specific configuration. Keep it if present.
|
|
24
|
+
|
|
25
|
+
### Root Dependencies for Next.js
|
|
26
|
+
|
|
27
|
+
Beyond the generic root deps issue (see SKILL.md), Next.js projects typically need:
|
|
28
|
+
|
|
29
|
+
**Core**: `react`, `react-dom`, `@types/react`, `@types/react-dom`, `@types/node`, `@nx/react` (see SKILL.md for `@nx/react` typings)
|
|
30
|
+
**Nx plugins**: `@nx/next` (auto-installed by import), `@nx/eslint`, `@nx/jest`
|
|
31
|
+
**Testing**: see SKILL.md "Jest Preset Missing" section
|
|
32
|
+
**ESLint**: `@next/eslint-plugin-next` (in addition to generic ESLint deps from SKILL.md)
|
|
33
|
+
|
|
34
|
+
### Next.js Auto-Installing Dependencies via Wrong Package Manager
|
|
35
|
+
|
|
36
|
+
Next.js detects missing `@types/react` during `next build` and tries to install it using `yarn add` regardless of the actual package manager. In a pnpm workspace, this fails with a "nearest package directory isn't part of the project" error.
|
|
37
|
+
|
|
38
|
+
**Root cause**: `@types/react` is missing from root devDependencies.
|
|
39
|
+
**Fix**: Install deps at the root before building: `pnpm add -wD @types/react @types/react-dom`
|
|
40
|
+
|
|
41
|
+
### Next.js TypeScript Config Specifics
|
|
42
|
+
|
|
43
|
+
Next.js app tsconfigs have unique patterns compared to Vite:
|
|
44
|
+
|
|
45
|
+
- **`noEmit: true`** with `emitDeclarationOnly: false` — Next.js handles emit, TS just checks types. This conflicts with `composite: true` from the TS solution setup.
|
|
46
|
+
- **`"types": ["jest", "node"]`** — includes test types in the main tsconfig (no separate `tsconfig.app.json`)
|
|
47
|
+
- **`"plugins": [{ "name": "next" }]`** — for IDE integration
|
|
48
|
+
- **`include`** references `.next/types/**/*.ts` for Next.js auto-generated types
|
|
49
|
+
- **`"jsx": "preserve"`** — Next.js uses its own JSX transform, not React's
|
|
50
|
+
|
|
51
|
+
**Gotcha**: The Next.js tsconfig sets `"noEmit": true` which disables `composite` mode. This is fine because Next.js projects use `next build` for building, not `tsc`. The `@nx/js/typescript` plugin's `typecheck` target is not needed for Next.js apps.
|
|
52
|
+
|
|
53
|
+
### `next.config.js` Lint Warning
|
|
54
|
+
|
|
55
|
+
Imported Next.js configs may have `// eslint-disable-next-line @typescript-eslint/no-var-requires` but the project ESLint config enables different rule sets. This produces `Unused eslint-disable directive` warnings. Harmless — remove the comment or ignore.
|
|
56
|
+
|
|
57
|
+
### `@nx/next:init` Rewrites All npm Scripts (Whole-Repo Import)
|
|
58
|
+
|
|
59
|
+
When `@nx/next:init` runs during a whole-repo import, it rewrites the project's `package.json` scripts to prefixed `nx` calls:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"dev": "nx next:dev",
|
|
64
|
+
"build": "nx next:build",
|
|
65
|
+
"start": "nx next:start"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This is the standard "npm Script Rewriting" issue from SKILL.md, but triggered by `@nx/next:init` rather than Nx init. **Fix**: Remove all rewritten scripts from `package.json` — `@nx/next/plugin` infers all targets from `next.config.*`.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Non-Nx Source (create-next-app)
|
|
74
|
+
|
|
75
|
+
### Whole-Repo Import Recommended
|
|
76
|
+
|
|
77
|
+
For single-project `create-next-app` repos, use whole-repo import into a subdirectory:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
nx import /path/to/source apps/web --ref=main --source=. --no-interactive
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `next-env.d.ts`
|
|
84
|
+
|
|
85
|
+
`next build` auto-generates `next-env.d.ts` at the project root. Add `next-env.d.ts` to the dest root `.gitignore` — it is framework-generated and should not be committed.
|
|
86
|
+
|
|
87
|
+
### ESLint: Self-Contained `eslint-config-next`
|
|
88
|
+
|
|
89
|
+
`create-next-app` generates a flat ESLint config using `eslint-config-next` (which bundles its own plugins). This is **self-contained** — no root `eslint.config.mjs` needed, no `@nx/eslint-plugin` dependency. The `@nx/eslint/plugin` detects it and creates a lint target.
|
|
90
|
+
|
|
91
|
+
### TypeScript: No Changes Needed
|
|
92
|
+
|
|
93
|
+
Non-Nx Next.js projects have self-contained tsconfigs with `noEmit: true`, their own `lib`, `module`, `moduleResolution`, and `jsx` settings. Since `next build` handles type checking internally, no tsconfig modifications are needed. The project does NOT need to extend `tsconfig.base.json`.
|
|
94
|
+
|
|
95
|
+
**Gotcha**: The `@nx/js/typescript` plugin won't create a `typecheck` target because there's no `tsconfig.lib.json`. This is fine — use `next:build` for type checking.
|
|
96
|
+
|
|
97
|
+
### `noEmit: true` and TS Solution Setup
|
|
98
|
+
|
|
99
|
+
Non-Nx Next.js projects use `noEmit: true`, which conflicts with Nx's TS solution setup (`composite: true`). If the dest workspace uses project references and you want the Next.js app to participate:
|
|
100
|
+
|
|
101
|
+
1. Remove `noEmit: true`, add `composite: true`, `emitDeclarationOnly: true`
|
|
102
|
+
2. Add `extends: "../../tsconfig.base.json"`
|
|
103
|
+
3. Add `outDir` and `tsBuildInfoFile`
|
|
104
|
+
|
|
105
|
+
**However**, this is optional for standalone Next.js apps that don't export types consumed by other workspace projects.
|
|
106
|
+
|
|
107
|
+
### Tailwind / PostCSS
|
|
108
|
+
|
|
109
|
+
`create-next-app` with Tailwind generates `postcss.config.mjs`. This works as-is after import — no path changes needed since PostCSS resolves relative to the project root.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Mixed Next.js + Vite Coexistence
|
|
114
|
+
|
|
115
|
+
When both Next.js and Vite projects exist in the same workspace.
|
|
116
|
+
|
|
117
|
+
### Plugin Coexistence
|
|
118
|
+
|
|
119
|
+
Both `@nx/next/plugin` and `@nx/vite/plugin` can coexist in `nx.json`. They detect different config files (`next.config.*` vs `vite.config.*`) so there are no conflicts. The `@nx/js/typescript` plugin handles libraries.
|
|
120
|
+
|
|
121
|
+
### Vite Standalone Project tsconfig Fixes
|
|
122
|
+
|
|
123
|
+
Vite standalone projects (imported as whole-repo) have self-contained tsconfigs without `composite: true`. The `@nx/js/typescript` plugin's typecheck target runs `tsc --build --emitDeclarationOnly` which requires `composite`.
|
|
124
|
+
|
|
125
|
+
**Fix**:
|
|
126
|
+
|
|
127
|
+
1. Add `extends: "../../tsconfig.base.json"` to the root project tsconfig
|
|
128
|
+
2. Add `composite: true`, `declaration: true`, `declarationMap: true`, `tsBuildInfoFile` to `tsconfig.app.json` and `tsconfig.spec.json`
|
|
129
|
+
3. Set `moduleResolution: "bundler"` (replace `"node"`)
|
|
130
|
+
4. Add source files to `tsconfig.spec.json` `include` — specs import app code, and `composite` mode requires all files to be listed
|
|
131
|
+
|
|
132
|
+
### Typecheck Target Names
|
|
133
|
+
|
|
134
|
+
- `@nx/vite/plugin` defaults `typecheckTargetName` to `"vite:typecheck"`
|
|
135
|
+
- `@nx/js/typescript` uses `"typecheck"`
|
|
136
|
+
- Next.js projects have NO standalone typecheck target — Next.js runs type checking during `next build`
|
|
137
|
+
|
|
138
|
+
No naming conflicts between frameworks.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Fix Order — Nx Source (Subdirectory Import)
|
|
143
|
+
|
|
144
|
+
1. Import Next.js apps into `apps/<name>` (see SKILL.md: "Application vs Library Detection")
|
|
145
|
+
2. Generic fixes from SKILL.md (pnpm globs, root deps, `.gitkeep` removal, frontend tsconfig base settings, `@nx/react` typings)
|
|
146
|
+
3. Install Next.js-specific deps: `pnpm add -wD @next/eslint-plugin-next`
|
|
147
|
+
4. ESLint setup (see SKILL.md: "Root ESLint Config Missing")
|
|
148
|
+
5. Jest setup (see SKILL.md: "Jest Preset Missing")
|
|
149
|
+
6. `nx reset && nx sync --yes && nx run-many -t typecheck,build,test,lint`
|
|
150
|
+
|
|
151
|
+
## Fix Order — Non-Nx Source (create-next-app)
|
|
152
|
+
|
|
153
|
+
1. Import into `apps/<name>` (see SKILL.md: "Application vs Library Detection")
|
|
154
|
+
2. Generic fixes from SKILL.md (pnpm globs, stale files cleanup, script rewriting, target name prefixing)
|
|
155
|
+
3. (Optional) If app needs to export types for other workspace projects: fix `noEmit` → `composite` (see SKILL.md)
|
|
156
|
+
4. `nx reset && nx run-many -t next:build,eslint:lint` (or unprefixed names if renamed)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Iteration Log
|
|
161
|
+
|
|
162
|
+
### Scenario 1: Basic Nx Next.js App Router + Shared Lib → TS preset (PASS)
|
|
163
|
+
|
|
164
|
+
- Source: CNW next preset (Next.js 16, App Router) + `@nx/react:library` shared-ui
|
|
165
|
+
- Dest: CNW ts preset (Nx 23)
|
|
166
|
+
- Import: subdirectory-at-a-time (apps, libs separately)
|
|
167
|
+
- Errors found & fixed:
|
|
168
|
+
1. pnpm-workspace.yaml: `apps`/`libs` → `apps/*`/`libs/*`
|
|
169
|
+
2. Root tsconfig: `nodenext` → `bundler`, add `dom`/`dom.iterable` to `lib`, add `jsx: react-jsx`
|
|
170
|
+
3. Missing `@nx/react` (for CSS module/image type defs in lib)
|
|
171
|
+
4. Missing `@types/react`, `@types/react-dom`, `@types/node`
|
|
172
|
+
5. Next.js trying `yarn add @types/react` — fixed by installing at root
|
|
173
|
+
6. Missing `@nx/eslint`, root `eslint.config.mjs`, ESLint plugins
|
|
174
|
+
7. Missing `@nx/jest`, `jest.preset.js`, `jest-environment-jsdom`, `ts-jest`
|
|
175
|
+
- All targets green: typecheck, build, test, lint
|
|
176
|
+
|
|
177
|
+
### Scenario 3: Non-Nx create-next-app (App Router + Tailwind) → TS preset (PASS)
|
|
178
|
+
|
|
179
|
+
- Source: `create-next-app@latest` (Next.js 16.1.6, App Router, Tailwind v4, flat ESLint config)
|
|
180
|
+
- Dest: CNW ts preset (Nx 23)
|
|
181
|
+
- Import: whole-repo into `apps/web`
|
|
182
|
+
- Errors found & fixed:
|
|
183
|
+
1. pnpm-workspace.yaml: `apps/web` → `apps/*`
|
|
184
|
+
2. Stale files: `node_modules/`, `pnpm-lock.yaml`, `pnpm-workspace.yaml`, `.gitignore` — deleted
|
|
185
|
+
3. Nx-rewritten npm scripts (`"build": "nx next:build"`, etc.) — removed
|
|
186
|
+
- No tsconfig changes needed — self-contained config with `noEmit: true`
|
|
187
|
+
- ESLint self-contained via `eslint-config-next` — no root config needed
|
|
188
|
+
- No test setup (create-next-app doesn't include tests)
|
|
189
|
+
- All targets green: next:build, eslint:lint
|
|
190
|
+
|
|
191
|
+
### Scenario 4: Non-Nx create-next-app (alongside Vite, React Router 7, TanStack, CRA) → TS preset (PASS)
|
|
192
|
+
|
|
193
|
+
- See VITE.md Scenario 6 for the full multi-import scenario
|
|
194
|
+
- Next.js-specific findings:
|
|
195
|
+
1. `@nx/next:init` rewrote all scripts to `nx next:*` format — removed all rewritten scripts
|
|
196
|
+
2. Stale files: `node_modules/`, `package-lock.json`, `.gitignore` — deleted (npm workspace, no pnpm files)
|
|
197
|
+
3. ESLint self-contained via `eslint-config-next` — no root config needed
|
|
198
|
+
4. No tsconfig changes needed — `noEmit: true` stays; `next build` handles type checking
|
|
199
|
+
- Targets: `next:build`, `next:dev`, `next:start`, `eslint:lint`
|
|
200
|
+
|
|
201
|
+
### Scenario 5: Mixed Next.js (Nx) + Vite React (standalone) → TS preset (PASS)
|
|
202
|
+
|
|
203
|
+
- Source A: CNW next preset (Next.js 16, App Router) — subdirectory import of `apps/`
|
|
204
|
+
- Source B: CNW react-standalone preset (Vite 7, React 19) — whole-repo import into `apps/vite-app`
|
|
205
|
+
- Dest: CNW ts preset (Nx 23)
|
|
206
|
+
- Errors found & fixed:
|
|
207
|
+
1. All Scenario 1 fixes for the Next.js app
|
|
208
|
+
2. Stale files from Vite source: `node_modules/`, `pnpm-lock.yaml`, `pnpm-workspace.yaml`, `.gitignore`, `nx.json`
|
|
209
|
+
3. Removed rewritten scripts from Vite app's `package.json`
|
|
210
|
+
4. ESLint 8 vs 9 conflict — `@nx/eslint` peer on ESLint 8 resolved wrong version. Fixed with `pnpm.overrides`
|
|
211
|
+
5. Vite tsconfigs missing `composite: true`, `declaration: true` — needed for `tsc --build --emitDeclarationOnly`
|
|
212
|
+
6. Vite `tsconfig.spec.json` `include` missing source files — specs import app code
|
|
213
|
+
7. Vite tsconfig `moduleResolution: "node"` → `"bundler"`, added `extends: "../../tsconfig.base.json"`
|
|
214
|
+
- All targets green: typecheck, build, test, lint for both projects
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
## Turborepo
|
|
2
|
+
|
|
3
|
+
- Nx replaces Turborepo task orchestration, but a clean migration requires handling Turborepo's config packages.
|
|
4
|
+
- Migration guide: https://nx.dev/docs/guides/adopting-nx/from-turborepo#easy-automated-migration-example
|
|
5
|
+
- Since Nx replaces Turborepo, all turbo config files and config packages become dead code and should be removed.
|
|
6
|
+
|
|
7
|
+
## The Config-as-Package Pattern
|
|
8
|
+
|
|
9
|
+
Turborepo monorepos ship with internal workspace packages that share configuration:
|
|
10
|
+
|
|
11
|
+
- **`@repo/typescript-config`** (or similar) — tsconfig files (`base.json`, `nextjs.json`, `react-library.json`, etc.)
|
|
12
|
+
- **`@repo/eslint-config`** (or similar) — ESLint config files and all ESLint plugin dependencies
|
|
13
|
+
|
|
14
|
+
These are not code libraries. They distribute config via Node module resolution (e.g., `"extends": "@repo/typescript-config/nextjs.json"`). This is the **default** Turborepo pattern — expect it in virtually every Turborepo import. Package names vary — check `package.json` files to identify the actual names.
|
|
15
|
+
|
|
16
|
+
## Check for Root Config Files First
|
|
17
|
+
|
|
18
|
+
**Before doing any config merging, check whether the destination workspace uses shared root configuration.** This decides how to handle the config packages.
|
|
19
|
+
|
|
20
|
+
- If the workspace has a root `tsconfig.base.json` and/or root `eslint.config.mjs` that projects extend, merge the config packages into these root configs (see steps below).
|
|
21
|
+
- If the workspace does NOT have root config files — each project manages its own configuration independently (similar to Turborepo). In this case, **do not create root config files or merge into them**. Just remove turbo-specific parts (`turbo.json`, `eslint-plugin-turbo`) and leave the config packages in place, or ask the user how they want to handle them.
|
|
22
|
+
|
|
23
|
+
If unclear, check for the presence of `tsconfig.base.json` at the root or ask the user.
|
|
24
|
+
|
|
25
|
+
## Merging TypeScript Config (Only When Root tsconfig.base.json Exists)
|
|
26
|
+
|
|
27
|
+
The config package contains a hierarchy of tsconfig files. Each project extends one via package name.
|
|
28
|
+
|
|
29
|
+
1. **Read the config package** — trace the full inheritance chain (e.g., `nextjs.json` extends `base.json`).
|
|
30
|
+
2. **Update root `tsconfig.base.json`** — absorb `compilerOptions` from the base config. Add Nx `paths` for cross-project imports (Turborepo doesn't use path aliases, Nx relies on them).
|
|
31
|
+
3. **Update each project's `tsconfig.json`**:
|
|
32
|
+
- Change `"extends"` from `"@repo/typescript-config/<variant>.json"` to the relative path to root `tsconfig.base.json`.
|
|
33
|
+
- Inline variant-specific overrides from the intermediate config (e.g., Next.js: `"module": "ESNext"`, `"moduleResolution": "Bundler"`, `"jsx": "preserve"`, `"noEmit": true`; React library: `"jsx": "react-jsx"`).
|
|
34
|
+
- Preserve project-specific settings (`outDir`, `include`, `exclude`, etc.).
|
|
35
|
+
4. **Delete the config package** and remove it from all `devDependencies`.
|
|
36
|
+
|
|
37
|
+
## Merging ESLint Config (Only When Root eslint.config Exists)
|
|
38
|
+
|
|
39
|
+
The config package centralizes ESLint plugin dependencies and exports composable flat configs.
|
|
40
|
+
|
|
41
|
+
1. **Read the config package** — identify exported configs, plugin dependencies, and inheritance.
|
|
42
|
+
2. **Update root `eslint.config.mjs`** — absorb base rules (JS recommended, TypeScript-ESLint, Prettier, etc.). Drop `eslint-plugin-turbo`.
|
|
43
|
+
3. **Update each project's `eslint.config.mjs`** — switch from importing `@repo/eslint-config/<variant>` to extending the root config, adding framework-specific plugins inline.
|
|
44
|
+
4. **Move ESLint plugin dependencies** from the config package to root `devDependencies`.
|
|
45
|
+
5. If `@nx/eslint` plugin is configured with inferred targets, remove `"lint"` scripts from project `package.json` files.
|
|
46
|
+
6. **Delete the config package** and remove it from all `devDependencies`.
|
|
47
|
+
|
|
48
|
+
## General Cleanup
|
|
49
|
+
|
|
50
|
+
- Remove turbo-specific dependencies: `turbo`, `eslint-plugin-turbo`.
|
|
51
|
+
- Delete all `turbo.json` files (root and per-package).
|
|
52
|
+
- Run workspace validation (`nx run-many -t build lint test typecheck`) to confirm nothing broke.
|
|
53
|
+
|
|
54
|
+
## Key Pitfalls
|
|
55
|
+
|
|
56
|
+
- **Trace the full inheritance chain** before inlining — check what each variant inherits from the base.
|
|
57
|
+
- **Module resolution changes** — from Node package resolution (`@repo/...`) to relative paths (`../../tsconfig.base.json`).
|
|
58
|
+
- **ESLint configs are JavaScript, not JSON** — handle JS imports, array spreading, and plugin objects when merging.
|
|
59
|
+
|
|
60
|
+
Helpful docs:
|
|
61
|
+
|
|
62
|
+
- https://nx.dev/docs/guides/adopting-nx/from-turborepo
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
## Vite
|
|
2
|
+
|
|
3
|
+
Vite-specific guidance for `nx import`. For generic import issues (pnpm globs, root deps, project references, name collisions, ESLint, frontend tsconfig base settings, `@nx/react` typings, Jest preset, non-Nx source handling), see `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### `@nx/vite/plugin` Typecheck Target
|
|
8
|
+
|
|
9
|
+
`@nx/vite/plugin` defaults `typecheckTargetName` to `"vite:typecheck"`. If the workspace expects `"typecheck"`, set it explicitly in `nx.json`. If `@nx/js/typescript` is also registered, rename one target to avoid conflicts (e.g. `"tsc-typecheck"` for the JS plugin).
|
|
10
|
+
|
|
11
|
+
Keep both plugins only if the workspace has non-Vite pure TS libraries — `@nx/js/typescript` handles those while `@nx/vite/plugin` handles Vite projects.
|
|
12
|
+
|
|
13
|
+
### @nx/vite Plugin Install Failure
|
|
14
|
+
|
|
15
|
+
Plugin init loads `vite.config.ts` before deps are available. **Fix**: `pnpm add -wD vite @vitejs/plugin-react` (or `@vitejs/plugin-vue`) first, then `pnpm exec nx add @nx/vite`.
|
|
16
|
+
|
|
17
|
+
### Vite `resolve.alias` and `__dirname` (Non-Nx Sources)
|
|
18
|
+
|
|
19
|
+
**`__dirname` undefined** (CJS-only): Replace with `fileURLToPath(new URL('./src', import.meta.url))` from `'node:url'`.
|
|
20
|
+
|
|
21
|
+
**`@/` path alias**: Vite's `resolve.alias` works at runtime but TS needs matching `"paths"`. Set `"baseUrl": "."` in project tsconfig.
|
|
22
|
+
|
|
23
|
+
**PostCSS/Tailwind**: Verify `content` globs resolve correctly after import.
|
|
24
|
+
|
|
25
|
+
### Missing TypeScript `types` (Non-Nx Sources)
|
|
26
|
+
|
|
27
|
+
Non-Nx tsconfigs may not declare all needed types. Ensure Vite projects include `"types": ["node", "vite/client"]` in their tsconfig.
|
|
28
|
+
|
|
29
|
+
### `noEmit` Fix: Vite-Specific Notes
|
|
30
|
+
|
|
31
|
+
See SKILL.md for the generic noEmit→composite fix. Vite-specific additions:
|
|
32
|
+
|
|
33
|
+
- Non-Nx Vite projects often have **both** `tsconfig.app.json` and `tsconfig.node.json` with `noEmit` — fix both
|
|
34
|
+
- Solution-style tsconfigs (`"files": [], "references": [...]`) may lack `extends`. Add `extends` pointing to the dest root `tsconfig.base.json` so base settings (`moduleResolution`, `lib`) apply.
|
|
35
|
+
- This is safe — Vite/Vitest ignore TypeScript emit settings.
|
|
36
|
+
|
|
37
|
+
### Dependency Version Conflicts
|
|
38
|
+
|
|
39
|
+
**Shared Vite deps (both frameworks):** `vite`, `vitest`, `jsdom`, `@types/node`, `typescript` (dev)
|
|
40
|
+
|
|
41
|
+
**Vite 6→7**: Typecheck fails (`Plugin<any>` type mismatch); build/serve still works. Fix: align versions.
|
|
42
|
+
**Vitest 3→4**: Usually works; type conflicts may surface in shared test utils.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## React Router 7 (Vite-Based)
|
|
47
|
+
|
|
48
|
+
React Router 7 (`@react-router/dev`) uses Vite under the hood with a `vite.config.ts` and a `react-router.config.ts`. The `@nx/vite/plugin` detects `vite.config.ts` and creates inferred targets.
|
|
49
|
+
|
|
50
|
+
### Targets
|
|
51
|
+
|
|
52
|
+
`@nx/vite/plugin` creates `build`, `dev`, `serve` targets. The `build` target invokes the script defined in `package.json` (usually `react-router build`), not `vite build` directly.
|
|
53
|
+
|
|
54
|
+
**No separate typecheck target from `@nx/vite/plugin`** — React Router 7 typegen is run as part of `typecheck` (e.g. `react-router typegen && tsc`). The `typecheck` target is inferred from the tsconfig. Keep the `typecheck` script in `package.json` if present; it is not rewritten.
|
|
55
|
+
|
|
56
|
+
### tsconfig Notes
|
|
57
|
+
|
|
58
|
+
React Router 7 uses a single `tsconfig.json` (no `tsconfig.app.json`/`tsconfig.node.json` split). It includes:
|
|
59
|
+
|
|
60
|
+
- `"rootDirs": [".", "./.react-router/types"]` — for generated type files; keep as-is
|
|
61
|
+
- `"paths": { "~/*": ["./app/*"] }` — self-referential alias; keep as-is
|
|
62
|
+
- `"noEmit": true` — replace with composite settings per SKILL.md
|
|
63
|
+
|
|
64
|
+
### Build Output
|
|
65
|
+
|
|
66
|
+
React Router 7 outputs to `build/` (not `dist/`). Add `build` to the dest root `.gitignore`.
|
|
67
|
+
|
|
68
|
+
### Generated Types Directory
|
|
69
|
+
|
|
70
|
+
React Router 7 generates `.react-router/` at the project root for route type generation. Add `.react-router` to the dest root `.gitignore`.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## TanStack Start (Vite-Based)
|
|
75
|
+
|
|
76
|
+
TanStack Start uses Vinxi under the hood, which wraps Vite. Projects have a standard `vite.config.ts` that `@nx/vite/plugin` detects normally.
|
|
77
|
+
|
|
78
|
+
### Targets
|
|
79
|
+
|
|
80
|
+
`@nx/vite/plugin` creates `build`, `dev`, `preview`, `serve-static`, `typecheck` targets. The `build` target runs `vite build` which invokes the TanStack Start Vinxi pipeline (produces both client and SSR bundles).
|
|
81
|
+
|
|
82
|
+
### tsconfig Notes
|
|
83
|
+
|
|
84
|
+
TanStack Start uses a single `tsconfig.json` with `"allowImportingTsExtensions": true` and `"noEmit": true`. Apply the standard noEmit → composite fix. `allowImportingTsExtensions` is compatible with `emitDeclarationOnly: true` — no change needed.
|
|
85
|
+
|
|
86
|
+
### `paths` Aliases
|
|
87
|
+
|
|
88
|
+
TanStack Start commonly uses `"#/*": ["./src/*"]` and `"@/*": ["./src/*"]`. These are self-referential — keep as-is for a single-project app.
|
|
89
|
+
|
|
90
|
+
### Uncommitted Source Repo
|
|
91
|
+
|
|
92
|
+
`create-tan-stack` initializes a git repo but does NOT make an initial commit. Before importing, commit first:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git -C /path/to/source add . && git -C /path/to/source commit -m "Initial commit"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Generated and Build Directories
|
|
99
|
+
|
|
100
|
+
TanStack Start / Vinxi / Nitro generate several directories that must be added to the dest root `.gitignore`:
|
|
101
|
+
|
|
102
|
+
- `.vinxi` — Vinxi build cache
|
|
103
|
+
- `.tanstack` — TanStack generated files
|
|
104
|
+
- `.nitro` — Nitro build artifacts
|
|
105
|
+
- `.output` — server-side build output (SSR/edge)
|
|
106
|
+
|
|
107
|
+
These are not covered by `dist` or `build`.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## React-Specific
|
|
112
|
+
|
|
113
|
+
### React Dependencies
|
|
114
|
+
|
|
115
|
+
**Production:** `react`, `react-dom`
|
|
116
|
+
**Dev:** `@types/react`, `@types/react-dom`, `@vitejs/plugin-react`, `@testing-library/react`, `@testing-library/jest-dom`, `jsdom`
|
|
117
|
+
**ESLint (Nx sources):** `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks`
|
|
118
|
+
**ESLint (`create-vite`):** `eslint-plugin-react-refresh`, `eslint-plugin-react-hooks` — self-contained flat configs can be left as-is
|
|
119
|
+
**Nx plugins:** `@nx/react` (generators), `@nx/vite`, `@nx/vitest`, `@nx/eslint`
|
|
120
|
+
|
|
121
|
+
### React TypeScript Configuration
|
|
122
|
+
|
|
123
|
+
Add `"jsx": "react-jsx"` — in `tsconfig.base.json` for single-framework workspaces, per-project for mixed (see Mixed section).
|
|
124
|
+
|
|
125
|
+
### React ESLint Config
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
import nx from '@nx/eslint-plugin';
|
|
129
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
130
|
+
export default [...baseConfig, ...nx.configs['flat/react'], { files: ['**/*.ts', '**/*.tsx'], rules: {} }];
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### React Version Conflicts
|
|
134
|
+
|
|
135
|
+
React 18 (source) + React 19 (dest): pnpm may hoist mismatched `react-dom`, causing `TypeError: Cannot read properties of undefined (reading 'S')`. **Fix**: Align versions with `pnpm.overrides`.
|
|
136
|
+
|
|
137
|
+
### `@testing-library/jest-dom` with Vitest
|
|
138
|
+
|
|
139
|
+
If source used Jest: change import to `@testing-library/jest-dom/vitest` in test-setup.ts, add to tsconfig `types`.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Vue-Specific
|
|
144
|
+
|
|
145
|
+
### Vue Dependencies
|
|
146
|
+
|
|
147
|
+
**Production:** `vue` (plus `vue-router`, `pinia` if used)
|
|
148
|
+
**Dev:** `@vitejs/plugin-vue`, `vue-tsc`, `@vue/test-utils`, `jsdom`
|
|
149
|
+
**ESLint:** `eslint-plugin-vue`, `vue-eslint-parser`, `@vue/eslint-config-typescript`, `@vue/eslint-config-prettier`
|
|
150
|
+
**Nx plugins:** `@nx/vue` (generators), `@nx/vite`, `@nx/vitest`, `@nx/eslint` (install AFTER deps — see below)
|
|
151
|
+
|
|
152
|
+
### Vue TypeScript Configuration
|
|
153
|
+
|
|
154
|
+
Add to `tsconfig.base.json` (single-framework) or per-project (mixed):
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{ "jsx": "preserve", "jsxImportSource": "vue", "resolveJsonModule": true }
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `vue-shims.d.ts`
|
|
161
|
+
|
|
162
|
+
Vue SFC files need a type declaration. Usually exists in each project's `src/` and imports cleanly. If missing:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
declare module '*.vue' {
|
|
166
|
+
import { defineComponent } from 'vue';
|
|
167
|
+
const component: ReturnType<typeof defineComponent>;
|
|
168
|
+
export default component;
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### `vue-tsc` Auto-Detection
|
|
173
|
+
|
|
174
|
+
Both `@nx/js/typescript` and `@nx/vite/plugin` auto-detect `vue-tsc` when installed — no manual config needed. Remove source scripts like `"typecheck": "vue-tsc --noEmit"`.
|
|
175
|
+
|
|
176
|
+
### ESLint Plugin Installation Order (Critical)
|
|
177
|
+
|
|
178
|
+
`@nx/eslint` init **crashes** if Vue ESLint deps aren't installed first (it loads all config files).
|
|
179
|
+
|
|
180
|
+
**Correct order:**
|
|
181
|
+
|
|
182
|
+
1. `pnpm add -wD eslint@^9 eslint-plugin-vue vue-eslint-parser @vue/eslint-config-typescript @typescript-eslint/parser @nx/eslint-plugin typescript-eslint`
|
|
183
|
+
2. Create root `eslint.config.mjs`
|
|
184
|
+
3. Then `npx nx add @nx/eslint`
|
|
185
|
+
|
|
186
|
+
### Vue ESLint Config Pattern
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
import vue from 'eslint-plugin-vue';
|
|
190
|
+
import vueParser from 'vue-eslint-parser';
|
|
191
|
+
import tsParser from '@typescript-eslint/parser';
|
|
192
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
193
|
+
export default [
|
|
194
|
+
...baseConfig,
|
|
195
|
+
...vue.configs['flat/recommended'],
|
|
196
|
+
{
|
|
197
|
+
files: ['**/*.vue'],
|
|
198
|
+
languageOptions: { parser: vueParser, parserOptions: { parser: tsParser } },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
|
|
202
|
+
rules: { 'vue/multi-word-component-names': 'off' },
|
|
203
|
+
},
|
|
204
|
+
];
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Important**: `vue-eslint-parser` override must come **AFTER** base config — `flat/typescript` sets the TS parser globally without a `files` filter, breaking `.vue` parsing.
|
|
208
|
+
|
|
209
|
+
`vue-eslint-parser` must be an explicit pnpm dependency (strict resolution prevents transitive import).
|
|
210
|
+
|
|
211
|
+
**Known issue**: Some generated Vue ESLint configs omit `vue-eslint-parser`. Use the pattern above instead.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Mixed React + Vue
|
|
216
|
+
|
|
217
|
+
When both frameworks coexist, several settings become per-project.
|
|
218
|
+
|
|
219
|
+
### tsconfig `jsx` — Per-Project Only
|
|
220
|
+
|
|
221
|
+
- React: `"jsx": "react-jsx"` in project tsconfig
|
|
222
|
+
- Vue: `"jsx": "preserve"`, `"jsxImportSource": "vue"` in project tsconfig
|
|
223
|
+
- Root: **NO** `jsx` setting
|
|
224
|
+
|
|
225
|
+
### Typecheck — Auto-Detects Framework
|
|
226
|
+
|
|
227
|
+
`@nx/vite/plugin` uses `vue-tsc` for Vue projects and `tsc` for React automatically.
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"plugins": [
|
|
232
|
+
{ "plugin": "@nx/eslint/plugin", "options": { "targetName": "lint" } },
|
|
233
|
+
{
|
|
234
|
+
"plugin": "@nx/vite/plugin",
|
|
235
|
+
"options": {
|
|
236
|
+
"buildTargetName": "build",
|
|
237
|
+
"typecheckTargetName": "typecheck",
|
|
238
|
+
"testTargetName": "test"
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Remove `@nx/js/typescript` if all projects use Vite. Keep it (renamed to `"tsc-typecheck"`) only for non-Vite pure TS libs.
|
|
246
|
+
|
|
247
|
+
### ESLint — Three-Tier Config
|
|
248
|
+
|
|
249
|
+
1. **Root**: Base rules only, no framework-specific rules
|
|
250
|
+
2. **React projects**: Extend root + `nx.configs['flat/react']`
|
|
251
|
+
3. **Vue projects**: Extend root + `vue.configs['flat/recommended']` + `vue-eslint-parser`
|
|
252
|
+
|
|
253
|
+
**Required packages**: Shared (`eslint@^9`, `@nx/eslint-plugin`, `typescript-eslint`, `@typescript-eslint/parser`), React (`eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks`), Vue (`eslint-plugin-vue`, `vue-eslint-parser`)
|
|
254
|
+
|
|
255
|
+
`@nx/react`/`@nx/vue` are for generators only — no target conflicts.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Redundant npm Scripts After Import
|
|
260
|
+
|
|
261
|
+
`nx import` copies `package.json` verbatim, so npm scripts come along. For Vite-based projects `@nx/vite/plugin` already infers the same targets from `vite.config.ts` — the npm scripts just shadow the plugin with weaker `nx:run-script` wrappers (no first-class caching inputs/outputs). Remove them after import.
|
|
262
|
+
|
|
263
|
+
### Standalone Vite App (`create-vite`)
|
|
264
|
+
|
|
265
|
+
Remove the following scripts — every one is redundant:
|
|
266
|
+
|
|
267
|
+
| Script | Plugin replacement |
|
|
268
|
+
| ----------------------------- | ---------------------------------------------------------------------------- |
|
|
269
|
+
| `dev: vite` | `@nx/vite/plugin` → `dev` |
|
|
270
|
+
| `build: tsc -b && vite build` | `@nx/vite/plugin` → `build`; `typecheck` via `@nx/js/typescript` handles tsc |
|
|
271
|
+
| `preview: vite preview` | `@nx/vite/plugin` → `preview` |
|
|
272
|
+
| `lint: eslint .` | `@nx/eslint/plugin` → `eslint:lint` |
|
|
273
|
+
|
|
274
|
+
### TanStack Start
|
|
275
|
+
|
|
276
|
+
Remove `build`, `dev`, `preview`, and `test` scripts, but move any hardcoded `--port` flag to `vite.config.ts` first:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
// vite.config.ts
|
|
280
|
+
export default defineConfig({
|
|
281
|
+
server: { port: 3000 }, // replaces `vite dev --port 3000`
|
|
282
|
+
...
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### React Router 7 — Keep ALL scripts
|
|
287
|
+
|
|
288
|
+
Do **not** remove React Router 7 scripts. They use the framework CLI (`react-router build`, `react-router dev`, `react-router-serve`) which is not interchangeable with plain `vite`:
|
|
289
|
+
|
|
290
|
+
- `typecheck` runs `react-router typegen && tsc` — typegen must precede `tsc` or it fails on missing route types
|
|
291
|
+
- `start` serves the SSR bundle — no plugin equivalent
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Fix Orders
|
|
296
|
+
|
|
297
|
+
### Nx Source
|
|
298
|
+
|
|
299
|
+
1. Generic fixes from SKILL.md (pnpm globs, root deps, executor paths, frontend tsconfig base settings, `@nx/react` typings)
|
|
300
|
+
2. Configure `@nx/vite/plugin` typecheck target
|
|
301
|
+
3. **React**: `jsx: "react-jsx"` (root or per-project)
|
|
302
|
+
4. **Vue**: `jsx: "preserve"` + `jsxImportSource: "vue"`; verify `vue-shims.d.ts`; install ESLint deps before `@nx/eslint`
|
|
303
|
+
5. **Mixed**: `jsx` per-project; remove/rename `@nx/js/typescript`
|
|
304
|
+
6. `nx sync --yes && nx reset && nx run-many -t typecheck,build,test,lint`
|
|
305
|
+
|
|
306
|
+
### Non-Nx Source (additional steps)
|
|
307
|
+
|
|
308
|
+
0. Import into `apps/<name>` (see SKILL.md: "Application vs Library Detection")
|
|
309
|
+
1. Generic fixes from SKILL.md (stale files cleanup, pnpm globs, rewritten scripts, target name prefixing, noEmit→composite, ESLint handling)
|
|
310
|
+
2. Fix `noEmit` in **all** tsconfigs (app, node, etc. — non-Nx projects often have multiple)
|
|
311
|
+
3. Add `extends` to solution-style tsconfigs so root settings apply
|
|
312
|
+
4. Fix `resolve.alias` / `__dirname` / `baseUrl`
|
|
313
|
+
5. Ensure `types` include `vite/client` and `node`
|
|
314
|
+
6. Install `@nx/vite` manually if it failed during import
|
|
315
|
+
7. Remove redundant npm scripts so `@nx/vite/plugin` infers them natively (see "Redundant npm Scripts" section)
|
|
316
|
+
8. **Vue**: Add `outDir` + `**/*.vue.d.ts` to ESLint ignores
|
|
317
|
+
9. Full verification
|
|
318
|
+
|
|
319
|
+
### Multiple-Source Imports
|
|
320
|
+
|
|
321
|
+
See SKILL.md for generic multi-import (name collisions, dep refs). Vite-specific: fix tsconfig `references` paths for alternate directories (`../../libs/` → `../../libs-beta/`).
|
|
322
|
+
|
|
323
|
+
### Non-Nx Source: React Router 7
|
|
324
|
+
|
|
325
|
+
1. Ensure source has at least one commit (see SKILL.md: "Source Repo Has No Commits")
|
|
326
|
+
2. `nx import` whole-repo into `apps/<name>` (see SKILL.md: "Application vs Library Detection") → auto-installs `@nx/vite`, `@nx/react`
|
|
327
|
+
3. Stale file cleanup: `node_modules/`, `package-lock.json`, `.gitignore`
|
|
328
|
+
4. Fix `tsconfig.json`: `noEmit` → `composite + emitDeclarationOnly + outDir + tsBuildInfoFile`
|
|
329
|
+
5. Add `build` and `.react-router` to dest root `.gitignore`
|
|
330
|
+
6. **Keep all npm scripts** — React Router 7 uses framework CLI (`react-router build/dev`), not plain vite (see "Redundant npm Scripts" above)
|
|
331
|
+
7. `npm install && nx reset && nx sync --yes`
|
|
332
|
+
|
|
333
|
+
### Non-Nx Source: TanStack Start
|
|
334
|
+
|
|
335
|
+
1. Ensure source has at least one commit — `create-tan-stack` does NOT auto-commit (see SKILL.md)
|
|
336
|
+
2. `nx import` whole-repo into `apps/<name>` (see SKILL.md: "Application vs Library Detection") → auto-installs `@nx/vite`, `@nx/vitest`
|
|
337
|
+
3. Stale file cleanup: `node_modules/`, `package-lock.json`, `.gitignore`
|
|
338
|
+
4. Fix `tsconfig.json`: `noEmit` → `composite + emitDeclarationOnly + outDir + tsBuildInfoFile`
|
|
339
|
+
5. Keep `allowImportingTsExtensions` — compatible with `emitDeclarationOnly: true`
|
|
340
|
+
6. Add `.vinxi`, `.tanstack`, `.nitro`, `.output` to dest root `.gitignore`
|
|
341
|
+
7. Move hardcoded `--port` from `dev` script into `vite.config.ts` (`server: { port: N }`)
|
|
342
|
+
8. Remove redundant npm scripts — `@nx/vite/plugin` infers `build`, `dev`, `preview`, `test` (see "Redundant npm Scripts" above)
|
|
343
|
+
9. `npm install && nx reset && nx sync --yes`
|
|
344
|
+
|
|
345
|
+
### Quick Reference: React vs Vue
|
|
346
|
+
|
|
347
|
+
| Aspect | React | Vue |
|
|
348
|
+
| ------------- | ------------------------ | ----------------------------------------- |
|
|
349
|
+
| Vite plugin | `@vitejs/plugin-react` | `@vitejs/plugin-vue` |
|
|
350
|
+
| Type checker | `tsc` | `vue-tsc` (auto-detected) |
|
|
351
|
+
| SFC support | N/A | `vue-shims.d.ts` needed |
|
|
352
|
+
| tsconfig jsx | `"react-jsx"` | `"preserve"` + `"jsxImportSource": "vue"` |
|
|
353
|
+
| ESLint parser | Standard TS | `vue-eslint-parser` + TS sub-parser |
|
|
354
|
+
| ESLint setup | Straightforward | Must install deps before `@nx/eslint` |
|
|
355
|
+
| Test utils | `@testing-library/react` | `@vue/test-utils` |
|
|
356
|
+
|
|
357
|
+
### Quick Reference: Vite-Based React Frameworks
|
|
358
|
+
|
|
359
|
+
| Aspect | Vite (standalone) | React Router 7 | TanStack Start |
|
|
360
|
+
| ------------------ | ----------------- | ----------------------- | ------------------------ |
|
|
361
|
+
| Build config | `vite.config.ts` | `vite.config.ts` | `vite.config.ts` |
|
|
362
|
+
| Build output | `dist/` | `build/` | `dist/` |
|
|
363
|
+
| SSR bundle | No | Yes (`build/server/`) | Yes (`dist/server/`) |
|
|
364
|
+
| tsconfig layout | app + node split | Single tsconfig | Single tsconfig |
|
|
365
|
+
| Auto-committed | Depends on tool | Usually yes | **No — commit first** |
|
|
366
|
+
| `nx import` plugin | `@nx/vite` | `@nx/vite`, `@nx/react` | `@nx/vite`, `@nx/vitest` |
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Iteration Log
|
|
371
|
+
|
|
372
|
+
### Scenario 6: Multiple non-Nx React apps (CRA, Next.js, React Router 7, TanStack Start, Vite) → TS preset (PASS)
|
|
373
|
+
|
|
374
|
+
- Sources: 5 standalone non-Nx repos with different build tools
|
|
375
|
+
- Dest: CNW ts preset (Nx 22.5.1), npm workspaces, `packages/*`
|
|
376
|
+
- Import: whole-repo for each, sequential into `packages/<name>`
|
|
377
|
+
- Pre-import fixes:
|
|
378
|
+
1. Removed `packages/.gitkeep` and committed
|
|
379
|
+
2. `git init && git add . && git commit` in Vite app (no git at all)
|
|
380
|
+
3. `git add . && git commit` in TanStack app (git init'd but no commits)
|
|
381
|
+
- Import: `npm exec nx -- import <source> packages/<name> --source=. --ref=main --no-interactive`
|
|
382
|
+
- Next.js import auto-installed `@nx/eslint`, `@nx/next`
|
|
383
|
+
- React Router 7 import auto-installed `@nx/vite`, `@nx/react`, `@nx/docker` (Dockerfile present)
|
|
384
|
+
- TanStack import auto-installed `@nx/vitest`
|
|
385
|
+
- Post-import fixes:
|
|
386
|
+
1. Removed stale `node_modules/`, `package-lock.json`, `.gitignore` from each package
|
|
387
|
+
2. Removed Nx-rewritten scripts from `board-games-nextjs/package.json` (had `"build": "nx next:build"`, etc.)
|
|
388
|
+
3. Updated root `tsconfig.base.json`: `nodenext` → `bundler`, added `dom`/`dom.iterable` to lib, added `jsx: react-jsx`
|
|
389
|
+
4. Added `build` to dest root `.gitignore` (CRA and React Router 7 output there)
|
|
390
|
+
5. Fixed `noEmit` → `composite + emitDeclarationOnly` in: `board-games-vite/tsconfig.app.json`, `board-games-vite/tsconfig.node.json`, `board-games-react-router/tsconfig.json`, `board-games-tanstack/tsconfig.json`
|
|
391
|
+
6. Fixed `tsBuildInfoFile` paths from `./node_modules/.tmp/...` to `./dist/...`
|
|
392
|
+
7. Installed root `@types/react`, `@types/react-dom`, `@types/node`
|
|
393
|
+
- All targets green: `build` for all 5 projects; `typecheck` for Vite/React Router/TanStack; `next:build` for Next.js
|