@nx/vitest 22.7.0-pr.35019.f500fd7 → 22.7.0-rc.0
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/package.json +6 -7
- package/src/generators/configuration/schema.d.ts +1 -1
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +13 -7
- package/src/generators/init/schema.d.ts +1 -1
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +108 -9
- package/src/utils/ensure-dependencies.d.ts.map +1 -1
- package/src/utils/ensure-dependencies.js +9 -1
- package/src/utils/executor-utils.d.ts +1 -1
- package/src/utils/executor-utils.d.ts.map +1 -1
- package/src/utils/executor-utils.js +3 -0
- package/src/utils/version-utils.d.ts +1 -1
- package/src/utils/version-utils.d.ts.map +1 -1
- package/src/utils/version-utils.js +1 -1
- package/src/utils/versions.d.ts +11 -9
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +9 -7
- package/project.json +0 -57
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vitest",
|
|
3
3
|
"description": "The Nx Plugin for Vitest to enable fast unit testing with Vitest.",
|
|
4
|
-
"version": "22.7.0-
|
|
4
|
+
"version": "22.7.0-rc.0",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"executors": "./executors.json",
|
|
53
53
|
"generators": "./generators.json",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@nx/devkit": "22.7.0-
|
|
56
|
-
"@nx/js": "22.7.0-
|
|
55
|
+
"@nx/devkit": "22.7.0-rc.0",
|
|
56
|
+
"@nx/js": "22.7.0-rc.0",
|
|
57
57
|
"tslib": "^2.3.0",
|
|
58
58
|
"semver": "^7.6.3",
|
|
59
59
|
"@phenomnomnominal/tsquery": "~6.1.4"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"vitest": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
63
|
-
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
63
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"vitest": {
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"nx": "22.7.0-
|
|
75
|
-
}
|
|
76
|
-
"types": "./src/index.d.ts"
|
|
74
|
+
"nx": "22.7.0-rc.0"
|
|
75
|
+
}
|
|
77
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,EAOvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/vitest/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,iBAAiB,EAOvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAa/C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,qBA2BzE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QA4B9C;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,8BAkC1E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -7,15 +7,21 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
8
8
|
const versions_1 = require("../../utils/versions");
|
|
9
9
|
const plugin_1 = require("../../plugins/plugin");
|
|
10
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
10
11
|
const ignore_vitest_temp_files_1 = require("../../utils/ignore-vitest-temp-files");
|
|
11
12
|
function updateDependencies(tree, schema) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
// Determine which vite version to install:
|
|
14
|
+
// 1. Explicit viteVersion flag takes priority
|
|
15
|
+
// 2. If vite is already installed, keep the matching major version
|
|
16
|
+
// 3. Otherwise, use the latest default (^8.0.0)
|
|
17
|
+
const installedMajor = schema.viteVersion ?? (0, version_utils_1.getInstalledViteMajorVersion)(tree);
|
|
18
|
+
const viteVersionToUse = installedMajor === 5
|
|
19
|
+
? versions_1.viteV5Version
|
|
20
|
+
: installedMajor === 6
|
|
21
|
+
? versions_1.viteV6Version
|
|
22
|
+
: installedMajor === 7
|
|
23
|
+
? versions_1.viteV7Version
|
|
24
|
+
: versions_1.viteVersion;
|
|
19
25
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
20
26
|
'@nx/vitest': versions_1.nxVersion,
|
|
21
27
|
vitest: versions_1.vitestVersion,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EASd,MAAM,YAAY,CAAC;AAepB,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAC5B;AAoBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CA2F1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -38,13 +38,13 @@ const devkit_1 = require("@nx/devkit");
|
|
|
38
38
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
39
39
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
40
40
|
const js_1 = require("@nx/js");
|
|
41
|
+
const internal_1 = require("@nx/js/src/internal");
|
|
41
42
|
const node_fs_1 = require("node:fs");
|
|
42
43
|
const node_path_1 = require("node:path");
|
|
43
44
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
44
45
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
45
46
|
const plugins_1 = require("nx/src/utils/plugins");
|
|
46
47
|
const executor_utils_1 = require("../utils/executor-utils");
|
|
47
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
48
48
|
function readTargetsCache(cachePath) {
|
|
49
49
|
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
|
|
50
50
|
? (0, devkit_1.readJsonFile)(cachePath)
|
|
@@ -64,6 +64,7 @@ const vitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';
|
|
|
64
64
|
exports.createNodes = [
|
|
65
65
|
vitestConfigGlob,
|
|
66
66
|
async (configFilePaths, options, context) => {
|
|
67
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
67
68
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
68
69
|
const normalizedOptions = normalizeOptions(options);
|
|
69
70
|
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `vitest-${optionsHash}.hash`);
|
|
@@ -80,7 +81,11 @@ exports.createNodes = [
|
|
|
80
81
|
configFiles: [],
|
|
81
82
|
});
|
|
82
83
|
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
83
|
-
const
|
|
84
|
+
const tsconfigChainsByProjectRoot = collectTsconfigInputsByProjectRoot(projectRoots, context.workspaceRoot);
|
|
85
|
+
const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, normalizedOptions, context, projectRoots.map((root) => [
|
|
86
|
+
lockfile,
|
|
87
|
+
...(tsconfigChainsByProjectRoot.get(root) ?? []),
|
|
88
|
+
]));
|
|
84
89
|
try {
|
|
85
90
|
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
86
91
|
const projectRoot = (0, node_path_1.dirname)(configFile);
|
|
@@ -90,7 +95,7 @@ exports.createNodes = [
|
|
|
90
95
|
// for different config files.
|
|
91
96
|
const hash = hashes[idx] + configFile;
|
|
92
97
|
const { projectType, metadata, targets } = (targetsCache[hash] ??=
|
|
93
|
-
await buildVitestTargets(configFile, projectRoot, normalizedOptions, context));
|
|
98
|
+
await buildVitestTargets(configFile, projectRoot, normalizedOptions, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []));
|
|
94
99
|
const project = {
|
|
95
100
|
root: projectRoot,
|
|
96
101
|
targets,
|
|
@@ -110,7 +115,7 @@ exports.createNodes = [
|
|
|
110
115
|
},
|
|
111
116
|
];
|
|
112
117
|
exports.createNodesV2 = exports.createNodes;
|
|
113
|
-
async function buildVitestTargets(configFilePath, projectRoot, options, context) {
|
|
118
|
+
async function buildVitestTargets(configFilePath, projectRoot, options, context, pmc, tsconfigInputs) {
|
|
114
119
|
const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
115
120
|
// Workaround for the `build$3 is not a function` error that we sometimes see in agents.
|
|
116
121
|
// This should be removed later once we address the issue properly
|
|
@@ -153,6 +158,8 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context)
|
|
|
153
158
|
// If this is a root workspace config file with projects property, don't infer targets.
|
|
154
159
|
// The root config is just an orchestrator - the actual tests live in the individual project configs.
|
|
155
160
|
const isWorkspaceRoot = projectRoot === '.';
|
|
161
|
+
// TODO(jack): Remove this cast when @nx/vitest switches to moduleResolution:
|
|
162
|
+
// "nodenext". Vite 8's rolldown types break vitest's test augmentation.
|
|
156
163
|
const hasProjectsProperty = Array.isArray(viteBuildConfig?.test?.projects);
|
|
157
164
|
if (isWorkspaceRoot && hasProjectsProperty) {
|
|
158
165
|
return { targets: {}, metadata: {}, projectType: 'library' };
|
|
@@ -163,7 +170,9 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context)
|
|
|
163
170
|
const targets = {};
|
|
164
171
|
// if file is vitest.config or vite.config has definition for test, create targets for test and/or atomized tests
|
|
165
172
|
if (configFilePath.includes('vitest.config') || hasTest) {
|
|
166
|
-
|
|
173
|
+
const isTypecheckEnabled = !!viteBuildConfig?.test?.typecheck
|
|
174
|
+
?.enabled;
|
|
175
|
+
targets[options.testTargetName] = await testTarget(namedInputs, testOutputs, projectRoot, options.testMode, pmc, isTypecheckEnabled, tsconfigInputs);
|
|
167
176
|
if (options.ciTargetName) {
|
|
168
177
|
const groupName = options.ciGroupName ?? (0, plugins_1.deriveGroupNameFromTarget)(options.ciTargetName);
|
|
169
178
|
const targetGroup = [];
|
|
@@ -238,8 +247,9 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context)
|
|
|
238
247
|
}
|
|
239
248
|
return { targets, metadata, projectType: 'library' };
|
|
240
249
|
}
|
|
241
|
-
async function testTarget(namedInputs, outputs, projectRoot, testMode = 'watch') {
|
|
250
|
+
async function testTarget(namedInputs, outputs, projectRoot, testMode = 'watch', pmc, isTypecheckEnabled, tsconfigInputs) {
|
|
242
251
|
const command = testMode === 'run' ? 'vitest run' : 'vitest';
|
|
252
|
+
const depOutputsGlob = isTypecheckEnabled ? '**/*.{js,d.ts}' : '**/*.js';
|
|
243
253
|
return {
|
|
244
254
|
command,
|
|
245
255
|
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
|
|
@@ -248,10 +258,15 @@ async function testTarget(namedInputs, outputs, projectRoot, testMode = 'watch')
|
|
|
248
258
|
...('production' in namedInputs
|
|
249
259
|
? ['default', '^production']
|
|
250
260
|
: ['default', '^default']),
|
|
261
|
+
...tsconfigInputs.map((f) => ({
|
|
262
|
+
json: `{workspaceRoot}/${f}`,
|
|
263
|
+
fields: ['compilerOptions'],
|
|
264
|
+
})),
|
|
251
265
|
{
|
|
252
266
|
externalDependencies: ['vitest'],
|
|
253
267
|
},
|
|
254
268
|
{ env: 'CI' },
|
|
269
|
+
{ dependentTasksOutputFiles: depOutputsGlob, transitive: true },
|
|
255
270
|
],
|
|
256
271
|
outputs,
|
|
257
272
|
metadata: {
|
|
@@ -292,10 +307,10 @@ function normalizeOutputPath(outputPath, projectRoot, workspaceRoot, path) {
|
|
|
292
307
|
}
|
|
293
308
|
else {
|
|
294
309
|
if (outputPath.startsWith('..')) {
|
|
295
|
-
return (0,
|
|
310
|
+
return (0, devkit_1.joinPathFragments)('{workspaceRoot}', projectRoot, outputPath);
|
|
296
311
|
}
|
|
297
312
|
else {
|
|
298
|
-
return (0,
|
|
313
|
+
return (0, devkit_1.joinPathFragments)('{projectRoot}', outputPath);
|
|
299
314
|
}
|
|
300
315
|
}
|
|
301
316
|
}
|
|
@@ -306,6 +321,90 @@ function normalizeOptions(options) {
|
|
|
306
321
|
options.testMode ??= 'watch';
|
|
307
322
|
return options;
|
|
308
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Collects tsconfig files that Vite's esbuild-based config bundler reads
|
|
326
|
+
* but are outside the project root (and thus not covered by `default`).
|
|
327
|
+
*
|
|
328
|
+
* Vite < 8 uses esbuild's Build API to bundle config files. esbuild walks
|
|
329
|
+
* UP from the entry point, reading and parsing every `tsconfig.json` in
|
|
330
|
+
* every ancestor directory plus their `extends` chains. Vite >= 8 uses
|
|
331
|
+
* rolldown with `tsconfig: false`, but pnpm can resolve different Vite
|
|
332
|
+
* versions per project, so we always collect — the walk is cheap (cached
|
|
333
|
+
* JSON reads) and over-declaring inputs for Vite 8 projects is harmless.
|
|
334
|
+
*
|
|
335
|
+
* Files already handled elsewhere are excluded:
|
|
336
|
+
* - Inside the project root → covered by `default` (`{projectRoot}/**\/*`)
|
|
337
|
+
* - The root tsconfig (tsconfig.base.json or tsconfig.json) → covered by
|
|
338
|
+
* the native TsConfiguration hash instruction
|
|
339
|
+
* - Inside node_modules → invalidated via lockfile
|
|
340
|
+
* - Outside the workspace → cannot be expressed as inputs
|
|
341
|
+
*/
|
|
342
|
+
function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
343
|
+
const jsonCache = new Map();
|
|
344
|
+
const result = new Map();
|
|
345
|
+
const rootTsConfigName = (0, js_1.getRootTsConfigFileName)();
|
|
346
|
+
for (const projectRoot of projectRoots) {
|
|
347
|
+
if (projectRoot === '.')
|
|
348
|
+
continue;
|
|
349
|
+
const outside = [];
|
|
350
|
+
const seen = new Set();
|
|
351
|
+
const projectPrefix = `${projectRoot}/`;
|
|
352
|
+
const collect = (absolutePath) => {
|
|
353
|
+
const wsRelative = (0, node_path_1.relative)(workspaceRoot, absolutePath)
|
|
354
|
+
.split(node_path_1.sep)
|
|
355
|
+
.join('/');
|
|
356
|
+
if (seen.has(wsRelative))
|
|
357
|
+
return;
|
|
358
|
+
seen.add(wsRelative);
|
|
359
|
+
if (wsRelative.startsWith('../') || wsRelative === '..')
|
|
360
|
+
return;
|
|
361
|
+
if (wsRelative.startsWith('node_modules/') ||
|
|
362
|
+
wsRelative.includes('/node_modules/'))
|
|
363
|
+
return;
|
|
364
|
+
if (wsRelative === projectRoot || wsRelative.startsWith(projectPrefix))
|
|
365
|
+
return;
|
|
366
|
+
if (wsRelative === rootTsConfigName)
|
|
367
|
+
return;
|
|
368
|
+
outside.push(wsRelative);
|
|
369
|
+
};
|
|
370
|
+
// 1. Walk the project tsconfig's extends chain
|
|
371
|
+
const projectTsconfig = (0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.json');
|
|
372
|
+
if ((0, node_fs_1.existsSync)(projectTsconfig)) {
|
|
373
|
+
(0, internal_1.walkTsconfigExtendsChain)(projectTsconfig, (absPath) => {
|
|
374
|
+
collect(absPath);
|
|
375
|
+
return 'continue';
|
|
376
|
+
}, { jsonCache });
|
|
377
|
+
}
|
|
378
|
+
// 2. Walk UP ancestor directories (esbuild reads every tsconfig.json
|
|
379
|
+
// between the entry point and the filesystem root)
|
|
380
|
+
let dir = (0, node_path_1.dirname)(projectRoot);
|
|
381
|
+
while (dir && dir !== '.') {
|
|
382
|
+
const ancestorTsconfig = (0, node_path_1.join)(workspaceRoot, dir, 'tsconfig.json');
|
|
383
|
+
if ((0, node_fs_1.existsSync)(ancestorTsconfig)) {
|
|
384
|
+
(0, internal_1.walkTsconfigExtendsChain)(ancestorTsconfig, (absPath) => {
|
|
385
|
+
collect(absPath);
|
|
386
|
+
return 'continue';
|
|
387
|
+
}, { jsonCache });
|
|
388
|
+
}
|
|
389
|
+
const parent = (0, node_path_1.dirname)(dir);
|
|
390
|
+
if (parent === dir)
|
|
391
|
+
break;
|
|
392
|
+
dir = parent;
|
|
393
|
+
}
|
|
394
|
+
// 3. Check the workspace root itself (dirname loop above stops at '.')
|
|
395
|
+
const rootTsconfig = (0, node_path_1.join)(workspaceRoot, 'tsconfig.json');
|
|
396
|
+
if ((0, node_fs_1.existsSync)(rootTsconfig)) {
|
|
397
|
+
(0, internal_1.walkTsconfigExtendsChain)(rootTsconfig, (absPath) => {
|
|
398
|
+
collect(absPath);
|
|
399
|
+
return 'continue';
|
|
400
|
+
}, { jsonCache });
|
|
401
|
+
}
|
|
402
|
+
if (outside.length > 0) {
|
|
403
|
+
result.set(projectRoot, outside);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return result;
|
|
407
|
+
}
|
|
309
408
|
function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
310
409
|
// Do not create a project if package.json and project.json isn't there.
|
|
311
410
|
const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, projectRoot));
|
|
@@ -327,5 +426,5 @@ async function getTestPathsRelativeToProjectRoot(projectRoot, workspaceRoot) {
|
|
|
327
426
|
const relevantTestSpecifications = await vitest.getRelevantTestSpecifications();
|
|
328
427
|
return relevantTestSpecifications
|
|
329
428
|
.filter((ts) => fullProjectRoot === '.' ? true : ts.moduleId.startsWith(fullProjectRoot))
|
|
330
|
-
.map((ts) => (0, node_path_1.relative)(projectRoot, ts.moduleId));
|
|
429
|
+
.map((ts) => (0, devkit_1.normalizePath)((0, node_path_1.relative)(projectRoot, ts.moduleId)));
|
|
331
430
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAepB,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAClD,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,GAAG,MAAM,CAAC;CAC5E,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CA0D5B"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureDependencies = ensureDependencies;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const semver_1 = require("semver");
|
|
5
6
|
const versions_1 = require("./versions");
|
|
6
7
|
const version_utils_1 = require("./version-utils");
|
|
7
8
|
async function ensureDependencies(tree, schema) {
|
|
@@ -30,7 +31,14 @@ async function ensureDependencies(tree, schema) {
|
|
|
30
31
|
devDependencies['@vitejs/plugin-react-swc'] = versions_1.vitePluginReactSwcVersion;
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
|
|
34
|
+
// @vitejs/plugin-react v6 requires Vite 8+, use v4 for older versions
|
|
35
|
+
const pkgJson = JSON.parse(tree.read('package.json', 'utf-8'));
|
|
36
|
+
const viteRange = pkgJson?.devDependencies?.['vite'];
|
|
37
|
+
const viteMajor = viteRange ? (0, semver_1.major)((0, semver_1.coerce)(viteRange)) : null;
|
|
38
|
+
devDependencies['@vitejs/plugin-react'] =
|
|
39
|
+
viteMajor !== null && viteMajor < 8
|
|
40
|
+
? versions_1.vitePluginReactV4Version
|
|
41
|
+
: versions_1.vitePluginReactVersion;
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
if (schema.includeLib) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function loadViteDynamicImport(): Promise<
|
|
1
|
+
export declare function loadViteDynamicImport(): Promise<any>;
|
|
2
2
|
export declare function loadVitestDynamicImport(): Promise<typeof import("vitest/node")>;
|
|
3
3
|
//# sourceMappingURL=executor-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/executor-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/executor-utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,IACW,OAAO,CAAC,GAAG,CAAC,CAC3D;AAED,wBAAgB,uBAAuB,IACgB,OAAO,CAC1D,cAAc,aAAa,CAAC,CAC7B,CACF"}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadViteDynamicImport = loadViteDynamicImport;
|
|
4
4
|
exports.loadVitestDynamicImport = loadVitestDynamicImport;
|
|
5
|
+
// TODO(jack): Remove this cast when @nx/vitest switches to moduleResolution:
|
|
6
|
+
// "nodenext". Vite 8 ships ESM-only type declarations (.d.mts) not resolvable
|
|
7
|
+
// under moduleResolution: "node".
|
|
5
8
|
function loadViteDynamicImport() {
|
|
6
9
|
return Function('return import("vite")')();
|
|
7
10
|
}
|
|
@@ -10,7 +10,7 @@ export declare function isVitestV3(tree: Tree): Promise<boolean>;
|
|
|
10
10
|
export declare function isVitestV2(tree: Tree): Promise<boolean>;
|
|
11
11
|
export declare function getInstalledVitestVersion(tree: Tree): string;
|
|
12
12
|
export declare function getInstalledViteVersion(tree: Tree): string;
|
|
13
|
-
export declare function getInstalledViteMajorVersion(tree: Tree): 5 | 6 | 7 | undefined;
|
|
13
|
+
export declare function getInstalledViteMajorVersion(tree: Tree): 5 | 6 | 7 | 8 | undefined;
|
|
14
14
|
export declare function getInstalledVitestVersionFromGraph(): Promise<string>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=version-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/version-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAcnD,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,wBAAsB,sCAAsC,CAC1D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAwBrC;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,oBAM1C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,oBAM1C;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAiB5D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAe1D;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"version-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/version-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAcnD,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,wBAAsB,sCAAsC,CAC1D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAwBrC;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,oBAM1C;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,IAAI,oBAM1C;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAiB5D;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAe1D;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,GACT,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAW3B;AAED,wBAAsB,kCAAkC,oBASvD"}
|
|
@@ -75,7 +75,7 @@ function getInstalledViteMajorVersion(tree) {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
const installedMajor = (0, semver_1.major)(installedViteVersion);
|
|
78
|
-
if (installedMajor < 5 || installedMajor >
|
|
78
|
+
if (installedMajor < 5 || installedMajor > 8) {
|
|
79
79
|
return undefined;
|
|
80
80
|
}
|
|
81
81
|
return installedMajor;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const viteVersion = "^
|
|
2
|
+
export declare const viteVersion = "^8.0.0";
|
|
3
|
+
export declare const viteV7Version = "^7.0.0";
|
|
3
4
|
export declare const viteV6Version = "^6.0.0";
|
|
4
5
|
export declare const viteV5Version = "^5.0.0";
|
|
5
|
-
export declare const vitestV4Version = "~4.0
|
|
6
|
+
export declare const vitestV4Version = "~4.1.0";
|
|
6
7
|
export declare const vitestV3Version = "^3.0.0";
|
|
7
8
|
export declare const vitestV2Version = "^2.1.8";
|
|
8
|
-
export declare const vitestVersion = "~4.0
|
|
9
|
-
export declare const vitePluginReactVersion = "^
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const vitestVersion = "~4.1.0";
|
|
10
|
+
export declare const vitePluginReactVersion = "^6.0.0";
|
|
11
|
+
export declare const vitePluginReactV4Version = "^4.2.0";
|
|
12
|
+
export declare const vitePluginReactSwcVersion = "^4.3.0";
|
|
11
13
|
export declare const jsdomVersion = "^27.1.0";
|
|
12
14
|
export declare const vitePluginDtsVersion = "~4.5.0";
|
|
13
15
|
export declare const ajvVersion = "^8.0.0";
|
|
@@ -15,12 +17,12 @@ export declare const happyDomVersion = "~9.20.3";
|
|
|
15
17
|
export declare const edgeRuntimeVmVersion = "~3.0.2";
|
|
16
18
|
export declare const jitiVersion = "2.4.2";
|
|
17
19
|
export declare const analogVitestAngular = "~2.1.2";
|
|
18
|
-
export declare const vitestV4CoverageV8Version = "~4.
|
|
20
|
+
export declare const vitestV4CoverageV8Version = "~4.1.0";
|
|
19
21
|
export declare const vitestV3CoverageV8Version = "^3.0.5";
|
|
20
22
|
export declare const vitestV2CoverageV8Version = "^2.1.8";
|
|
21
|
-
export declare const vitestCoverageV8Version = "~4.
|
|
22
|
-
export declare const vitestV4CoverageIstanbulVersion = "~4.
|
|
23
|
+
export declare const vitestCoverageV8Version = "~4.1.0";
|
|
24
|
+
export declare const vitestV4CoverageIstanbulVersion = "~4.1.0";
|
|
23
25
|
export declare const vitestV3CoverageIstanbulVersion = "^3.0.5";
|
|
24
26
|
export declare const vitestV2CoverageIstanbulVersion = "^2.1.8";
|
|
25
|
-
export declare const vitestCoverageIstanbulVersion = "~4.
|
|
27
|
+
export declare const vitestCoverageIstanbulVersion = "~4.1.0";
|
|
26
28
|
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,aAAa,WAAkB,CAAC;AAC7C,eAAO,MAAM,sBAAsB,WAAW,CAAC;AAC/C,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAG5C,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,WAA4B,CAAC;AACjE,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,6BAA6B,WAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/vitest/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,aAAa,WAAkB,CAAC;AAC7C,eAAO,MAAM,sBAAsB,WAAW,CAAC;AAC/C,eAAO,MAAM,wBAAwB,WAAW,CAAC;AACjD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,YAAY,YAAY,CAAC;AACtC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,UAAU,WAAW,CAAC;AACnC,eAAO,MAAM,eAAe,YAAY,CAAC;AACzC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAG5C,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,eAAO,MAAM,uBAAuB,WAA4B,CAAC;AACjE,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,6BAA6B,WAAkC,CAAC"}
|
package/src/utils/versions.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.vitestCoverageIstanbulVersion = exports.vitestV2CoverageIstanbulVersion = exports.vitestV3CoverageIstanbulVersion = exports.vitestV4CoverageIstanbulVersion = exports.vitestCoverageV8Version = exports.vitestV2CoverageV8Version = exports.vitestV3CoverageV8Version = exports.vitestV4CoverageV8Version = exports.analogVitestAngular = exports.jitiVersion = exports.edgeRuntimeVmVersion = exports.happyDomVersion = exports.ajvVersion = exports.vitePluginDtsVersion = exports.jsdomVersion = exports.vitePluginReactSwcVersion = exports.vitePluginReactVersion = exports.vitestVersion = exports.vitestV2Version = exports.vitestV3Version = exports.vitestV4Version = exports.viteV5Version = exports.viteV6Version = exports.viteVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.vitestCoverageIstanbulVersion = exports.vitestV2CoverageIstanbulVersion = exports.vitestV3CoverageIstanbulVersion = exports.vitestV4CoverageIstanbulVersion = exports.vitestCoverageV8Version = exports.vitestV2CoverageV8Version = exports.vitestV3CoverageV8Version = exports.vitestV4CoverageV8Version = exports.analogVitestAngular = exports.jitiVersion = exports.edgeRuntimeVmVersion = exports.happyDomVersion = exports.ajvVersion = exports.vitePluginDtsVersion = exports.jsdomVersion = exports.vitePluginReactSwcVersion = exports.vitePluginReactV4Version = exports.vitePluginReactVersion = exports.vitestVersion = exports.vitestV2Version = exports.vitestV3Version = exports.vitestV4Version = exports.viteV5Version = exports.viteV6Version = exports.viteV7Version = exports.viteVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.viteVersion = '^
|
|
5
|
+
exports.viteVersion = '^8.0.0';
|
|
6
|
+
exports.viteV7Version = '^7.0.0';
|
|
6
7
|
exports.viteV6Version = '^6.0.0';
|
|
7
8
|
exports.viteV5Version = '^5.0.0';
|
|
8
|
-
exports.vitestV4Version = '~4.0
|
|
9
|
+
exports.vitestV4Version = '~4.1.0';
|
|
9
10
|
exports.vitestV3Version = '^3.0.0';
|
|
10
11
|
exports.vitestV2Version = '^2.1.8';
|
|
11
12
|
exports.vitestVersion = exports.vitestV4Version;
|
|
12
|
-
exports.vitePluginReactVersion = '^
|
|
13
|
-
exports.
|
|
13
|
+
exports.vitePluginReactVersion = '^6.0.0';
|
|
14
|
+
exports.vitePluginReactV4Version = '^4.2.0';
|
|
15
|
+
exports.vitePluginReactSwcVersion = '^4.3.0';
|
|
14
16
|
exports.jsdomVersion = '^27.1.0';
|
|
15
17
|
exports.vitePluginDtsVersion = '~4.5.0';
|
|
16
18
|
exports.ajvVersion = '^8.0.0';
|
|
@@ -19,11 +21,11 @@ exports.edgeRuntimeVmVersion = '~3.0.2';
|
|
|
19
21
|
exports.jitiVersion = '2.4.2';
|
|
20
22
|
exports.analogVitestAngular = '~2.1.2';
|
|
21
23
|
// Coverage providers
|
|
22
|
-
exports.vitestV4CoverageV8Version = '~4.
|
|
24
|
+
exports.vitestV4CoverageV8Version = '~4.1.0';
|
|
23
25
|
exports.vitestV3CoverageV8Version = '^3.0.5';
|
|
24
26
|
exports.vitestV2CoverageV8Version = '^2.1.8';
|
|
25
27
|
exports.vitestCoverageV8Version = exports.vitestV4CoverageV8Version;
|
|
26
|
-
exports.vitestV4CoverageIstanbulVersion = '~4.
|
|
28
|
+
exports.vitestV4CoverageIstanbulVersion = '~4.1.0';
|
|
27
29
|
exports.vitestV3CoverageIstanbulVersion = '^3.0.5';
|
|
28
30
|
exports.vitestV2CoverageIstanbulVersion = '^2.1.8';
|
|
29
31
|
exports.vitestCoverageIstanbulVersion = exports.vitestV4CoverageIstanbulVersion;
|
package/project.json
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vitest",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "packages/vitest",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"targets": {
|
|
7
|
-
"build": {
|
|
8
|
-
"command": "node ./scripts/copy-readme.js vitest",
|
|
9
|
-
"outputs": ["{workspaceRoot}/dist/packages/vitest/README.md"]
|
|
10
|
-
},
|
|
11
|
-
"legacy-post-build": {
|
|
12
|
-
"executor": "@nx/workspace-plugin:legacy-post-build",
|
|
13
|
-
"options": {
|
|
14
|
-
"tsConfig": "./tsconfig.lib.json",
|
|
15
|
-
"assets": [
|
|
16
|
-
{
|
|
17
|
-
"input": "packages/vitest",
|
|
18
|
-
"glob": "**/files/**",
|
|
19
|
-
"output": "/"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"input": "packages/vitest",
|
|
23
|
-
"glob": "**files/**/.gitkeep",
|
|
24
|
-
"output": "/"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"input": "packages/vitest",
|
|
28
|
-
"glob": "**/*.json",
|
|
29
|
-
"ignore": ["**/tsconfig*.json", "project.json", ".eslintrc.json"],
|
|
30
|
-
"output": "/"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"input": "packages/vitest",
|
|
34
|
-
"glob": "**/*.js",
|
|
35
|
-
"ignore": ["**/jest.config.js"],
|
|
36
|
-
"output": "/"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"input": "packages/vitest",
|
|
40
|
-
"glob": "**/*.d.ts",
|
|
41
|
-
"output": "/"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"input": "packages/vitest",
|
|
45
|
-
"glob": "PLUGIN.md",
|
|
46
|
-
"output": "/"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"input": "",
|
|
50
|
-
"glob": "LICENSE",
|
|
51
|
-
"output": "/"
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|