@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
package/src/plugins/plugin.js
CHANGED
|
@@ -1,61 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
37
5
|
const devkit_1 = require("@nx/devkit");
|
|
38
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
39
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
40
6
|
const js_1 = require("@nx/js");
|
|
41
|
-
const
|
|
7
|
+
const internal_2 = require("@nx/js/src/internal");
|
|
42
8
|
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
43
9
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
44
10
|
const node_fs_1 = require("node:fs");
|
|
45
11
|
const node_path_1 = require("node:path");
|
|
46
12
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
47
13
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
48
|
-
const plugins_1 = require("nx/src/utils/plugins");
|
|
49
14
|
const executor_utils_1 = require("../utils/executor-utils");
|
|
50
15
|
const picomatch = require("picomatch");
|
|
51
|
-
function readTargetsCache(cachePath) {
|
|
52
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
|
|
53
|
-
? (0, devkit_1.readJsonFile)(cachePath)
|
|
54
|
-
: {};
|
|
55
|
-
}
|
|
56
|
-
function writeTargetsToCache(cachePath, results) {
|
|
57
|
-
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
58
|
-
}
|
|
59
16
|
/**
|
|
60
17
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
61
18
|
*/
|
|
@@ -63,14 +20,14 @@ const createDependencies = () => {
|
|
|
63
20
|
return [];
|
|
64
21
|
};
|
|
65
22
|
exports.createDependencies = createDependencies;
|
|
66
|
-
const
|
|
23
|
+
const viteConfigGlob = '**/vite.config.{js,ts,mjs,mts,cjs,cts}';
|
|
67
24
|
exports.createNodes = [
|
|
68
|
-
|
|
25
|
+
viteConfigGlob,
|
|
69
26
|
async (configFilePaths, options, context) => {
|
|
70
27
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
71
28
|
const normalizedOptions = normalizeOptions(options);
|
|
72
29
|
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `vite-${optionsHash}.hash`);
|
|
73
|
-
const targetsCache =
|
|
30
|
+
const targetsCache = new internal_1.PluginCache(cachePath);
|
|
74
31
|
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
75
32
|
const { roots: projectRoots, configFiles: validConfigFiles } = configFilePaths.reduce((acc, configFile) => {
|
|
76
33
|
const potentialRoot = (0, node_path_1.dirname)(configFile);
|
|
@@ -87,7 +44,7 @@ exports.createNodes = [
|
|
|
87
44
|
const pmc = (0, devkit_1.getPackageManagerCommand)(detectedPackageManager);
|
|
88
45
|
const lockfile = (0, js_1.getLockFileName)(detectedPackageManager);
|
|
89
46
|
const tsconfigChainsByProjectRoot = collectTsconfigInputsByProjectRoot(projectRoots, context.workspaceRoot);
|
|
90
|
-
const hashes = await (0,
|
|
47
|
+
const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((root) => [
|
|
91
48
|
lockfile,
|
|
92
49
|
...(tsconfigChainsByProjectRoot.get(root) ?? []),
|
|
93
50
|
]));
|
|
@@ -103,13 +60,11 @@ exports.createNodes = [
|
|
|
103
60
|
parts[1] === 'config' &&
|
|
104
61
|
parts.length > 2);
|
|
105
62
|
});
|
|
106
|
-
// results from vitest.config.js will be different from results of vite.config.js
|
|
107
|
-
// but the hash will be the same because it is based on the files under the project root.
|
|
108
|
-
// Adding the config file path to the hash ensures that the final hash value is different
|
|
109
|
-
// for different config files.
|
|
110
63
|
const hash = hashes[idx] + configFile;
|
|
111
|
-
|
|
112
|
-
await buildViteTargets(configFile, projectRoot, normalizedOptions, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []));
|
|
64
|
+
if (!targetsCache.has(hash)) {
|
|
65
|
+
targetsCache.set(hash, await buildViteTargets(configFile, projectRoot, normalizedOptions, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []));
|
|
66
|
+
}
|
|
67
|
+
const { projectType, metadata, targets } = targetsCache.get(hash);
|
|
113
68
|
const project = {
|
|
114
69
|
root: projectRoot,
|
|
115
70
|
targets,
|
|
@@ -128,7 +83,7 @@ exports.createNodes = [
|
|
|
128
83
|
}, validConfigFiles, options, context);
|
|
129
84
|
}
|
|
130
85
|
finally {
|
|
131
|
-
|
|
86
|
+
targetsCache.writeToDisk();
|
|
132
87
|
}
|
|
133
88
|
},
|
|
134
89
|
];
|
|
@@ -156,115 +111,23 @@ async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFi
|
|
|
156
111
|
catch {
|
|
157
112
|
// Plugin not installed or not needed, ignore
|
|
158
113
|
}
|
|
159
|
-
// Workaround for race condition with vitest/node on Node 24+
|
|
160
|
-
// When multiple vitest.config files are processed in parallel, Node can throw:
|
|
161
|
-
// Error [ERR_INTERNAL_ASSERTION]: Cannot require() ES Module vitest/dist/node.js
|
|
162
|
-
// because it is not yet fully loaded.
|
|
163
|
-
// See: https://github.com/nrwl/nx/issues/34028
|
|
164
|
-
try {
|
|
165
|
-
const importVitestNode = () => new Function('return import("vitest/node")')();
|
|
166
|
-
await importVitestNode();
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// vitest/node not available or not needed, ignore
|
|
170
|
-
}
|
|
171
114
|
const { resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
|
|
172
115
|
const viteBuildConfig = await resolveConfig({
|
|
173
116
|
configFile: absoluteConfigFilePath,
|
|
174
117
|
mode: 'development',
|
|
175
118
|
root: projectRoot,
|
|
176
119
|
}, 'build');
|
|
177
|
-
|
|
178
|
-
const { buildOutputs,
|
|
179
|
-
const namedInputs = (0,
|
|
120
|
+
const metadata = {};
|
|
121
|
+
const { buildOutputs, isBuildable, hasServeConfig } = getOutputs(viteBuildConfig, projectRoot, context.workspaceRoot);
|
|
122
|
+
const namedInputs = (0, internal_1.getNamedInputs)(projectRoot, context);
|
|
180
123
|
const targets = {};
|
|
181
|
-
// if file is vitest.config or vite.config has definition for test, create targets for test and/or atomized tests
|
|
182
|
-
if (configFilePath.includes('vitest.config') || hasTest) {
|
|
183
|
-
const isTypecheckEnabled = !!viteBuildConfig?.test?.typecheck
|
|
184
|
-
?.enabled;
|
|
185
|
-
targets[options.testTargetName] = await testTarget(namedInputs, testOutputs, projectRoot, pmc, isTypecheckEnabled, tsconfigInputs);
|
|
186
|
-
if (options.ciTargetName) {
|
|
187
|
-
const groupName = options.ciGroupName ?? (0, plugins_1.deriveGroupNameFromTarget)(options.ciTargetName);
|
|
188
|
-
const targetGroup = [];
|
|
189
|
-
const dependsOn = [];
|
|
190
|
-
metadata = {
|
|
191
|
-
targetGroups: {
|
|
192
|
-
[groupName]: targetGroup,
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
const projectRootRelativeTestPaths = await getTestPathsRelativeToProjectRoot(projectRoot, context.workspaceRoot);
|
|
196
|
-
for (const relativePath of projectRootRelativeTestPaths) {
|
|
197
|
-
if (relativePath.includes('../')) {
|
|
198
|
-
throw new Error('@nx/vite/plugin attempted to run tests outside of the project root. This is not supported and should not happen. Please open an issue at https://github.com/nrwl/nx/issues/new/choose with the following information:\n\n' +
|
|
199
|
-
`\n\n${JSON.stringify({
|
|
200
|
-
projectRoot,
|
|
201
|
-
relativePath,
|
|
202
|
-
projectRootRelativeTestPaths,
|
|
203
|
-
context,
|
|
204
|
-
}, null, 2)}`);
|
|
205
|
-
}
|
|
206
|
-
const targetName = `${options.ciTargetName}--${relativePath}`;
|
|
207
|
-
dependsOn.push(targetName);
|
|
208
|
-
targets[targetName] = {
|
|
209
|
-
// It does not make sense to run atomized tests in watch mode as they are intended to be run in CI
|
|
210
|
-
command: `vitest run ${relativePath}`,
|
|
211
|
-
cache: targets[options.testTargetName].cache,
|
|
212
|
-
inputs: targets[options.testTargetName].inputs,
|
|
213
|
-
outputs: targets[options.testTargetName].outputs,
|
|
214
|
-
options: {
|
|
215
|
-
cwd: projectRoot,
|
|
216
|
-
env: targets[options.testTargetName].options.env,
|
|
217
|
-
},
|
|
218
|
-
metadata: {
|
|
219
|
-
technologies: ['vitest'],
|
|
220
|
-
description: `Run Vitest Tests in ${relativePath}`,
|
|
221
|
-
help: {
|
|
222
|
-
command: `${pmc.exec} vitest --help`,
|
|
223
|
-
example: {
|
|
224
|
-
options: {
|
|
225
|
-
coverage: true,
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
};
|
|
231
|
-
targetGroup.push(targetName);
|
|
232
|
-
}
|
|
233
|
-
if (targetGroup.length > 0) {
|
|
234
|
-
targets[options.ciTargetName] = {
|
|
235
|
-
executor: 'nx:noop',
|
|
236
|
-
cache: true,
|
|
237
|
-
inputs: targets[options.testTargetName].inputs,
|
|
238
|
-
outputs: targets[options.testTargetName].outputs,
|
|
239
|
-
dependsOn,
|
|
240
|
-
metadata: {
|
|
241
|
-
technologies: ['vitest'],
|
|
242
|
-
description: 'Run Vitest Tests in CI',
|
|
243
|
-
nonAtomizedTarget: options.testTargetName,
|
|
244
|
-
help: {
|
|
245
|
-
command: `${pmc.exec} vitest --help`,
|
|
246
|
-
example: {
|
|
247
|
-
options: {
|
|
248
|
-
coverage: true,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
targetGroup.unshift(options.ciTargetName);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
124
|
if (hasReactRouterConfig) {
|
|
259
125
|
// If we have a react-router config, we can skip the rest of the targets
|
|
260
126
|
return { targets, metadata: {}, projectType: 'application' };
|
|
261
127
|
}
|
|
262
|
-
// If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static
|
|
263
128
|
const hasRemixPlugin = viteBuildConfig.plugins &&
|
|
264
129
|
viteBuildConfig.plugins.some((p) => p.name === 'remix');
|
|
265
|
-
if (!
|
|
266
|
-
!hasRemixPlugin &&
|
|
267
|
-
isBuildable) {
|
|
130
|
+
if (!hasRemixPlugin && isBuildable) {
|
|
268
131
|
targets[options.buildTargetName] = await buildTarget(options.buildTargetName, namedInputs, buildOutputs, projectRoot, isUsingTsSolutionSetup, pmc);
|
|
269
132
|
// If running in library mode, then there is nothing to serve.
|
|
270
133
|
if (!viteBuildConfig.build?.lib || hasServeConfig) {
|
|
@@ -417,42 +280,6 @@ function previewTarget(projectRoot, buildTargetName, pmc) {
|
|
|
417
280
|
};
|
|
418
281
|
return targetConfig;
|
|
419
282
|
}
|
|
420
|
-
async function testTarget(namedInputs, outputs, projectRoot, pmc, isTypecheckEnabled, tsconfigInputs) {
|
|
421
|
-
const depOutputsGlob = isTypecheckEnabled ? '**/*.{js,d.ts}' : '**/*.js';
|
|
422
|
-
return {
|
|
423
|
-
command: `vitest`,
|
|
424
|
-
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
|
|
425
|
-
cache: true,
|
|
426
|
-
inputs: [
|
|
427
|
-
...('production' in namedInputs
|
|
428
|
-
? ['default', '^production']
|
|
429
|
-
: ['default', '^default']),
|
|
430
|
-
...tsconfigInputs.map((f) => ({
|
|
431
|
-
json: `{workspaceRoot}/${f}`,
|
|
432
|
-
fields: ['compilerOptions'],
|
|
433
|
-
})),
|
|
434
|
-
{
|
|
435
|
-
externalDependencies: ['vitest'],
|
|
436
|
-
},
|
|
437
|
-
{ env: 'CI' },
|
|
438
|
-
{ dependentTasksOutputFiles: depOutputsGlob, transitive: true },
|
|
439
|
-
],
|
|
440
|
-
outputs,
|
|
441
|
-
metadata: {
|
|
442
|
-
technologies: ['vite'],
|
|
443
|
-
description: `Run Vite tests`,
|
|
444
|
-
help: {
|
|
445
|
-
command: `${pmc.exec} vitest --help`,
|
|
446
|
-
example: {
|
|
447
|
-
options: {
|
|
448
|
-
bail: 1,
|
|
449
|
-
coverage: true,
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
283
|
function serveStaticTarget(options, isUsingTsSolutionSetup) {
|
|
457
284
|
const targetConfig = {
|
|
458
285
|
continuous: true,
|
|
@@ -471,8 +298,8 @@ function getOutputs(viteBuildConfig, projectRoot, workspaceRoot) {
|
|
|
471
298
|
// TODO(jack): Remove this cast when @nx/vite switches to moduleResolution:
|
|
472
299
|
// "nodenext". Vite 8's rolldown types are ESM-only (.d.mts) and not
|
|
473
300
|
// resolvable under moduleResolution: "node", which breaks rolldownOptions
|
|
474
|
-
//
|
|
475
|
-
const { build,
|
|
301
|
+
// on ResolvedConfig.
|
|
302
|
+
const { build, server } = viteBuildConfig;
|
|
476
303
|
const buildOutputPath = normalizeOutputPath(build?.outDir, projectRoot, workspaceRoot, 'dist');
|
|
477
304
|
const isBuildable = Boolean(build?.lib ||
|
|
478
305
|
viteBuildConfig?.builder?.buildApp ||
|
|
@@ -480,11 +307,8 @@ function getOutputs(viteBuildConfig, projectRoot, workspaceRoot) {
|
|
|
480
307
|
build?.rolldownOptions?.input || // Vite >=8
|
|
481
308
|
(0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, projectRoot, 'index.html')));
|
|
482
309
|
const hasServeConfig = Boolean(server?.host || server?.port);
|
|
483
|
-
const reportsDirectoryPath = normalizeOutputPath(test?.coverage?.reportsDirectory, projectRoot, workspaceRoot, 'coverage');
|
|
484
310
|
return {
|
|
485
311
|
buildOutputs: [buildOutputPath],
|
|
486
|
-
testOutputs: [reportsDirectoryPath],
|
|
487
|
-
hasTest: !!test,
|
|
488
312
|
isBuildable,
|
|
489
313
|
hasServeConfig,
|
|
490
314
|
};
|
|
@@ -518,7 +342,6 @@ function normalizeOptions(options) {
|
|
|
518
342
|
options.serveTargetName ??= 'serve';
|
|
519
343
|
options.devTargetName ??= 'dev';
|
|
520
344
|
options.previewTargetName ??= 'preview';
|
|
521
|
-
options.testTargetName ??= 'test';
|
|
522
345
|
options.serveStaticTargetName ??= 'serve-static';
|
|
523
346
|
options.typecheckTargetName ??= 'typecheck';
|
|
524
347
|
return options;
|
|
@@ -565,7 +388,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
565
388
|
// Walk the project tsconfig's extends chain
|
|
566
389
|
const projectTsconfig = (0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.json');
|
|
567
390
|
if ((0, node_fs_1.existsSync)(projectTsconfig)) {
|
|
568
|
-
(0,
|
|
391
|
+
(0, internal_2.walkTsconfigExtendsChain)(projectTsconfig, (absPath) => {
|
|
569
392
|
collect(absPath);
|
|
570
393
|
return 'continue';
|
|
571
394
|
}, { jsonCache });
|
|
@@ -576,7 +399,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
576
399
|
while (dir && dir !== '.') {
|
|
577
400
|
const ancestorTsconfig = (0, node_path_1.join)(workspaceRoot, dir, 'tsconfig.json');
|
|
578
401
|
if ((0, node_fs_1.existsSync)(ancestorTsconfig)) {
|
|
579
|
-
(0,
|
|
402
|
+
(0, internal_2.walkTsconfigExtendsChain)(ancestorTsconfig, (absPath) => {
|
|
580
403
|
collect(absPath);
|
|
581
404
|
return 'continue';
|
|
582
405
|
}, { jsonCache });
|
|
@@ -589,7 +412,7 @@ function collectTsconfigInputsByProjectRoot(projectRoots, workspaceRoot) {
|
|
|
589
412
|
// Check the workspace root itself (dirname loop above stops at '.')
|
|
590
413
|
const rootTsconfig = (0, node_path_1.join)(workspaceRoot, 'tsconfig.json');
|
|
591
414
|
if ((0, node_fs_1.existsSync)(rootTsconfig)) {
|
|
592
|
-
(0,
|
|
415
|
+
(0, internal_2.walkTsconfigExtendsChain)(rootTsconfig, (absPath) => {
|
|
593
416
|
collect(absPath);
|
|
594
417
|
return 'continue';
|
|
595
418
|
}, { jsonCache });
|
|
@@ -609,17 +432,3 @@ function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
|
609
432
|
}
|
|
610
433
|
return true;
|
|
611
434
|
}
|
|
612
|
-
async function getTestPathsRelativeToProjectRoot(projectRoot, workspaceRoot) {
|
|
613
|
-
const fullProjectRoot = (0, node_path_1.join)(workspaceRoot, projectRoot);
|
|
614
|
-
const { createVitest } = await Promise.resolve().then(() => __importStar(require('vitest/node')));
|
|
615
|
-
const vitest = await createVitest('test', {
|
|
616
|
-
root: fullProjectRoot,
|
|
617
|
-
dir: fullProjectRoot,
|
|
618
|
-
filesOnly: true,
|
|
619
|
-
watch: false,
|
|
620
|
-
});
|
|
621
|
-
const relevantTestSpecifications = await vitest.getRelevantTestSpecifications();
|
|
622
|
-
return relevantTestSpecifications
|
|
623
|
-
.filter((ts) => projectRoot === '.' ? true : ts.moduleId.startsWith(fullProjectRoot))
|
|
624
|
-
.map((ts) => (0, devkit_1.normalizePath)((0, node_path_1.relative)(projectRoot, ts.moduleId)));
|
|
625
|
-
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const VITE_BUILD_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/vite:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
2
|
+
export declare const VITE_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/vite:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
3
|
+
export declare const VITE_PREVIEW_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/vite:preview-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
4
|
+
export declare function warnViteBuildExecutorDeprecation(): void;
|
|
5
|
+
export declare function warnViteDevServerExecutorDeprecation(): void;
|
|
6
|
+
export declare function warnVitePreviewServerExecutorDeprecation(): void;
|
|
7
|
+
export declare function warnViteExecutorGenerating(): void;
|
|
8
|
+
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/deprecation.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uCAAuC,4PACuM,CAAC;AAE5P,eAAO,MAAM,4CAA4C,iQACuM,CAAC;AAEjQ,eAAO,MAAM,gDAAgD,qQACuM,CAAC;AAErQ,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D;AAED,wBAAgB,wCAAwC,IAAI,IAAI,CAE/D;AAMD,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VITE_PREVIEW_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.VITE_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.VITE_BUILD_EXECUTOR_DEPRECATION_MESSAGE = void 0;
|
|
4
|
+
exports.warnViteBuildExecutorDeprecation = warnViteBuildExecutorDeprecation;
|
|
5
|
+
exports.warnViteDevServerExecutorDeprecation = warnViteDevServerExecutorDeprecation;
|
|
6
|
+
exports.warnVitePreviewServerExecutorDeprecation = warnVitePreviewServerExecutorDeprecation;
|
|
7
|
+
exports.warnViteExecutorGenerating = warnViteExecutorGenerating;
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
// TODO(v24): Remove the @nx/vite:build, @nx/vite:dev-server, and
|
|
10
|
+
// @nx/vite:preview-server executors. The inferred plugin (@nx/vite/plugin)
|
|
11
|
+
// and the convert-to-inferred generator stay supported. (`@nx/vite:test`
|
|
12
|
+
// is being deprecated in a separate change for the test-runner batch.)
|
|
13
|
+
exports.VITE_BUILD_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/vite:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
14
|
+
exports.VITE_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/vite:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
15
|
+
exports.VITE_PREVIEW_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/vite:preview-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
|
|
16
|
+
function warnViteBuildExecutorDeprecation() {
|
|
17
|
+
devkit_1.logger.warn(exports.VITE_BUILD_EXECUTOR_DEPRECATION_MESSAGE);
|
|
18
|
+
}
|
|
19
|
+
function warnViteDevServerExecutorDeprecation() {
|
|
20
|
+
devkit_1.logger.warn(exports.VITE_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
21
|
+
}
|
|
22
|
+
function warnVitePreviewServerExecutorDeprecation() {
|
|
23
|
+
devkit_1.logger.warn(exports.VITE_PREVIEW_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
|
|
24
|
+
}
|
|
25
|
+
// Fired when the @nx/vite:configuration generator is about to generate
|
|
26
|
+
// targets that use the deprecated executors — i.e. when @nx/vite/plugin
|
|
27
|
+
// isn't registered in nx.json. Surfaces the deprecation at generation time
|
|
28
|
+
// rather than only when the user later runs the generated targets.
|
|
29
|
+
function warnViteExecutorGenerating() {
|
|
30
|
+
devkit_1.logger.warn('Generating targets that use the deprecated `@nx/vite:build`, `@nx/vite:dev-server`, and `@nx/vite:preview-server` executors. These executors will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` next to migrate these targets to the `@nx/vite/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
|
|
31
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
export declare function getViteE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number, e2eCIPortOverride?: number): Promise<import("@nx/devkit/
|
|
3
|
-
export declare function getReactRouterE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number, e2eCIPortOverride?: number): Promise<import("@nx/devkit/
|
|
2
|
+
export declare function getViteE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number, e2eCIPortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
|
|
3
|
+
export declare function getReactRouterE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number, e2eCIPortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
|
|
4
4
|
//# sourceMappingURL=e2e-web-server-info-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"e2e-web-server-info-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/e2e-web-server-info-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,YAAY,CAAC;AAGnD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,CAAC,EAAE,MAAM,EACxB,iBAAiB,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"e2e-web-server-info-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/e2e-web-server-info-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,YAAY,CAAC;AAGnD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,CAAC,EAAE,MAAM,EACxB,iBAAiB,CAAC,EAAE,MAAM,8DAkC3B;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,OAAO,EAC3B,eAAe,CAAC,EAAE,MAAM,EACxB,iBAAiB,CAAC,EAAE,MAAM,8DAsB3B"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getViteE2EWebServerInfo = getViteE2EWebServerInfo;
|
|
4
4
|
exports.getReactRouterE2EWebServerInfo = getReactRouterE2EWebServerInfo;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
async function getViteE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride, e2eCIPortOverride) {
|
|
8
8
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
9
9
|
let e2ePort = e2ePortOverride ?? 4200;
|
|
@@ -15,7 +15,7 @@ async function getViteE2EWebServerInfo(tree, projectName, configFilePath, isPlug
|
|
|
15
15
|
nxJson.targetDefaults?.['dev'].options?.port ??
|
|
16
16
|
nxJson.targetDefaults?.['serve'].options?.port;
|
|
17
17
|
}
|
|
18
|
-
return (0,
|
|
18
|
+
return (0, internal_1.getE2EWebServerInfo)(tree, projectName, {
|
|
19
19
|
plugin: '@nx/vite/plugin',
|
|
20
20
|
serveTargetName: 'devTargetName',
|
|
21
21
|
serveStaticTargetName: 'previewTargetName',
|
|
@@ -30,7 +30,7 @@ async function getViteE2EWebServerInfo(tree, projectName, configFilePath, isPlug
|
|
|
30
30
|
}
|
|
31
31
|
async function getReactRouterE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride, e2eCIPortOverride) {
|
|
32
32
|
const e2ePort = e2ePortOverride ?? parseInt(process.env.PORT) ?? 4200;
|
|
33
|
-
return await (0,
|
|
33
|
+
return await (0, internal_1.getE2EWebServerInfo)(tree, projectName, {
|
|
34
34
|
plugin: '@nx/react/router-plugin',
|
|
35
35
|
serveTargetName: 'devTargetName',
|
|
36
36
|
serveStaticTargetName: 'devTargetName',
|
|
@@ -3,7 +3,6 @@ export type EnsureDependenciesOptions = {
|
|
|
3
3
|
uiFramework: 'angular' | 'react' | 'none';
|
|
4
4
|
compiler?: 'babel' | 'swc';
|
|
5
5
|
includeLib?: boolean;
|
|
6
|
-
testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
|
|
7
6
|
};
|
|
8
7
|
export declare function ensureDependencies(host: Tree, schema: EnsureDependenciesOptions): GeneratorCallback;
|
|
9
8
|
//# sourceMappingURL=ensure-dependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-dependencies.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/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/vite/src/utils/ensure-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAUpB,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,yBAAyB,GAChC,iBAAiB,CA2BnB"}
|
|
@@ -6,31 +6,16 @@ const semver_1 = require("semver");
|
|
|
6
6
|
const versions_1 = require("./versions");
|
|
7
7
|
function ensureDependencies(host, schema) {
|
|
8
8
|
const devDependencies = {};
|
|
9
|
-
if (schema.testEnvironment === 'jsdom') {
|
|
10
|
-
devDependencies['jsdom'] = versions_1.jsdomVersion;
|
|
11
|
-
}
|
|
12
|
-
else if (schema.testEnvironment === 'happy-dom') {
|
|
13
|
-
devDependencies['happy-dom'] = versions_1.happyDomVersion;
|
|
14
|
-
}
|
|
15
|
-
else if (schema.testEnvironment === 'edge-runtime') {
|
|
16
|
-
devDependencies['@edge-runtime/vm'] = versions_1.edgeRuntimeVmVersion;
|
|
17
|
-
}
|
|
18
|
-
else if (schema.testEnvironment !== 'node' && schema.testEnvironment) {
|
|
19
|
-
devkit_1.logger.info(`A custom environment was provided: ${schema.testEnvironment}. You need to install it manually.`);
|
|
20
|
-
}
|
|
21
|
-
if (schema.uiFramework === 'angular') {
|
|
22
|
-
devDependencies['@analogjs/vitest-angular'] = versions_1.analogVitestAngular;
|
|
23
|
-
devDependencies['@analogjs/vite-plugin-angular'] = versions_1.analogVitestAngular;
|
|
24
|
-
}
|
|
25
9
|
if (schema.uiFramework === 'react') {
|
|
26
10
|
if (schema.compiler === 'swc') {
|
|
27
11
|
devDependencies['@vitejs/plugin-react-swc'] = versions_1.vitePluginReactSwcVersion;
|
|
28
12
|
}
|
|
29
13
|
else {
|
|
30
|
-
// @vitejs/plugin-react v6 requires Vite 8+, use v4 for older versions
|
|
31
|
-
|
|
32
|
-
const viteRange =
|
|
33
|
-
const
|
|
14
|
+
// @vitejs/plugin-react v6 requires Vite 8+, use v4 for older versions.
|
|
15
|
+
// getDependencyVersionFromPackageJson resolves pnpm catalog: refs.
|
|
16
|
+
const viteRange = (0, devkit_1.getDependencyVersionFromPackageJson)(host, 'vite');
|
|
17
|
+
const coerced = viteRange ? (0, semver_1.coerce)(viteRange) : null;
|
|
18
|
+
const viteMajor = coerced ? (0, semver_1.major)(coerced) : null;
|
|
34
19
|
devDependencies['@vitejs/plugin-react'] =
|
|
35
20
|
viteMajor !== null && viteMajor < 8
|
|
36
21
|
? versions_1.vitePluginReactV4Version
|
|
@@ -9,5 +9,4 @@ export declare function createBuildableTsConfig(projectRoot: string, options: {
|
|
|
9
9
|
buildLibsFromSource?: boolean;
|
|
10
10
|
}, context: ExecutorContext): string;
|
|
11
11
|
export declare function loadViteDynamicImport(): Promise<typeof import("vite")>;
|
|
12
|
-
export declare function loadVitestDynamicImport(): Promise<typeof import("vitest/node")>;
|
|
13
12
|
//# sourceMappingURL=executor-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA4B,MAAM,YAAY,CAAC;AAUvE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7D,OAAO,EAAE,eAAe,UA4BzB;AAED,wBAAgB,qBAAqB,IACW,OAAO,CAAC,cAAc,MAAM,CAAC,CAAC,CAC7E
|
|
1
|
+
{"version":3,"file":"executor-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA4B,MAAM,YAAY,CAAC;AAUvE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhB;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,EAC7D,OAAO,EAAE,eAAe,UA4BzB;AAED,wBAAgB,qBAAqB,IACW,OAAO,CAAC,cAAc,MAAM,CAAC,CAAC,CAC7E"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateTypes = validateTypes;
|
|
4
4
|
exports.createBuildableTsConfig = createBuildableTsConfig;
|
|
5
5
|
exports.loadViteDynamicImport = loadViteDynamicImport;
|
|
6
|
-
exports.loadVitestDynamicImport = loadVitestDynamicImport;
|
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
|
8
7
|
const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
9
8
|
const options_utils_1 = require("./options-utils");
|
|
@@ -52,6 +51,3 @@ function createBuildableTsConfig(projectRoot, options, context) {
|
|
|
52
51
|
function loadViteDynamicImport() {
|
|
53
52
|
return Function('return import("vite")')();
|
|
54
53
|
}
|
|
55
|
-
function loadVitestDynamicImport() {
|
|
56
|
-
return Function('return import("vitest/node")')();
|
|
57
|
-
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
import { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';
|
|
3
|
-
import { VitestGeneratorSchema } from '../generators/vitest/schema';
|
|
4
3
|
export type Target = 'build' | 'serve' | 'test' | 'preview';
|
|
5
4
|
export type TargetFlags = Partial<Record<Target, boolean>>;
|
|
6
5
|
export type UserProvidedTargetName = Partial<Record<Target, string>>;
|
|
@@ -11,7 +10,6 @@ export declare function findExistingJsBuildTargetInProject(targets: {
|
|
|
11
10
|
supported?: string;
|
|
12
11
|
unsupported?: string;
|
|
13
12
|
};
|
|
14
|
-
export declare function addOrChangeTestTarget(tree: Tree, options: VitestGeneratorSchema, hasPlugin: boolean): void;
|
|
15
13
|
export declare function addBuildTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
|
|
16
14
|
export declare function addServeTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
|
|
17
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findExistingJsBuildTargetInProject = findExistingJsBuildTargetInProject;
|
|
4
|
-
exports.addOrChangeTestTarget = addOrChangeTestTarget;
|
|
5
4
|
exports.addBuildTarget = addBuildTarget;
|
|
6
5
|
exports.addServeTarget = addServeTarget;
|
|
7
6
|
exports.addPreviewTarget = addPreviewTarget;
|
|
@@ -13,8 +12,8 @@ exports.normalizeViteConfigFilePathWithTree = normalizeViteConfigFilePathWithTre
|
|
|
13
12
|
exports.getViteConfigPathForProject = getViteConfigPathForProject;
|
|
14
13
|
exports.handleUnsupportedUserProvidedTargets = handleUnsupportedUserProvidedTargets;
|
|
15
14
|
exports.handleUnknownConfiguration = handleUnknownConfiguration;
|
|
15
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
16
16
|
const devkit_1 = require("@nx/devkit");
|
|
17
|
-
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
18
17
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
19
18
|
const vite_config_edit_utils_1 = require("./vite-config-edit-utils");
|
|
20
19
|
function findExistingJsBuildTargetInProject(targets) {
|
|
@@ -64,35 +63,8 @@ function findExistingJsBuildTargetInProject(targets) {
|
|
|
64
63
|
}
|
|
65
64
|
return output;
|
|
66
65
|
}
|
|
67
|
-
function addOrChangeTestTarget(tree, options, hasPlugin) {
|
|
68
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
69
|
-
hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
70
|
-
? p === '@nx/vite/plugin'
|
|
71
|
-
: p.plugin === '@nx/vite/plugin' || hasPlugin);
|
|
72
|
-
if (hasPlugin) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
76
|
-
const target = options.testTarget ?? 'test';
|
|
77
|
-
const reportsDirectory = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(project.root), 'coverage', project.root === '.' ? options.project : project.root);
|
|
78
|
-
const testOptions = {
|
|
79
|
-
reportsDirectory,
|
|
80
|
-
};
|
|
81
|
-
project.targets ??= {};
|
|
82
|
-
if (project.targets[target]) {
|
|
83
|
-
throw new Error(`Target "${target}" already exists in the project.`);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
project.targets[target] = {
|
|
87
|
-
executor: '@nx/vite:test',
|
|
88
|
-
outputs: ['{options.reportsDirectory}'],
|
|
89
|
-
options: testOptions,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
93
|
-
}
|
|
94
66
|
function addBuildTarget(tree, options, target) {
|
|
95
|
-
(0,
|
|
67
|
+
(0, internal_1.addBuildTargetDefaults)(tree, '@nx/vite:build');
|
|
96
68
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
97
69
|
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
98
70
|
const buildOptions = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAMhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"options-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAMhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAsBpB;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAcpB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,eAAe,GACvB,MAAM,GAAG,SAAS,CAapB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,4BAA4B,EACrC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyBlC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,CAO9C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,OAG1E"}
|
|
@@ -25,9 +25,6 @@ function normalizeViteConfigFilePath(contextRoot, projectRoot, configFile) {
|
|
|
25
25
|
if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(contextRoot, projectRoot, `vite.config.${ext}`))) {
|
|
26
26
|
return (0, devkit_1.joinPathFragments)(contextRoot, projectRoot, `vite.config.${ext}`);
|
|
27
27
|
}
|
|
28
|
-
else if ((0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(contextRoot, projectRoot, `vitest.config.${ext}`))) {
|
|
29
|
-
return (0, devkit_1.joinPathFragments)(contextRoot, projectRoot, `vitest.config.${ext}`);
|
|
30
|
-
}
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
function getProjectTsConfigPath(projectRoot) {
|