@nx/vite 23.0.0-beta.0 → 23.0.0-beta.10
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/executors.d.ts +0 -2
- package/executors.d.ts.map +1 -1
- package/executors.js +1 -3
- package/executors.json +0 -10
- package/generators.json +0 -5
- package/index.d.ts +0 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -3
- package/migrations.json +37 -0
- package/package.json +7 -8
- package/src/executors/build/build.impl.d.ts.map +1 -1
- package/src/executors/build/build.impl.js +5 -3
- package/src/executors/build/schema.json +1 -0
- package/src/executors/dev-server/dev-server.impl.d.ts.map +1 -1
- package/src/executors/dev-server/dev-server.impl.js +2 -0
- package/src/executors/dev-server/schema.json +1 -0
- package/src/executors/preview-server/preview-server.impl.d.ts.map +1 -1
- package/src/executors/preview-server/preview-server.impl.js +2 -0
- package/src/executors/preview-server/schema.json +1 -0
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +14 -3
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js +4 -12
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js +2 -2
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts +1 -1
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts.map +1 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts +1 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts.map +1 -1
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +2 -3
- package/src/generators/init/lib/utils.d.ts.map +1 -1
- package/src/generators/init/lib/utils.js +0 -3
- package/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.d.ts.map +1 -1
- package/src/migrations/update-22-2-0/migrate-vitest-to-vitest-package.js +2 -2
- package/src/migrations/update-23-0-0/create-ai-instructions-for-vite-8.d.ts +3 -0
- package/src/migrations/update-23-0-0/create-ai-instructions-for-vite-8.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/create-ai-instructions-for-vite-8.js +16 -0
- package/src/migrations/update-23-0-0/ensure-vitest-package-migration.d.ts +3 -0
- package/src/migrations/update-23-0-0/ensure-vitest-package-migration.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/ensure-vitest-package-migration.js +205 -0
- package/src/migrations/update-23-0-0/files/ai-instructions-for-vite-8.md +250 -0
- package/src/migrations/update-23-0-0/rename-rollup-options-to-rolldown-options.d.ts +3 -0
- package/src/migrations/update-23-0-0/rename-rollup-options-to-rolldown-options.d.ts.map +1 -0
- package/src/migrations/update-23-0-0/rename-rollup-options-to-rolldown-options.js +36 -0
- package/src/plugins/plugin.d.ts +0 -9
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +20 -211
- package/src/utils/deprecation.d.ts +8 -0
- package/src/utils/deprecation.d.ts.map +1 -0
- package/src/utils/deprecation.js +31 -0
- package/src/utils/e2e-web-server-info-utils.d.ts +2 -2
- package/src/utils/e2e-web-server-info-utils.d.ts.map +1 -1
- package/src/utils/e2e-web-server-info-utils.js +3 -3
- package/src/utils/ensure-dependencies.d.ts +0 -1
- package/src/utils/ensure-dependencies.d.ts.map +1 -1
- package/src/utils/ensure-dependencies.js +5 -20
- package/src/utils/executor-utils.d.ts +0 -1
- package/src/utils/executor-utils.d.ts.map +1 -1
- package/src/utils/executor-utils.js +0 -4
- package/src/utils/generator-utils.d.ts +0 -2
- package/src/utils/generator-utils.d.ts.map +1 -1
- package/src/utils/generator-utils.js +2 -30
- package/src/utils/options-utils.d.ts.map +1 -1
- package/src/utils/options-utils.js +0 -3
- package/src/utils/version-utils.d.ts +0 -11
- package/src/utils/version-utils.d.ts.map +1 -1
- package/src/utils/version-utils.js +0 -61
- package/src/utils/versions.d.ts +0 -19
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +1 -22
- package/src/executors/test/compat.d.ts +0 -3
- package/src/executors/test/compat.d.ts.map +0 -1
- package/src/executors/test/compat.js +0 -6
- package/src/executors/test/lib/nx-reporter.d.ts +0 -19
- package/src/executors/test/lib/nx-reporter.d.ts.map +0 -1
- package/src/executors/test/lib/nx-reporter.js +0 -39
- package/src/executors/test/lib/utils.d.ts +0 -5
- package/src/executors/test/lib/utils.d.ts.map +0 -1
- package/src/executors/test/lib/utils.js +0 -68
- package/src/executors/test/schema.d.ts +0 -7
- package/src/executors/test/schema.json +0 -36
- package/src/executors/test/vitest.impl.d.ts +0 -10
- package/src/executors/test/vitest.impl.d.ts.map +0 -1
- package/src/executors/test/vitest.impl.js +0 -49
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts +0 -6
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.js +0 -56
- package/src/generators/vitest/files/tsconfig.spec.json__tmpl__ +0 -22
- package/src/generators/vitest/schema.d.ts +0 -15
- package/src/generators/vitest/schema.json +0 -65
- package/src/generators/vitest/vitest-generator.d.ts +0 -8
- package/src/generators/vitest/vitest-generator.d.ts.map +0 -1
- package/src/generators/vitest/vitest-generator.js +0 -51
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ensureVitestPackageMigration;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
// @nx/vite no longer infers vitest targets, nor provides vitest executor.
|
|
8
|
+
// - swap @nx/vite:test -> @nx/vitest:test
|
|
9
|
+
// - register @nx/vitest plugin
|
|
10
|
+
async function ensureVitestPackageMigration(tree) {
|
|
11
|
+
const migratedExecutors = migrateExecutorUsages(tree);
|
|
12
|
+
const migratedPlugins = migratePluginConfigurations(tree);
|
|
13
|
+
const migratedTargetDefaults = migrateTargetDefaults(tree);
|
|
14
|
+
const registeredVitestPlugin = await ensureVitestPluginRegistration(tree);
|
|
15
|
+
if (migratedExecutors ||
|
|
16
|
+
migratedPlugins ||
|
|
17
|
+
migratedTargetDefaults ||
|
|
18
|
+
registeredVitestPlugin) {
|
|
19
|
+
const installTask = installVitestPackage(tree);
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
return installTask;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return () => { };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function installVitestPackage(tree) {
|
|
28
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
29
|
+
const hasNxVitest = packageJson.dependencies?.['@nx/vitest'] ||
|
|
30
|
+
packageJson.devDependencies?.['@nx/vitest'];
|
|
31
|
+
if (hasNxVitest) {
|
|
32
|
+
return () => { };
|
|
33
|
+
}
|
|
34
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/vitest': versions_1.nxVersion });
|
|
35
|
+
}
|
|
36
|
+
function migrateExecutorUsages(tree) {
|
|
37
|
+
const projectsToUpdate = new Set();
|
|
38
|
+
(0, internal_1.forEachExecutorOptions)(tree, '@nx/vite:test', (_options, projectName) => {
|
|
39
|
+
projectsToUpdate.add(projectName);
|
|
40
|
+
});
|
|
41
|
+
if (projectsToUpdate.size === 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
for (const projectName of projectsToUpdate) {
|
|
45
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
46
|
+
for (const target of Object.values(projectConfig.targets ?? {})) {
|
|
47
|
+
if (target.executor === '@nx/vite:test') {
|
|
48
|
+
target.executor = '@nx/vitest:test';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
function migratePluginConfigurations(tree) {
|
|
56
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
57
|
+
if (!nxJson?.plugins) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const newPlugins = [];
|
|
61
|
+
let changed = false;
|
|
62
|
+
for (const plugin of nxJson.plugins) {
|
|
63
|
+
if (typeof plugin === 'string' || plugin.plugin !== '@nx/vite/plugin') {
|
|
64
|
+
newPlugins.push(plugin);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const options = plugin.options || {};
|
|
68
|
+
const { testTargetName, ciTargetName, ciGroupName, ...viteOptions } = options;
|
|
69
|
+
if (!testTargetName && !ciTargetName && !ciGroupName) {
|
|
70
|
+
newPlugins.push(plugin);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const vitestOptions = {};
|
|
74
|
+
if (testTargetName)
|
|
75
|
+
vitestOptions.testTargetName = testTargetName;
|
|
76
|
+
if (ciTargetName)
|
|
77
|
+
vitestOptions.ciTargetName = ciTargetName;
|
|
78
|
+
if (ciGroupName)
|
|
79
|
+
vitestOptions.ciGroupName = ciGroupName;
|
|
80
|
+
const vitestPlugin = { plugin: '@nx/vitest' };
|
|
81
|
+
if (Object.keys(vitestOptions).length > 0) {
|
|
82
|
+
vitestPlugin.options = vitestOptions;
|
|
83
|
+
}
|
|
84
|
+
if (plugin.include)
|
|
85
|
+
vitestPlugin.include = plugin.include;
|
|
86
|
+
if (plugin.exclude)
|
|
87
|
+
vitestPlugin.exclude = plugin.exclude;
|
|
88
|
+
const updatedVitePlugin = { ...plugin };
|
|
89
|
+
if (Object.keys(viteOptions).length > 0) {
|
|
90
|
+
updatedVitePlugin.options = viteOptions;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
delete updatedVitePlugin.options;
|
|
94
|
+
}
|
|
95
|
+
newPlugins.push(updatedVitePlugin);
|
|
96
|
+
newPlugins.push(vitestPlugin);
|
|
97
|
+
changed = true;
|
|
98
|
+
}
|
|
99
|
+
if (!changed) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
nxJson.plugins = newPlugins;
|
|
103
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
function migrateTargetDefaults(tree) {
|
|
107
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
108
|
+
if (!nxJson?.targetDefaults) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
let hasChanges = false;
|
|
112
|
+
for (const [targetOrExecutor, targetConfig] of Object.entries(nxJson.targetDefaults)) {
|
|
113
|
+
if (targetOrExecutor === '@nx/vite:test') {
|
|
114
|
+
nxJson.targetDefaults['@nx/vitest:test'] ??= {};
|
|
115
|
+
Object.assign(nxJson.targetDefaults['@nx/vitest:test'], targetConfig);
|
|
116
|
+
delete nxJson.targetDefaults['@nx/vite:test'];
|
|
117
|
+
hasChanges = true;
|
|
118
|
+
}
|
|
119
|
+
else if (targetConfig.executor === '@nx/vite:test') {
|
|
120
|
+
targetConfig.executor = '@nx/vitest:test';
|
|
121
|
+
hasChanges = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (hasChanges) {
|
|
125
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
126
|
+
}
|
|
127
|
+
return hasChanges;
|
|
128
|
+
}
|
|
129
|
+
async function ensureVitestPluginRegistration(tree) {
|
|
130
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
131
|
+
if (!nxJson?.plugins?.length) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const vitePluginRegistrations = nxJson.plugins.filter((p) => typeof p === 'string'
|
|
135
|
+
? p === '@nx/vite/plugin'
|
|
136
|
+
: p.plugin === '@nx/vite/plugin');
|
|
137
|
+
if (vitePluginRegistrations.length === 0) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
// Only register @nx/vitest when the workspace actually uses vitest.
|
|
141
|
+
// Otherwise we'd add a plugin (and trigger an install) for vite-only setups.
|
|
142
|
+
if (!(await workspaceUsesVitest(tree))) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
// Skip @nx/vite/plugin entries whose scope already has a matching @nx/vitest.
|
|
146
|
+
// Mixed-shape configs (one scope split by migratePluginConfigurations, another
|
|
147
|
+
// bare) need per-scope checks rather than a global short-circuit.
|
|
148
|
+
const coveredScopes = new Set(nxJson.plugins
|
|
149
|
+
.filter((p) => typeof p === 'string' ? p === '@nx/vitest' : p.plugin === '@nx/vitest')
|
|
150
|
+
.map((p) => scopeKey(typeof p === 'string' ? { plugin: p } : p)));
|
|
151
|
+
let added = false;
|
|
152
|
+
for (const vitePlugin of vitePluginRegistrations) {
|
|
153
|
+
const vitestPlugin = { plugin: '@nx/vitest' };
|
|
154
|
+
if (typeof vitePlugin !== 'string') {
|
|
155
|
+
if (vitePlugin.include) {
|
|
156
|
+
vitestPlugin.include = vitePlugin.include;
|
|
157
|
+
}
|
|
158
|
+
if (vitePlugin.exclude) {
|
|
159
|
+
vitestPlugin.exclude = vitePlugin.exclude;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (coveredScopes.has(scopeKey(vitestPlugin))) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
nxJson.plugins.push(vitestPlugin);
|
|
166
|
+
coveredScopes.add(scopeKey(vitestPlugin));
|
|
167
|
+
added = true;
|
|
168
|
+
}
|
|
169
|
+
if (!added) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
function scopeKey(entry) {
|
|
176
|
+
return [
|
|
177
|
+
(entry.include ?? []).join(','),
|
|
178
|
+
(entry.exclude ?? []).join(','),
|
|
179
|
+
].join('|');
|
|
180
|
+
}
|
|
181
|
+
async function workspaceUsesVitest(tree) {
|
|
182
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
183
|
+
if (packageJson.dependencies?.['vitest'] ||
|
|
184
|
+
packageJson.devDependencies?.['vitest']) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
// Inference-only setup: vitest.config.* anywhere, or vite.config.* with a
|
|
188
|
+
// top-level `test:` key. Catches workspaces that relied on @nx/vite/plugin's
|
|
189
|
+
// test inference without an explicit executor or root vitest dep.
|
|
190
|
+
const configFiles = await (0, devkit_1.globAsync)(tree, [
|
|
191
|
+
'**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}',
|
|
192
|
+
]);
|
|
193
|
+
for (const configFile of configFiles) {
|
|
194
|
+
if (configFile.includes('vitest.config')) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
const content = tree.read(configFile, 'utf-8') ?? '';
|
|
198
|
+
// Bias toward over-install: a commented-out `test:` will false-positive,
|
|
199
|
+
// which is safer than missing real usage and dropping inferred targets.
|
|
200
|
+
if (/(^|[\s,{])test\s*:/m.test(content)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Vite 8 Migration Instructions for LLM
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
These instructions guide you through migrating an Nx workspace from Vite 7 to Vite 8. Vite 8 swaps Rollup for Rolldown as its bundler and updates a number of plugin APIs. Work through each section in order and run tests after each change.
|
|
6
|
+
|
|
7
|
+
## Pre-Migration Checklist
|
|
8
|
+
|
|
9
|
+
1. **Identify all Vite-using projects**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
nx show projects --with-target build
|
|
13
|
+
nx show projects --with-target serve
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. **Locate all Vite configuration files**:
|
|
17
|
+
- Search for `vite.config.{ts,js,mts,mjs,cts,cjs}`
|
|
18
|
+
- Check `project.json` files for inline Vite-related options
|
|
19
|
+
|
|
20
|
+
3. **Cypress Component Testing**: Cypress >= 15.14.0 supports Vite 8. The `nx migrate` step bumps Cypress automatically. If you have explicitly pinned Cypress below 15.14.0, upgrade it before bumping Vite.
|
|
21
|
+
|
|
22
|
+
## Migration Steps by Category
|
|
23
|
+
|
|
24
|
+
### 1. Rename `rollupOptions` to `rolldownOptions`
|
|
25
|
+
|
|
26
|
+
The `nx migrate` codemod handles this automatically for `vite.config.{ts,js,mts,mjs,cts,cjs}` files. If you have `rollupOptions` declared elsewhere (e.g., in helper modules imported by your config), rename them by hand.
|
|
27
|
+
|
|
28
|
+
**Search Pattern**: `rollupOptions` in any TypeScript/JavaScript file
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// ❌ BEFORE (Vite 7)
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
build: {
|
|
34
|
+
rollupOptions: {
|
|
35
|
+
external: ['react'],
|
|
36
|
+
output: { manualChunks: { vendor: ['react', 'react-dom'] } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// ✅ AFTER (Vite 8)
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
build: {
|
|
44
|
+
rolldownOptions: {
|
|
45
|
+
external: ['react'],
|
|
46
|
+
output: { manualChunks: { vendor: ['react', 'react-dom'] } },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Action Items**:
|
|
53
|
+
|
|
54
|
+
- [ ] Verify the codemod picked up every config file (`rg "rollupOptions"` should return zero hits inside vite configs)
|
|
55
|
+
- [ ] Rename any `rollupOptions` in helper modules or shared config builders
|
|
56
|
+
- [ ] Update CI scripts that parse `build.rollupOptions` (e.g., custom bundle-size assertions)
|
|
57
|
+
|
|
58
|
+
### 2. `@vitejs/plugin-react` v6 (Oxc Replaces Babel)
|
|
59
|
+
|
|
60
|
+
`@vitejs/plugin-react@^6` is required for Vite 8 and uses [Oxc](https://oxc.rs/) instead of Babel for JSX transformation. The plugin's `babel` option is gone.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// ❌ BEFORE (Vite 7, plugin-react v4)
|
|
64
|
+
import react from '@vitejs/plugin-react';
|
|
65
|
+
|
|
66
|
+
export default defineConfig({
|
|
67
|
+
plugins: [
|
|
68
|
+
react({
|
|
69
|
+
babel: {
|
|
70
|
+
plugins: ['babel-plugin-styled-components'],
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ✅ AFTER (Vite 8, plugin-react v6)
|
|
77
|
+
import react from '@vitejs/plugin-react';
|
|
78
|
+
|
|
79
|
+
export default defineConfig({
|
|
80
|
+
plugins: [react()],
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Action Items**:
|
|
85
|
+
|
|
86
|
+
- [ ] Remove `babel` options from `react()` plugin invocations
|
|
87
|
+
- [ ] If you depended on a Babel plugin (e.g., styled-components, emotion, relay), find an Oxc-compatible replacement or switch to `@vitejs/plugin-react-swc` (still Babel-free). There is no drop-in for arbitrary Babel plugins.
|
|
88
|
+
- [ ] If you cannot drop your Babel plugin, stay on Vite 7 + plugin-react v4 for now (see "Project-Level Vite 7 Pinning")
|
|
89
|
+
- [ ] Run `pnpm install` (or your package manager equivalent) so the new plugin-react version resolves
|
|
90
|
+
|
|
91
|
+
### 3. Angular + Vitest: Add `@oxc-project/runtime`
|
|
92
|
+
|
|
93
|
+
`@angular/build` depends on `rolldown`, which injects `@oxc-project/runtime` helpers at transform time but does not declare it as a dependency. Angular projects using Vitest will fail at runtime unless `@oxc-project/runtime` is installed explicitly.
|
|
94
|
+
|
|
95
|
+
**Search Pattern**: Projects using both `@angular/build` and Vitest
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
rg "@angular/build" package.json
|
|
99
|
+
rg "@nx/vitest:test|@nx/vite:test" --type json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Action Items**:
|
|
103
|
+
|
|
104
|
+
- [ ] For each Angular project with Vitest, add `@oxc-project/runtime` to root `devDependencies`
|
|
105
|
+
- [ ] Run `pnpm install` (or equivalent)
|
|
106
|
+
- [ ] Run the project's tests to confirm the helper resolves at runtime
|
|
107
|
+
|
|
108
|
+
### 4. Type Resolution Under `moduleResolution: "node"`
|
|
109
|
+
|
|
110
|
+
Vite 8 ships its types only via conditional `exports` (it dropped the top-level `types` field that Vite 7 carried), which TypeScript cannot resolve under `moduleResolution: "node"`. Symptoms include type errors on `defineConfig`, `UserConfig`, or plugin return types.
|
|
111
|
+
|
|
112
|
+
**Action Items**:
|
|
113
|
+
|
|
114
|
+
- [ ] Update affected `tsconfig*.json` files: `"moduleResolution": "bundler"` (recommended) or `"node16"`/`"nodenext"`
|
|
115
|
+
- [ ] If you cannot change `moduleResolution`, narrow the impact with explicit `as any` casts at vite imports. The Nx-generated configs already do this in a handful of places.
|
|
116
|
+
- [ ] Run `tsc --noEmit` after the change to confirm types resolve cleanly
|
|
117
|
+
|
|
118
|
+
### 5. Bundle Validation Scripts
|
|
119
|
+
|
|
120
|
+
Rolldown produces different chunk and module counts than Rollup for the same input. Custom build validation (e.g., "bundle has exactly N chunks") will need to be re-baselined.
|
|
121
|
+
|
|
122
|
+
**Action Items**:
|
|
123
|
+
|
|
124
|
+
- [ ] Identify scripts that assert chunk/module counts or names
|
|
125
|
+
- [ ] Re-run the build and update expected values
|
|
126
|
+
- [ ] Prefer asserting on size budgets over exact counts going forward
|
|
127
|
+
|
|
128
|
+
### 6. Project-Level Vite 7 Pinning (Custom Babel Plugins)
|
|
129
|
+
|
|
130
|
+
If a project depends on a Babel plugin that has no Oxc equivalent, pin that project to Vite 7.
|
|
131
|
+
|
|
132
|
+
```jsonc
|
|
133
|
+
// package.json (workspace root)
|
|
134
|
+
{
|
|
135
|
+
"devDependencies": {
|
|
136
|
+
"vite": "^7.1.0",
|
|
137
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
If only some projects need to stay on 7 while the rest move to 8, use your package manager's overrides feature:
|
|
143
|
+
|
|
144
|
+
- pnpm: `pnpm.overrides` in root `package.json`
|
|
145
|
+
- npm/yarn: `overrides`/`resolutions`
|
|
146
|
+
|
|
147
|
+
**Action Items**:
|
|
148
|
+
|
|
149
|
+
- [ ] Document which projects are pinned to Vite 7 and why
|
|
150
|
+
- [ ] Track Oxc plugin equivalents so you can unpin later
|
|
151
|
+
|
|
152
|
+
## Post-Migration Validation
|
|
153
|
+
|
|
154
|
+
### 1. Run Tests Per Project
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
nx run-many -t test -p PROJECT_NAME
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 2. Build All Affected Projects
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
nx affected -t build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3. Validate Dev Server
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
nx serve PROJECT_NAME
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Open the app and verify HMR still works for changes in source files.
|
|
173
|
+
|
|
174
|
+
### 4. Validate CI Pipeline
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
nx prepush
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 5. Review Migration Checklist
|
|
181
|
+
|
|
182
|
+
- [ ] All `rollupOptions` references renamed to `rolldownOptions`
|
|
183
|
+
- [ ] `@vitejs/plugin-react` upgraded to v6 (or pinned to v4 with a documented reason)
|
|
184
|
+
- [ ] No `babel: { ... }` options remain in `react()` calls (or those projects are pinned to Vite 7)
|
|
185
|
+
- [ ] Angular + Vitest projects have `@oxc-project/runtime` installed
|
|
186
|
+
- [ ] Cypress upgraded by `nx migrate` (>= 15.14.0 for Vite 8 support)
|
|
187
|
+
- [ ] `tsc --noEmit` passes on all affected projects
|
|
188
|
+
- [ ] Build, test, and dev-server commands all succeed
|
|
189
|
+
|
|
190
|
+
## Common Issues and Solutions
|
|
191
|
+
|
|
192
|
+
### Issue: `Cannot find name 'rollupOptions'` or build options ignored
|
|
193
|
+
|
|
194
|
+
**Solution**: Rename to `rolldownOptions`. Vite 8 still accepts `rollupOptions` as a deprecated alias (it copies the value to `rolldownOptions` and logs a deprecation warning), but mixing both at the same level may cause precedence surprises (`rolldownOptions` wins).
|
|
195
|
+
|
|
196
|
+
### Issue: Babel plugin no longer applied (e.g., styled-components classNames missing)
|
|
197
|
+
|
|
198
|
+
**Solution**: `@vitejs/plugin-react@6` removed Babel. Find an Oxc-compatible alternative, switch to `@vitejs/plugin-react-swc`, or pin to Vite 7 + plugin-react v4.
|
|
199
|
+
|
|
200
|
+
### Issue: Angular + Vitest fails with `Cannot find module '@oxc-project/runtime/...'`
|
|
201
|
+
|
|
202
|
+
**Solution**: Add `@oxc-project/runtime` to root `devDependencies` and reinstall.
|
|
203
|
+
|
|
204
|
+
### Issue: Type errors on `defineConfig`, `UserConfig`, or `Plugin` imports from vite
|
|
205
|
+
|
|
206
|
+
**Solution**: Set `moduleResolution: "bundler"` in your tsconfig (or `nodenext` if you need Node-style resolution).
|
|
207
|
+
|
|
208
|
+
### Issue: Cypress CT fails to start under Vite 8
|
|
209
|
+
|
|
210
|
+
**Solution**: Confirm `cypress >= 15.14.0` is installed (Vite 8 support landed in that release). `nx migrate` bumps Cypress automatically; if you pinned it lower in `package.json`, remove the pin and reinstall.
|
|
211
|
+
|
|
212
|
+
### Issue: Bundle-size or chunk-count assertions fail after upgrade
|
|
213
|
+
|
|
214
|
+
**Solution**: Rolldown chunks differently than Rollup. Re-baseline expected values.
|
|
215
|
+
|
|
216
|
+
## Files to Review
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Vite config files
|
|
220
|
+
find . -name "vite.config.*" -not -path "*/node_modules/*"
|
|
221
|
+
|
|
222
|
+
# Cypress component testing setup
|
|
223
|
+
rg "@nx/(angular|react|next|remix)/plugins/component-testing"
|
|
224
|
+
|
|
225
|
+
# Babel plugin usage in plugin-react
|
|
226
|
+
rg "@vitejs/plugin-react.*babel|babel:\s*\{" --type ts --type js
|
|
227
|
+
|
|
228
|
+
# Angular projects with Vitest
|
|
229
|
+
rg "@angular/build" -l package.json
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Guard Rails
|
|
233
|
+
|
|
234
|
+
DO NOT
|
|
235
|
+
|
|
236
|
+
- Force tests to pass by removing assertions or replacing them with `expect(true).toBe(true)`
|
|
237
|
+
- Strip `react()` plugin options without finding an equivalent for what they did
|
|
238
|
+
- Roll Cypress back below 15.14.0 after the migrate. Older Cypress fails to start under Vite 8.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Notes for LLM Execution
|
|
243
|
+
|
|
244
|
+
When executing this migration:
|
|
245
|
+
|
|
246
|
+
1. **Work systematically**: Complete one category before moving to the next
|
|
247
|
+
2. **Test after each change**: Build and test affected projects after each step
|
|
248
|
+
3. **Keep user informed**: Report which categories applied and which were skipped
|
|
249
|
+
4. **Use TodoWrite tool**: Track migration progress for visibility
|
|
250
|
+
5. **Stop and ask** if a project depends on a Babel plugin with no Oxc equivalent. Pinning to Vite 7 is a workspace decision.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-rollup-options-to-rolldown-options.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/migrations/update-23-0-0/rename-rollup-options-to-rolldown-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAU1E,wBAA8B,oCAAoC,CAAC,IAAI,EAAE,IAAI,iBAqC5E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = renameRollupOptionsToRolldownOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const picomatch = require("picomatch");
|
|
7
|
+
const ROLLUP_OPTIONS_IDENTIFIER_SELECTOR = 'PropertyAssignment > Identifier[name=rollupOptions]';
|
|
8
|
+
const VITE_CONFIG_GLOB = '**/vite.*config*.{js,ts,mjs,mts,cjs,cts}';
|
|
9
|
+
async function renameRollupOptionsToRolldownOptions(tree) {
|
|
10
|
+
const matchVite = picomatch(VITE_CONFIG_GLOB);
|
|
11
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '', (filePath) => {
|
|
12
|
+
if (!matchVite(filePath)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const contents = tree.read(filePath, 'utf-8');
|
|
16
|
+
if (!contents.includes('rollupOptions')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
20
|
+
const identifiers = (0, tsquery_1.query)(sourceFile, ROLLUP_OPTIONS_IDENTIFIER_SELECTOR);
|
|
21
|
+
if (identifiers.length === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Replace from end-to-start so positions stay valid as we mutate.
|
|
25
|
+
let updated = contents;
|
|
26
|
+
for (let i = identifiers.length - 1; i >= 0; i--) {
|
|
27
|
+
const node = identifiers[i];
|
|
28
|
+
updated =
|
|
29
|
+
updated.slice(0, node.getStart()) +
|
|
30
|
+
'rolldownOptions' +
|
|
31
|
+
updated.slice(node.getEnd());
|
|
32
|
+
}
|
|
33
|
+
tree.write(filePath, updated);
|
|
34
|
+
});
|
|
35
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
36
|
+
}
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CreateDependencies, CreateNodesV2 } from '@nx/devkit';
|
|
2
2
|
export interface VitePluginOptions {
|
|
3
3
|
buildTargetName?: string;
|
|
4
|
-
testTargetName?: string;
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated Use devTargetName instead. This option will be removed in Nx 22.
|
|
7
6
|
*/
|
|
@@ -19,14 +18,6 @@ export interface VitePluginOptions {
|
|
|
19
18
|
compiler?: 'tsc' | 'tsgo' | 'vue-tsc';
|
|
20
19
|
watchDepsTargetName?: string;
|
|
21
20
|
buildDepsTargetName?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Atomizer for vitest
|
|
24
|
-
*/
|
|
25
|
-
ciTargetName?: string;
|
|
26
|
-
/**
|
|
27
|
-
* The name that should be used to group atomized tasks on CI
|
|
28
|
-
*/
|
|
29
|
-
ciGroupName?: string;
|
|
30
21
|
}
|
|
31
22
|
/**
|
|
32
23
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAMd,MAAM,YAAY,CAAC;AAgBpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAOD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAiHxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
|