@nx/vite 17.3.0-beta.2 → 17.3.0-beta.4
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 +4 -4
- package/plugins/rollup-replace-files.plugin.d.ts +1 -1
- package/plugins/rollup-replace-files.plugin.js +1 -1
- package/plugins/rollup-replace-files.plugin.js.map +1 -1
- package/src/executors/build/schema.d.ts +1 -3
- package/src/executors/build/schema.json +0 -22
- package/src/generators/configuration/configuration.js +9 -5
- package/src/generators/configuration/configuration.js.map +1 -1
- package/src/generators/init/init.d.ts +2 -2
- package/src/generators/init/init.js +9 -11
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/lib/utils.d.ts +1 -1
- package/src/generators/init/lib/utils.js +9 -30
- package/src/generators/init/lib/utils.js.map +1 -1
- package/src/generators/init/schema.d.ts +2 -5
- package/src/generators/init/schema.json +7 -22
- package/src/generators/vitest/vitest-generator.js +6 -2
- package/src/generators/vitest/vitest-generator.js.map +1 -1
- package/src/migrations/update-17-2-0/update-vite-config.js +2 -2
- package/src/migrations/update-17-2-0/update-vite-config.js.map +1 -1
- package/src/plugins/plugin.js +8 -3
- package/src/plugins/plugin.js.map +1 -1
- package/src/utils/ensure-dependencies.d.ts +8 -0
- package/src/utils/ensure-dependencies.js +34 -0
- package/src/utils/ensure-dependencies.js.map +1 -0
- package/src/utils/generator-utils.js +3 -5
- package/src/utils/generator-utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "17.3.0-beta.
|
|
3
|
+
"version": "17.3.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"migrations": "./migrations.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@nx/devkit": "17.3.0-beta.
|
|
32
|
+
"@nx/devkit": "17.3.0-beta.4",
|
|
33
33
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
34
34
|
"@swc/helpers": "~0.5.0",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "17.3.0-beta.
|
|
36
|
+
"@nx/js": "17.3.0-beta.4",
|
|
37
37
|
"tsconfig-paths": "^4.1.2",
|
|
38
|
-
"@nrwl/vite": "17.3.0-beta.
|
|
38
|
+
"@nrwl/vite": "17.3.0-beta.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"vite": "^5.0.0",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param {FileReplacement[]} replacements
|
|
4
4
|
* @return {({name: "rollup-plugin-replace-files", enforce: "pre" | "post" | undefined, Promise<resolveId>})}
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare function replaceFiles(replacements: FileReplacement[]): {
|
|
7
7
|
name: string;
|
|
8
8
|
enforce: 'pre' | 'post' | undefined;
|
|
9
9
|
resolveId(source: any, importer: any, options: any): Promise<{
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param {FileReplacement[]} replacements
|
|
5
5
|
* @return {({name: "rollup-plugin-replace-files", enforce: "pre" | "post" | undefined, Promise<resolveId>})}
|
|
6
6
|
*/ "use strict";
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "replaceFiles", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function() {
|
|
10
10
|
return replaceFiles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/vite/plugins/rollup-replace-files.plugin.ts"],"sourcesContent":["// source: https://github.com/Myrmod/vitejs-theming/blob/master/build-plugins/rollup/replace-files.js\n\n/**\n * @function replaceFiles\n * @param {FileReplacement[]} replacements\n * @return {({name: \"rollup-plugin-replace-files\", enforce: \"pre\" | \"post\" | undefined, Promise<resolveId>})}\n */\nexport
|
|
1
|
+
{"version":3,"sources":["../../../../packages/vite/plugins/rollup-replace-files.plugin.ts"],"sourcesContent":["// source: https://github.com/Myrmod/vitejs-theming/blob/master/build-plugins/rollup/replace-files.js\n\n/**\n * @function replaceFiles\n * @param {FileReplacement[]} replacements\n * @return {({name: \"rollup-plugin-replace-files\", enforce: \"pre\" | \"post\" | undefined, Promise<resolveId>})}\n */\nexport function replaceFiles(replacements: FileReplacement[]): {\n name: string;\n enforce: 'pre' | 'post' | undefined;\n resolveId(\n source: any,\n importer: any,\n options: any\n ): Promise<{\n id: string;\n }>;\n} {\n if (!replacements?.length) {\n return null;\n }\n return {\n name: 'rollup-plugin-replace-files',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n const resolved = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n /**\n * The reason we're using endsWith here is because the resolved id\n * will be the absolute path to the file. We want to check if the\n * file ends with the file we're trying to replace, which will be essentially\n * the path from the root of our workspace.\n */\n\n const foundReplace = replacements.find((replacement) =>\n resolved?.id?.endsWith(replacement.replace)\n );\n if (foundReplace) {\n console.info(\n `replace \"${foundReplace.replace}\" with \"${foundReplace.with}\"`\n );\n try {\n // return new file content\n return {\n id: foundReplace.with,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n }\n return null;\n },\n };\n}\n\nexport interface FileReplacement {\n replace: string;\n with: string;\n}\n"],"names":["replaceFiles","replacements","length","name","enforce","resolveId","source","importer","options","resolved","resolve","skipSelf","foundReplace","find","replacement","id","endsWith","replace","console","info","with","err","error"],"mappings":"AAAA,qGAAqG;AAErG;;;;CAIC;+BACeA;;;eAAAA;;;;AAAT,SAASA,aAAaC,YAA+B;IAW1D,IAAI,EAACA,gCAAAA,aAAcC,MAAM,GAAE;QACzB,OAAO;IACT;IACA,OAAO;QACLC,MAAM;QACNC,SAAS;QACT,MAAMC,WAAUC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;YACvC,MAAMC,WAAW,MAAM,IAAI,CAACC,OAAO,CAACJ,QAAQC,UAAU,eACjDC;gBACHG,UAAU;;YAEZ;;;;;OAKC,GAED,MAAMC,eAAeX,aAAaY,IAAI,CAAC,CAACC;oBACtCL;uBAAAA,6BAAAA,eAAAA,SAAUM,EAAE,qBAAZN,aAAcO,QAAQ,CAACF,YAAYG,OAAO;;YAE5C,IAAIL,cAAc;gBAChBM,QAAQC,IAAI,CACV,CAAC,SAAS,EAAEP,aAAaK,OAAO,CAAC,QAAQ,EAAEL,aAAaQ,IAAI,CAAC,CAAC,CAAC;gBAEjE,IAAI;oBACF,0BAA0B;oBAC1B,OAAO;wBACLL,IAAIH,aAAaQ,IAAI;oBACvB;gBACF,EAAE,OAAOC,KAAK;oBACZH,QAAQI,KAAK,CAACD;oBACd,OAAO;gBACT;YACF;YACA,OAAO;QACT;IACF;AACF"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { FileReplacement } from '../../plugins/rollup-replace-files.plugin';
|
|
2
1
|
export interface ViteBuildExecutorOptions {
|
|
3
2
|
outputPath?: string;
|
|
3
|
+
buildLibsFromSource?: boolean;
|
|
4
4
|
skipTypeCheck?: boolean;
|
|
5
5
|
configFile?: string;
|
|
6
|
-
fileReplacements?: FileReplacement[];
|
|
7
6
|
watch?: boolean;
|
|
8
7
|
generatePackageJson?: boolean;
|
|
9
8
|
includeDevDependenciesInPackageJson?: boolean;
|
|
10
|
-
buildLibsFromSource?: boolean;
|
|
11
9
|
}
|
|
@@ -34,28 +34,6 @@
|
|
|
34
34
|
"x-completion-type": "file",
|
|
35
35
|
"x-completion-glob": "vite.config.@(js|ts)"
|
|
36
36
|
},
|
|
37
|
-
"fileReplacements": {
|
|
38
|
-
"description": "Replace files with other files in the build.",
|
|
39
|
-
"type": "array",
|
|
40
|
-
"items": {
|
|
41
|
-
"type": "object",
|
|
42
|
-
"properties": {
|
|
43
|
-
"replace": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"description": "The file to be replaced.",
|
|
46
|
-
"x-completion-type": "file"
|
|
47
|
-
},
|
|
48
|
-
"with": {
|
|
49
|
-
"type": "string",
|
|
50
|
-
"description": "The file to replace with.",
|
|
51
|
-
"x-completion-type": "file"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"additionalProperties": false,
|
|
55
|
-
"required": ["replace", "with"]
|
|
56
|
-
},
|
|
57
|
-
"default": []
|
|
58
|
-
},
|
|
59
37
|
"watch": {
|
|
60
38
|
"description": "Enable re-building when files change.",
|
|
61
39
|
"oneOf": [
|
|
@@ -15,9 +15,11 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _extends = require("@swc/helpers/_/_extends");
|
|
17
17
|
const _devkit = require("@nx/devkit");
|
|
18
|
+
const _js = require("@nx/js");
|
|
18
19
|
const _generatorutils = require("../../utils/generator-utils");
|
|
19
20
|
const _init = require("../init/init");
|
|
20
21
|
const _vitestgenerator = require("../vitest/vitest-generator");
|
|
22
|
+
const _ensuredependencies = require("../../utils/ensure-dependencies");
|
|
21
23
|
async function viteConfigurationGenerator(tree, schema) {
|
|
22
24
|
var _nxJson_plugins;
|
|
23
25
|
var _schema, // Setting default to jsdom since it is the most common use case (React, Web).
|
|
@@ -99,14 +101,16 @@ async function viteConfigurationGenerator(tree, schema) {
|
|
|
99
101
|
(0, _generatorutils.deleteWebpackConfig)(tree, projectRoot, targets == null ? void 0 : (_targets_buildTargetName = targets[buildTargetName]) == null ? void 0 : (_targets_buildTargetName_options = _targets_buildTargetName.options) == null ? void 0 : _targets_buildTargetName_options.webpackConfig);
|
|
100
102
|
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
101
103
|
}
|
|
104
|
+
const jsInitTask = await (0, _js.initGenerator)(tree, _extends._({}, schema, {
|
|
105
|
+
skipFormat: true,
|
|
106
|
+
tsConfigName: projectRoot === '.' ? 'tsconfig.json' : 'tsconfig.base.json'
|
|
107
|
+
}));
|
|
108
|
+
tasks.push(jsInitTask);
|
|
102
109
|
const initTask = await (0, _init.default)(tree, {
|
|
103
|
-
|
|
104
|
-
includeLib: schema.includeLib,
|
|
105
|
-
compiler: schema.compiler,
|
|
106
|
-
testEnvironment: schema.testEnvironment,
|
|
107
|
-
rootProject: projectRoot === '.'
|
|
110
|
+
skipFormat: true
|
|
108
111
|
});
|
|
109
112
|
tasks.push(initTask);
|
|
113
|
+
tasks.push((0, _ensuredependencies.ensureDependencies)(tree, schema));
|
|
110
114
|
const nxJson = (0, _devkit.readNxJson)(tree);
|
|
111
115
|
const hasPlugin = (_nxJson_plugins = nxJson.plugins) == null ? void 0 : _nxJson_plugins.some((p)=>typeof p === 'string' ? p === '@nx/vite/plugin' : p.plugin === '@nx/vite/plugin');
|
|
112
116
|
if (!hasPlugin) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\n\nimport {\n addOrChangeBuildTarget,\n addOrChangeServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n deleteWebpackConfig,\n editTsConfig,\n findExistingTargetsInProject,\n handleUnknownExecutors,\n handleUnsupportedUserProvidedTargets,\n moveAndEditIndexHtml,\n TargetFlags,\n UserProvidedTargetName,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\n\nexport async function viteConfigurationGenerator(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const {\n targets,\n projectType,\n root: projectRoot,\n } = readProjectConfiguration(tree, schema.project);\n let buildTargetName = 'build';\n let serveTargetName = 'serve';\n let testTargetName = 'test';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n const userProvidedTargetName: UserProvidedTargetName = {\n build: schema.buildTarget,\n serve: schema.serveTarget,\n test: schema.testTarget,\n };\n\n const {\n validFoundTargetName,\n projectContainsUnsupportedExecutor,\n userProvidedTargetIsUnsupported,\n alreadyHasNxViteTargets,\n } = findExistingTargetsInProject(targets, userProvidedTargetName);\n projectAlreadyHasViteTargets = alreadyHasNxViteTargets;\n /**\n * This means that we only found unsupported build targets in that project.\n * The only way that buildTarget is defined, means that it is supported.\n *\n * If the `unsupported` flag was false, it would mean that we did not find\n * a build target at all, so we can create a new one.\n *\n * So we only throw if we found a target, but it is unsupported.\n */\n if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {\n throw new Error(\n `The project ${schema.project} cannot be converted to use the @nx/vite executors.`\n );\n }\n\n if (\n alreadyHasNxViteTargets.build &&\n (alreadyHasNxViteTargets.serve || projectType === 'library') &&\n alreadyHasNxViteTargets.test\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use the @nx/vite executors.\n Please try a different project, or remove the existing targets \n and re-run this generator to reset the existing Vite Configuration.\n `\n );\n }\n\n /**\n * This means that we did not find any supported executors\n * so we don't have any valid target names.\n *\n * However, the executors that we may have found are not in the\n * list of the specifically unsupported executors either.\n *\n * So, we should warn the user about it.\n */\n\n if (\n !projectContainsUnsupportedExecutor &&\n !validFoundTargetName.build &&\n !validFoundTargetName.serve &&\n !validFoundTargetName.test\n ) {\n await handleUnknownExecutors(schema.project);\n }\n\n /**\n * There is a possibility at this stage that the user has provided\n * targets with unsupported executors.\n * We keep track here of which of the targets that the user provided\n * are unsupported.\n * We do this with the `userProvidedTargetIsUnsupported` object,\n * which contains flags for each target (whether it is supported or not).\n *\n * We also keep track of the targets that we found in the project,\n * through the findExistingTargetsInProject function, which returns\n * targets for build/serve/test that use supported executors, and\n * can be converted to use the vite executors. These are the\n * kept in the validFoundTargetName object.\n */\n await handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported,\n userProvidedTargetName,\n validFoundTargetName\n );\n\n /**\n * Once the user is at this stage, then they can go ahead and convert.\n */\n\n buildTargetName = validFoundTargetName.build ?? buildTargetName;\n serveTargetName = validFoundTargetName.serve ?? serveTargetName;\n\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema, buildTargetName);\n }\n\n deleteWebpackConfig(\n tree,\n projectRoot,\n targets?.[buildTargetName]?.options?.webpackConfig\n );\n\n editTsConfig(tree, schema);\n }\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n includeLib: schema.includeLib,\n compiler: schema.compiler,\n testEnvironment: schema.testEnvironment,\n rootProject: projectRoot === '.',\n });\n tasks.push(initTask);\n\n const nxJson = readNxJson(tree);\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n if (!projectAlreadyHasViteTargets.build) {\n addOrChangeBuildTarget(tree, schema, buildTargetName);\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addOrChangeServeTarget(tree, schema, serveTargetName);\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, serveTargetName);\n }\n }\n }\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n }\n );\n }\n\n if (!schema.newProject) {\n // We are converting existing project to use Vite\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false,\n undefined\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'v8',\n skipViteConfig: true,\n testTarget: testTargetName,\n skipFormat: true,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","tree","schema","nxJson","tasks","targets","projectType","root","projectRoot","readProjectConfiguration","project","buildTargetName","serveTargetName","testTargetName","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","userProvidedTargetName","build","buildTarget","serve","serveTarget","test","testTarget","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","findExistingTargetsInProject","Error","handleUnknownExecutors","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","deleteWebpackConfig","options","webpackConfig","editTsConfig","initTask","initGenerator","uiFramework","compiler","rootProject","push","readNxJson","hasPlugin","plugins","some","p","plugin","addOrChangeBuildTarget","addOrChangeServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","imports","undefined","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","skipFormat","formatFiles","runTasksInSerial"],"mapp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,IAAAA,sCAAsB,EAAC3D,MAAMC,QAAQ,OAAOc;QAC9C;IACF;IAEA,IAAId,OAAO2D,aAAa,EAAE;QACxB,MAAMK,aAAa,MAAMC,IAAAA,wBAAe,EAAClE,MAAM;YAC7CS,SAASR,OAAOQ,OAAO;YACvB8B,aAAatC,OAAOsC,WAAW;YAC/BsB,eAAe5D,OAAO4D,aAAa;YACnCM,kBAAkB;YAClBC,gBAAgB;YAChB7C,YAAYX;YACZyD,YAAY;QACd;QACAlE,MAAMuC,IAAI,CAACuB;IACb;IAEA,IAAI,CAAChE,OAAOoE,UAAU,EAAE;QACtB,MAAMC,IAAAA,mBAAW,EAACtE;IACpB;IAEA,OAAOuE,IAAAA,wBAAgB,KAAIpE;AAC7B;MAEA,WAAeJ"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport { initGenerator as jsInitGenerator } from '@nx/js';\n\nimport {\n addOrChangeBuildTarget,\n addOrChangeServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n deleteWebpackConfig,\n editTsConfig,\n findExistingTargetsInProject,\n handleUnknownExecutors,\n handleUnsupportedUserProvidedTargets,\n moveAndEditIndexHtml,\n TargetFlags,\n UserProvidedTargetName,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\nimport { ensureDependencies } from '../../utils/ensure-dependencies';\n\nexport async function viteConfigurationGenerator(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const {\n targets,\n projectType,\n root: projectRoot,\n } = readProjectConfiguration(tree, schema.project);\n let buildTargetName = 'build';\n let serveTargetName = 'serve';\n let testTargetName = 'test';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n const userProvidedTargetName: UserProvidedTargetName = {\n build: schema.buildTarget,\n serve: schema.serveTarget,\n test: schema.testTarget,\n };\n\n const {\n validFoundTargetName,\n projectContainsUnsupportedExecutor,\n userProvidedTargetIsUnsupported,\n alreadyHasNxViteTargets,\n } = findExistingTargetsInProject(targets, userProvidedTargetName);\n projectAlreadyHasViteTargets = alreadyHasNxViteTargets;\n /**\n * This means that we only found unsupported build targets in that project.\n * The only way that buildTarget is defined, means that it is supported.\n *\n * If the `unsupported` flag was false, it would mean that we did not find\n * a build target at all, so we can create a new one.\n *\n * So we only throw if we found a target, but it is unsupported.\n */\n if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {\n throw new Error(\n `The project ${schema.project} cannot be converted to use the @nx/vite executors.`\n );\n }\n\n if (\n alreadyHasNxViteTargets.build &&\n (alreadyHasNxViteTargets.serve || projectType === 'library') &&\n alreadyHasNxViteTargets.test\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use the @nx/vite executors.\n Please try a different project, or remove the existing targets \n and re-run this generator to reset the existing Vite Configuration.\n `\n );\n }\n\n /**\n * This means that we did not find any supported executors\n * so we don't have any valid target names.\n *\n * However, the executors that we may have found are not in the\n * list of the specifically unsupported executors either.\n *\n * So, we should warn the user about it.\n */\n\n if (\n !projectContainsUnsupportedExecutor &&\n !validFoundTargetName.build &&\n !validFoundTargetName.serve &&\n !validFoundTargetName.test\n ) {\n await handleUnknownExecutors(schema.project);\n }\n\n /**\n * There is a possibility at this stage that the user has provided\n * targets with unsupported executors.\n * We keep track here of which of the targets that the user provided\n * are unsupported.\n * We do this with the `userProvidedTargetIsUnsupported` object,\n * which contains flags for each target (whether it is supported or not).\n *\n * We also keep track of the targets that we found in the project,\n * through the findExistingTargetsInProject function, which returns\n * targets for build/serve/test that use supported executors, and\n * can be converted to use the vite executors. These are the\n * kept in the validFoundTargetName object.\n */\n await handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported,\n userProvidedTargetName,\n validFoundTargetName\n );\n\n /**\n * Once the user is at this stage, then they can go ahead and convert.\n */\n\n buildTargetName = validFoundTargetName.build ?? buildTargetName;\n serveTargetName = validFoundTargetName.serve ?? serveTargetName;\n\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema, buildTargetName);\n }\n\n deleteWebpackConfig(\n tree,\n projectRoot,\n targets?.[buildTargetName]?.options?.webpackConfig\n );\n\n editTsConfig(tree, schema);\n }\n\n const jsInitTask = await jsInitGenerator(tree, {\n ...schema,\n skipFormat: true,\n tsConfigName: projectRoot === '.' ? 'tsconfig.json' : 'tsconfig.base.json',\n });\n tasks.push(jsInitTask);\n const initTask = await initGenerator(tree, { skipFormat: true });\n tasks.push(initTask);\n tasks.push(ensureDependencies(tree, schema));\n\n const nxJson = readNxJson(tree);\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n if (!projectAlreadyHasViteTargets.build) {\n addOrChangeBuildTarget(tree, schema, buildTargetName);\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addOrChangeServeTarget(tree, schema, serveTargetName);\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, serveTargetName);\n }\n }\n }\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n }\n );\n }\n\n if (!schema.newProject) {\n // We are converting existing project to use Vite\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false,\n undefined\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'v8',\n skipViteConfig: true,\n testTarget: testTargetName,\n skipFormat: true,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","tree","schema","nxJson","tasks","targets","projectType","root","projectRoot","readProjectConfiguration","project","buildTargetName","serveTargetName","testTargetName","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","userProvidedTargetName","build","buildTarget","serve","serveTarget","test","testTarget","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","findExistingTargetsInProject","Error","handleUnknownExecutors","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","deleteWebpackConfig","options","webpackConfig","editTsConfig","jsInitTask","jsInitGenerator","skipFormat","tsConfigName","push","initTask","initGenerator","ensureDependencies","readNxJson","hasPlugin","plugins","some","p","plugin","addOrChangeBuildTarget","addOrChangeServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","uiFramework","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","imports","compiler","undefined","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IAgCsBA,0BAA0B;eAA1BA;;IA2OtB,OAA0C;eAA1C;;;;wBAlQO;oBAC0C;gCAe1C;sBAEmB;iCACE;oCAEO;AAE5B,eAAeA,2BACpBC,IAAU,EACVC,MAAwC;QAyItBC;QA5HlBD,SAEA,8EAA8E;IAC9E,8EAA8E;IAC9EA;IAfA,MAAME,QAA6B,EAAE;IAErC,MAAM,EACJC,OAAO,EACPC,WAAW,EACXC,MAAMC,WAAW,EAClB,GAAGC,IAAAA,gCAAwB,EAACR,MAAMC,OAAOQ,OAAO;IACjD,IAAIC,kBAAkB;IACtB,IAAIC,kBAAkB;IACtB,IAAIC,iBAAiB;;IAErBX,gBAAAA,UAAAA,QAAOY,oCAAPZ,QAAOY,aAAeR,gBAAgB;;IAItCJ,qBAAAA,WAAAA,QAAOa,8CAAPb,SAAOa,kBAAoB;IAE3B;;;GAGC,GACD,IAAIC,+BAA4C,CAAC;IAEjD,IAAI,CAACd,OAAOe,UAAU,EAAE;YA+FpBZ,kCAAAA;QA9FF,MAAMa,yBAAiD;YACrDC,OAAOjB,OAAOkB,WAAW;YACzBC,OAAOnB,OAAOoB,WAAW;YACzBC,MAAMrB,OAAOsB,UAAU;QACzB;QAEA,MAAM,EACJC,oBAAoB,EACpBC,kCAAkC,EAClCC,+BAA+B,EAC/BC,uBAAuB,EACxB,GAAGC,IAAAA,4CAA4B,EAACxB,SAASa;QAC1CF,+BAA+BY;QAC/B;;;;;;;;KAQC,GACD,IAAI,CAACH,qBAAqBN,KAAK,IAAIO,oCAAoC;YACrE,MAAM,IAAII,MACR,CAAC,YAAY,EAAE5B,OAAOQ,OAAO,CAAC,mDAAmD,CAAC;QAEtF;QAEA,IACEkB,wBAAwBT,KAAK,IA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BACnCC,eAAe/D,OAAO+D,aAAa;gBACnCC,uBAAuB;oBACrB;oBACA;oBACA;iBACD;gBACDC,SAAS;oBACPjE,OAAOkE,QAAQ,KAAK,QAChB,CAAC,4CAA4C,CAAC,GAC9C,CAAC,wCAAwC,CAAC;iBAC/C;gBACDpB,SAAS;oBAAC;iBAAU;YACtB,GACA,OACAqB;QAEJ,OAAO;YACLN,IAAAA,sCAAsB,EAAC9D,MAAMC,QAAQ,OAAOc;QAC9C;IACF;IAEA,IAAId,OAAO8D,aAAa,EAAE;QACxB,MAAMM,aAAa,MAAMC,IAAAA,wBAAe,EAACtE,MAAM;YAC7CS,SAASR,OAAOQ,OAAO;YACvBoD,aAAa5D,OAAO4D,WAAW;YAC/BG,eAAe/D,OAAO+D,aAAa;YACnCO,kBAAkB;YAClBC,gBAAgB;YAChBjD,YAAYX;YACZ2B,YAAY;QACd;QACApC,MAAMsC,IAAI,CAAC4B;IACb;IAEA,IAAI,CAACpE,OAAOsC,UAAU,EAAE;QACtB,MAAMkC,IAAAA,mBAAW,EAACzE;IACpB;IAEA,OAAO0E,IAAAA,wBAAgB,KAAIvE;AAC7B;MAEA,WAAeJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { InitGeneratorSchema } from './schema';
|
|
3
3
|
export declare function updateNxJsonSettings(tree: Tree): void;
|
|
4
|
-
export declare function initGenerator(tree: Tree, schema: InitGeneratorSchema): Promise<
|
|
4
|
+
export declare function initGenerator(tree: Tree, schema: InitGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
5
|
export default initGenerator;
|
|
@@ -16,9 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return _default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _extends = require("@swc/helpers/_/_extends");
|
|
20
19
|
const _devkit = require("@nx/devkit");
|
|
21
|
-
const _js = require("@nx/js");
|
|
22
20
|
const _utils = require("./lib/utils");
|
|
23
21
|
function updateNxJsonSettings(tree) {
|
|
24
22
|
var _nxJson_namedInputs, _nxJson_plugins;
|
|
@@ -46,18 +44,18 @@ function updateNxJsonSettings(tree) {
|
|
|
46
44
|
(0, _devkit.updateNxJson)(tree, nxJson);
|
|
47
45
|
}
|
|
48
46
|
async function initGenerator(tree, schema) {
|
|
49
|
-
(
|
|
47
|
+
if (process.env.NX_PCV3 === 'true') {
|
|
48
|
+
(0, _utils.addPlugin)(tree);
|
|
49
|
+
}
|
|
50
50
|
updateNxJsonSettings(tree);
|
|
51
51
|
const tasks = [];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(0, _utils.addPlugin)(tree);
|
|
52
|
+
if (!schema.skipPackageJson) {
|
|
53
|
+
tasks.push((0, _utils.moveToDevDependencies)(tree));
|
|
54
|
+
tasks.push((0, _utils.checkDependenciesInstalled)(tree, schema));
|
|
55
|
+
}
|
|
56
|
+
if (!schema.skipFormat) {
|
|
57
|
+
await (0, _devkit.formatFiles)(tree);
|
|
59
58
|
}
|
|
60
|
-
tasks.push((0, _utils.checkDependenciesInstalled)(tree, schema));
|
|
61
59
|
return (0, _devkit.runTasksInSerial)(...tasks);
|
|
62
60
|
}
|
|
63
61
|
const _default = initGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n readNxJson,\n runTasksInSerial,\n Tree,\n updateNxJson,\n} from '@nx/devkit';\n\nimport { InitGeneratorSchema } from './schema';\nimport {\n addPlugin,\n checkDependenciesInstalled,\n moveToDevDependencies,\n} from './lib/utils';\n\nexport function updateNxJsonSettings(tree: Tree) {\n const nxJson = readNxJson(tree);\n\n const productionFileSet = nxJson.namedInputs?.production;\n if (productionFileSet) {\n productionFileSet.push(\n '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',\n '!{projectRoot}/tsconfig.spec.json'\n );\n\n nxJson.namedInputs.production = Array.from(new Set(productionFileSet));\n }\n\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n nxJson.targetDefaults ??= {};\n nxJson.targetDefaults['@nx/vite:test'] ??= {};\n nxJson.targetDefaults['@nx/vite:test'].cache ??= true;\n nxJson.targetDefaults['@nx/vite:test'].inputs ??= [\n 'default',\n productionFileSet ? '^production' : '^default',\n ];\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport async function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n if (process.env.NX_PCV3 === 'true') {\n addPlugin(tree);\n }\n\n updateNxJsonSettings(tree);\n\n const tasks: GeneratorCallback[] = [];\n if (!schema.skipPackageJson) {\n tasks.push(moveToDevDependencies(tree));\n tasks.push(checkDependenciesInstalled(tree, schema));\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default initGenerator;\n"],"names":["updateNxJsonSettings","initGenerator","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","process","env","NX_PCV3","addPlugin","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IAgBgBA,oBAAoB;eAApBA;;IAgCMC,aAAa;eAAbA;;IAoBtB,OAA6B;eAA7B;;;wBA7DO;uBAOA;AAEA,SAASD,qBAAqBE,IAAU;QAGnBC,qBAURA;IAZlB,MAAMA,SAASC,IAAAA,kBAAU,EAACF;IAE1B,MAAMG,qBAAoBF,sBAAAA,OAA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,KAAIN;AAC7B;MAEA,WAAezB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { InitGeneratorSchema } from '../schema';
|
|
3
3
|
export declare function checkDependenciesInstalled(host: Tree, schema: InitGeneratorSchema): import("@nx/devkit").GeneratorCallback;
|
|
4
|
-
export declare function moveToDevDependencies(tree: Tree): void;
|
|
4
|
+
export declare function moveToDevDependencies(tree: Tree): () => void;
|
|
5
5
|
export declare function createVitestConfig(tree: Tree): void;
|
|
6
6
|
export declare function addPlugin(tree: Tree): void;
|
|
@@ -22,47 +22,26 @@ _export(exports, {
|
|
|
22
22
|
const _devkit = require("@nx/devkit");
|
|
23
23
|
const _versions = require("../../../utils/versions");
|
|
24
24
|
function checkDependenciesInstalled(host, schema) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
devDependencies['@nx/vite'] = _versions.nxVersion;
|
|
32
|
-
devDependencies['vite'] = _versions.viteVersion;
|
|
33
|
-
devDependencies['vitest'] = _versions.vitestVersion;
|
|
34
|
-
devDependencies['@vitest/ui'] = _versions.vitestVersion;
|
|
35
|
-
if (schema.testEnvironment === 'jsdom') {
|
|
36
|
-
devDependencies['jsdom'] = _versions.jsdomVersion;
|
|
37
|
-
} else if (schema.testEnvironment === 'happy-dom') {
|
|
38
|
-
devDependencies['happy-dom'] = _versions.happyDomVersion;
|
|
39
|
-
} else if (schema.testEnvironment === 'edge-runtime') {
|
|
40
|
-
devDependencies['@edge-runtime/vm'] = _versions.edgeRuntimeVmVersion;
|
|
41
|
-
} else if (schema.testEnvironment !== 'node' && schema.testEnvironment) {
|
|
42
|
-
_devkit.logger.info(`A custom environment was provided: ${schema.testEnvironment}. You need to install it manually.`);
|
|
43
|
-
}
|
|
44
|
-
if (schema.uiFramework === 'react') {
|
|
45
|
-
if (schema.compiler === 'swc') {
|
|
46
|
-
devDependencies['@vitejs/plugin-react-swc'] = _versions.vitePluginReactSwcVersion;
|
|
47
|
-
} else {
|
|
48
|
-
devDependencies['@vitejs/plugin-react'] = _versions.vitePluginReactVersion;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (schema.includeLib) {
|
|
52
|
-
devDependencies['vite-plugin-dts'] = _versions.vitePluginDtsVersion;
|
|
53
|
-
}
|
|
54
|
-
return (0, _devkit.addDependenciesToPackageJson)(host, dependencies, devDependencies);
|
|
25
|
+
return (0, _devkit.addDependenciesToPackageJson)(host, {}, {
|
|
26
|
+
'@nx/vite': _versions.nxVersion,
|
|
27
|
+
vite: _versions.viteVersion,
|
|
28
|
+
vitest: _versions.vitestVersion,
|
|
29
|
+
'@vitest/ui': _versions.vitestVersion
|
|
30
|
+
});
|
|
55
31
|
}
|
|
56
32
|
function moveToDevDependencies(tree) {
|
|
33
|
+
let wasUpdated = false;
|
|
57
34
|
(0, _devkit.updateJson)(tree, 'package.json', (packageJson)=>{
|
|
58
35
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
59
36
|
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
60
37
|
if (packageJson.dependencies['@nx/vite']) {
|
|
61
38
|
packageJson.devDependencies['@nx/vite'] = packageJson.dependencies['@nx/vite'];
|
|
62
39
|
delete packageJson.dependencies['@nx/vite'];
|
|
40
|
+
wasUpdated = true;
|
|
63
41
|
}
|
|
64
42
|
return packageJson;
|
|
65
43
|
});
|
|
44
|
+
return wasUpdated ? ()=>(0, _devkit.installPackagesTask)(tree) : ()=>{};
|
|
66
45
|
}
|
|
67
46
|
function createVitestConfig(tree) {
|
|
68
47
|
var _nxJson_namedInputs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/vite/src/generators/init/lib/utils.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/vite/src/generators/init/lib/utils.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n installPackagesTask,\n readNxJson,\n Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { nxVersion, vitestVersion, viteVersion } from '../../../utils/versions';\nimport { InitGeneratorSchema } from '../schema';\n\nexport function checkDependenciesInstalled(\n host: Tree,\n schema: InitGeneratorSchema\n) {\n return addDependenciesToPackageJson(\n host,\n {},\n {\n '@nx/vite': nxVersion,\n vite: viteVersion,\n vitest: vitestVersion,\n '@vitest/ui': vitestVersion,\n }\n );\n}\n\nexport function moveToDevDependencies(tree: Tree) {\n let wasUpdated = false;\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.dependencies = packageJson.dependencies || {};\n packageJson.devDependencies = packageJson.devDependencies || {};\n\n if (packageJson.dependencies['@nx/vite']) {\n packageJson.devDependencies['@nx/vite'] =\n packageJson.dependencies['@nx/vite'];\n delete packageJson.dependencies['@nx/vite'];\n wasUpdated = true;\n }\n return packageJson;\n });\n\n return wasUpdated ? () => installPackagesTask(tree) : () => {};\n}\n\nexport function createVitestConfig(tree: Tree) {\n const nxJson = readNxJson(tree);\n\n const productionFileSet = nxJson.namedInputs?.production;\n if (productionFileSet) {\n productionFileSet.push(\n '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',\n '!{projectRoot}/tsconfig.spec.json'\n );\n\n nxJson.namedInputs.production = Array.from(new Set(productionFileSet));\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport function addPlugin(tree: Tree) {\n const nxJson = readNxJson(tree);\n nxJson.plugins ??= [];\n\n for (const plugin of nxJson.plugins) {\n if (\n typeof plugin === 'string'\n ? plugin === '@nx/vite/plugin'\n : plugin.plugin === '@nx/vite/plugin'\n ) {\n return;\n }\n }\n\n nxJson.plugins.push({\n plugin: '@nx/vite/plugin',\n options: {\n buildTargetName: 'build',\n previewTargetName: 'preview',\n testTargetName: 'test',\n serveTargetName: 'serve',\n serveStaticTargetName: 'serve-static',\n },\n });\n updateNxJson(tree, nxJson);\n}\n"],"names":["checkDependenciesInstalled","moveToDevDependencies","createVitestConfig","addPlugin","host","schema","addDependenciesToPackageJson","nxVersion","vite","viteVersion","vitest","vitestVersion","tree","wasUpdated","updateJson","packageJson","dependencies","devDependencies","installPackagesTask","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","updateNxJson","plugins","plugin","options","buildTargetName","previewTargetName","testTargetName","serveTargetName","serveStaticTargetName"],"mappings":";;;;;;;;IAWgBA,0BAA0B;eAA1BA;;IAgBAC,qBAAqB;eAArBA;;IAkBAC,kBAAkB;eAAlBA;;IAgBAC,SAAS;eAATA;;;wBAtDT;0BAC+C;AAG/C,SAASH,2BACdI,IAAU,EACVC,MAA2B;IAE3B,OAAOC,IAAAA,oCAA4B,EACjCF,MACA,CAAC,GACD;QACE,YAAYG,mBAAS;QACrBC,MAAMC,qBAAW;QACjBC,QAAQC,uBAAa;QACrB,cAAcA,uBAAa;IAC7B;AAEJ;AAEO,SAASV,sBAAsBW,IAAU;IAC9C,IAAIC,aAAa;IACjBC,IAAAA,kBAAU,EAACF,MAAM,gBAAgB,CAACG;QAChCA,YAAYC,YAAY,GAAGD,YAAYC,YAAY,IAAI,CAAC;QACxDD,YAAYE,eAAe,GAAGF,YAAYE,eAAe,IAAI,CAAC;QAE9D,IAAIF,YAAYC,YAAY,CAAC,WAAW,EAAE;YACxCD,YAAYE,eAAe,CAAC,WAAW,GACrCF,YAAYC,YAAY,CAAC,WAAW;YACtC,OAAOD,YAAYC,YAAY,CAAC,WAAW;YAC3CH,aAAa;QACf;QACA,OAAOE;IACT;IAEA,OAAOF,aAAa,IAAMK,IAAAA,2BAAmB,EAACN,QAAQ,KAAO;AAC/D;AAEO,SAASV,mBAAmBU,IAAU;QAGjBO;IAF1B,MAAMA,SAASC,IAAAA,kBAAU,EAACR;IAE1B,MAAMS,qBAAoBF,sBAAAA,OAAOG,WAAW,qBAAlBH,oBAAoBI,UAAU;IACxD,IAAIF,mBAAmB;QACrBA,kBAAkBG,IAAI,CACpB,yDACA;QAGFL,OAAOG,WAAW,CAACC,UAAU,GAAGE,MAAMC,IAAI,CAAC,IAAIC,IAAIN;IACrD;IAEAO,IAAAA,oBAAY,EAAChB,MAAMO;AACrB;AAEO,SAAShB,UAAUS,IAAU;QAElCO;IADA,MAAMA,SAASC,IAAAA,kBAAU,EAACR;;IAC1BO,aAAAA,UAAAA,QAAOU,8BAAPV,QAAOU,UAAY,EAAE;IAErB,KAAK,MAAMC,UAAUX,OAAOU,OAAO,CAAE;QACnC,IACE,OAAOC,WAAW,WACdA,WAAW,oBACXA,OAAOA,MAAM,KAAK,mBACtB;YACA;QACF;IACF;IAEAX,OAAOU,OAAO,CAACL,IAAI,CAAC;QAClBM,QAAQ;QACRC,SAAS;YACPC,iBAAiB;YACjBC,mBAAmB;YACnBC,gBAAgB;YAChBC,iBAAiB;YACjBC,uBAAuB;QACzB;IACF;IACAR,IAAAA,oBAAY,EAAChB,MAAMO;AACrB"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export interface InitGeneratorSchema {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
includeLib?: boolean;
|
|
5
|
-
testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
|
|
6
|
-
rootProject?: boolean;
|
|
2
|
+
skipFormat?: boolean;
|
|
3
|
+
skipPackageJson?: boolean;
|
|
7
4
|
}
|
|
@@ -5,30 +5,15 @@
|
|
|
5
5
|
"$id": "init-vite-plugin",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"description": "UI Framework to use for Vite.",
|
|
11
|
-
"enum": ["react", "none"],
|
|
12
|
-
"default": "react",
|
|
13
|
-
"x-prompt": "What UI framework plugin should Vite use?"
|
|
14
|
-
},
|
|
15
|
-
"compiler": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "Compiler to use for Vite when UI Framework is React.",
|
|
18
|
-
"enum": ["babel", "swc"],
|
|
19
|
-
"default": "babel"
|
|
20
|
-
},
|
|
21
|
-
"includeLib": {
|
|
8
|
+
"skipFormat": {
|
|
9
|
+
"description": "Skip formatting files.",
|
|
22
10
|
"type": "boolean",
|
|
23
|
-
"description": "Add dependencies needed to build libraries.",
|
|
24
11
|
"default": false
|
|
25
12
|
},
|
|
26
|
-
"
|
|
27
|
-
"description": "
|
|
28
|
-
"type": "
|
|
29
|
-
"
|
|
30
|
-
"default": "jsdom"
|
|
13
|
+
"skipPackageJson": {
|
|
14
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"default": false
|
|
31
17
|
}
|
|
32
|
-
}
|
|
33
|
-
"examplesFile": "../../../docs/init-examples.md"
|
|
18
|
+
}
|
|
34
19
|
}
|
|
@@ -20,6 +20,7 @@ const _init = require("../init/init");
|
|
|
20
20
|
const _versions = require("../../utils/versions");
|
|
21
21
|
const _js = require("@nx/js");
|
|
22
22
|
const _path = require("path");
|
|
23
|
+
const _ensuredependencies = require("../../utils/ensure-dependencies");
|
|
23
24
|
async function vitestGenerator(tree, schema, hasPlugin = false) {
|
|
24
25
|
var _nxJson_plugins;
|
|
25
26
|
const tasks = [];
|
|
@@ -31,11 +32,14 @@ async function vitestGenerator(tree, schema, hasPlugin = false) {
|
|
|
31
32
|
const testTarget = (_ref = (_schema_testTarget = schema.testTarget) != null ? _schema_testTarget : (0, _generatorutils.findExistingTargetsInProject)(targets).validFoundTargetName.test) != null ? _ref : 'test';
|
|
32
33
|
(0, _generatorutils.addOrChangeTestTarget)(tree, schema, testTarget);
|
|
33
34
|
}
|
|
35
|
+
tasks.push(await (0, _js.initGenerator)(tree, _extends._({}, schema, {
|
|
36
|
+
skipFormat: true
|
|
37
|
+
})));
|
|
34
38
|
const initTask = await (0, _init.default)(tree, {
|
|
35
|
-
|
|
36
|
-
testEnvironment: schema.testEnvironment
|
|
39
|
+
skipFormat: true
|
|
37
40
|
});
|
|
38
41
|
tasks.push(initTask);
|
|
42
|
+
tasks.push((0, _ensuredependencies.ensureDependencies)(tree, schema));
|
|
39
43
|
if (!schema.skipViteConfig) {
|
|
40
44
|
if (schema.uiFramework === 'react') {
|
|
41
45
|
(0, _generatorutils.createOrEditViteConfig)(tree, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/generators/vitest/vitest-generator.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n GeneratorCallback,\n joinPathFragments,\n offsetFromRoot,\n readNxJson,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport {\n addOrChangeTestTarget,\n createOrEditViteConfig,\n findExistingTargetsInProject,\n} from '../../utils/generator-utils';\nimport { VitestGeneratorSchema } from './schema';\n\nimport initGenerator from '../init/init';\nimport {\n vitestCoverageIstanbulVersion,\n vitestCoverageV8Version,\n} from '../../utils/versions';\n\nimport { addTsLibDependencies } from '@nx/js';\nimport { join } from 'path';\n\nexport async function vitestGenerator(\n tree: Tree,\n schema: VitestGeneratorSchema,\n hasPlugin = false\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, root, projectType } = readProjectConfiguration(\n tree,\n schema.project\n );\n\n const nxJson = readNxJson(tree);\n const hasPluginCheck = nxJson.plugins?.some(\n (p) =>\n (typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin') || hasPlugin\n );\n if (!hasPluginCheck) {\n const testTarget =\n schema.testTarget ??\n findExistingTargetsInProject(targets).validFoundTargetName.test ??\n 'test';\n addOrChangeTestTarget(tree, schema, testTarget);\n }\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n testEnvironment: schema.testEnvironment,\n });\n tasks.push(initTask);\n\n if (!schema.skipViteConfig) {\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: projectType === 'library',\n includeVitest: true,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [`import react from '@vitejs/plugin-react'`],\n plugins: ['react()'],\n coverageProvider: schema.coverageProvider,\n },\n true\n );\n } else {\n createOrEditViteConfig(\n tree,\n {\n ...schema,\n includeVitest: true,\n includeLib: projectType === 'library',\n },\n true\n );\n }\n }\n\n createFiles(tree, schema, root);\n updateTsConfig(tree, schema, root);\n\n const coverageProviderDependency = getCoverageProviderDependency(\n schema.coverageProvider\n );\n\n const installCoverageProviderTask = addDependenciesToPackageJson(\n tree,\n {},\n coverageProviderDependency\n );\n tasks.push(installCoverageProviderTask);\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nfunction updateTsConfig(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n if (tree.exists(joinPathFragments(projectRoot, 'tsconfig.spec.json'))) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.spec.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (\n json.references &&\n !json.references.some((r) => r.path === './tsconfig.spec.json')\n ) {\n json.references.push({\n path: './tsconfig.spec.json',\n });\n }\n return json;\n }\n );\n } else {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n }\n\n if (options.inSourceTests) {\n const tsconfigLibPath = joinPathFragments(projectRoot, 'tsconfig.lib.json');\n const tsconfigAppPath = joinPathFragments(projectRoot, 'tsconfig.app.json');\n if (tree.exists(tsconfigLibPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n } else if (tree.exists(tsconfigAppPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.app.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n }\n\n addTsLibDependencies(tree);\n }\n}\n\nfunction createFiles(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n generateFiles(tree, join(__dirname, 'files'), projectRoot, {\n tmpl: '',\n ...options,\n projectRoot,\n offsetFromRoot: offsetFromRoot(projectRoot),\n });\n}\n\nfunction getCoverageProviderDependency(\n coverageProvider: VitestGeneratorSchema['coverageProvider']\n) {\n switch (coverageProvider) {\n case 'v8':\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n case 'istanbul':\n return {\n '@vitest/coverage-istanbul': vitestCoverageIstanbulVersion,\n };\n default:\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n }\n}\n\nexport default vitestGenerator;\n"],"names":["vitestGenerator","tree","schema","hasPlugin","nxJson","tasks","targets","root","projectType","readProjectConfiguration","project","readNxJson","hasPluginCheck","plugins","some","p","plugin","testTarget","findExistingTargetsInProject","validFoundTargetName","test","addOrChangeTestTarget","initTask","initGenerator","uiFramework","testEnvironment","push","skipViteConfig","createOrEditViteConfig","includeLib","includeVitest","inSourceTests","rollupOptionsExternal","imports","coverageProvider","createFiles","updateTsConfig","coverageProviderDependency","getCoverageProviderDependency","installCoverageProviderTask","addDependenciesToPackageJson","skipFormat","formatFiles","runTasksInSerial","options","projectRoot","exists","joinPathFragments","updateJson","json","compilerOptions","types","includes","references","r","path","tsconfigLibPath","tsconfigAppPath","addTsLibDependencies","generateFiles","join","__dirname","tmpl","offsetFromRoot","vitestCover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ACF,aAAa,sBAC/B,CAACI;oBACEA;;gBAAAA,CAAAA,WAAAA,wBAAAA,KAAKC,eAAe,EAACC,0BAArBF,sBAAqBE,QAAU,EAAE,AAAD,EAAGzB,IAAI,CAAC;gBACzC,OAAOuB;YACT;QAEJ;QAEAS,IAAAA,wBAAoB,EAACzD;IACvB;AACF;AAEA,SAASkC,YACPlC,IAAU,EACV2C,OAA8B,EAC9BC,WAAmB;IAEnBc,IAAAA,qBAAa,EAAC1D,MAAM2D,IAAAA,UAAI,EAACC,WAAW,UAAUhB,aAAa;QACzDiB,MAAM;OACHlB;QACHC;QACAkB,gBAAgBA,IAAAA,sBAAc,EAAClB;;AAEnC;AAEA,SAASP,8BACPJ,gBAA2D;IAE3D,OAAQA;QACN,KAAK;YACH,OAAO;gBACL,uBAAuB8B,iCAAuB;YAChD;QACF,KAAK;YACH,OAAO;gBACL,6BAA6BC,uCAA6B;YAC5D;QACF;YACE,OAAO;gBACL,uBAAuBD,iCAAuB;YAChD;IACJ;AACF;MAEA,WAAehE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/vitest/vitest-generator.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n GeneratorCallback,\n joinPathFragments,\n offsetFromRoot,\n readNxJson,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport {\n addOrChangeTestTarget,\n createOrEditViteConfig,\n findExistingTargetsInProject,\n} from '../../utils/generator-utils';\nimport { VitestGeneratorSchema } from './schema';\n\nimport initGenerator from '../init/init';\nimport {\n vitestCoverageIstanbulVersion,\n vitestCoverageV8Version,\n} from '../../utils/versions';\n\nimport { addTsLibDependencies, initGenerator as jsInitGenerator } from '@nx/js';\nimport { join } from 'path';\nimport { ensureDependencies } from '../../utils/ensure-dependencies';\n\nexport async function vitestGenerator(\n tree: Tree,\n schema: VitestGeneratorSchema,\n hasPlugin = false\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, root, projectType } = readProjectConfiguration(\n tree,\n schema.project\n );\n\n const nxJson = readNxJson(tree);\n const hasPluginCheck = nxJson.plugins?.some(\n (p) =>\n (typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin') || hasPlugin\n );\n if (!hasPluginCheck) {\n const testTarget =\n schema.testTarget ??\n findExistingTargetsInProject(targets).validFoundTargetName.test ??\n 'test';\n addOrChangeTestTarget(tree, schema, testTarget);\n }\n\n tasks.push(await jsInitGenerator(tree, { ...schema, skipFormat: true }));\n const initTask = await initGenerator(tree, { skipFormat: true });\n tasks.push(initTask);\n tasks.push(ensureDependencies(tree, schema));\n\n if (!schema.skipViteConfig) {\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: projectType === 'library',\n includeVitest: true,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [`import react from '@vitejs/plugin-react'`],\n plugins: ['react()'],\n coverageProvider: schema.coverageProvider,\n },\n true\n );\n } else {\n createOrEditViteConfig(\n tree,\n {\n ...schema,\n includeVitest: true,\n includeLib: projectType === 'library',\n },\n true\n );\n }\n }\n\n createFiles(tree, schema, root);\n updateTsConfig(tree, schema, root);\n\n const coverageProviderDependency = getCoverageProviderDependency(\n schema.coverageProvider\n );\n\n const installCoverageProviderTask = addDependenciesToPackageJson(\n tree,\n {},\n coverageProviderDependency\n );\n tasks.push(installCoverageProviderTask);\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nfunction updateTsConfig(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n if (tree.exists(joinPathFragments(projectRoot, 'tsconfig.spec.json'))) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.spec.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (\n json.references &&\n !json.references.some((r) => r.path === './tsconfig.spec.json')\n ) {\n json.references.push({\n path: './tsconfig.spec.json',\n });\n }\n return json;\n }\n );\n } else {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.json'),\n (json) => {\n if (!json.compilerOptions?.types?.includes('vitest')) {\n if (json.compilerOptions?.types) {\n json.compilerOptions.types.push('vitest');\n } else {\n json.compilerOptions ??= {};\n json.compilerOptions.types = ['vitest'];\n }\n }\n return json;\n }\n );\n }\n\n if (options.inSourceTests) {\n const tsconfigLibPath = joinPathFragments(projectRoot, 'tsconfig.lib.json');\n const tsconfigAppPath = joinPathFragments(projectRoot, 'tsconfig.app.json');\n if (tree.exists(tsconfigLibPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n } else if (tree.exists(tsconfigAppPath)) {\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.app.json'),\n (json) => {\n (json.compilerOptions.types ??= []).push('vitest/importMeta');\n return json;\n }\n );\n }\n\n addTsLibDependencies(tree);\n }\n}\n\nfunction createFiles(\n tree: Tree,\n options: VitestGeneratorSchema,\n projectRoot: string\n) {\n generateFiles(tree, join(__dirname, 'files'), projectRoot, {\n tmpl: '',\n ...options,\n projectRoot,\n offsetFromRoot: offsetFromRoot(projectRoot),\n });\n}\n\nfunction getCoverageProviderDependency(\n coverageProvider: VitestGeneratorSchema['coverageProvider']\n) {\n switch (coverageProvider) {\n case 'v8':\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n case 'istanbul':\n return {\n '@vitest/coverage-istanbul': vitestCoverageIstanbulVersion,\n };\n default:\n return {\n '@vitest/coverage-v8': vitestCoverageV8Version,\n };\n }\n}\n\nexport default vitestGenerator;\n"],"names":["vitestGenerator","tree","schema","hasPlugin","nxJson","tasks","targets","root","projectType","readProjectConfiguration","project","readNxJson","hasPluginCheck","plugins","some","p","plugin","testTarget","findExistingTargetsInProject","validFoundTargetName","test","addOrChangeTestTarget","push","jsInitGenerator","skipFormat","initTask","initGenerator","ensureDependencies","skipViteConfig","uiFramework","createOrEditViteConfig","includeLib","includeVitest","inSourceTests","rollupOptionsExternal","imports","coverageProvider","createFiles","updateTsConfig","coverageProviderDependency","getCoverageProviderDependency","installCoverageProviderTask","addDependenciesToPackageJson","formatFiles","runTasksInSerial","options","projectRoot","exists","joinPathFragments","updateJson","json","compilerOptions","types","includes","references","r","path","tsconfigLibPath","tsconfigAppPath","addTsLibDependencies","generateFiles","join","__dirname","tmpl","offsetFromRoot","vitestCoverageV8Version","vitestCoverageIstanbulVersion"],"mappings":";;;;;;;;IA8BsBA,eAAe;eAAfA;;IAwMtB,OAA+B;eAA/B;;;;wBA1NO;gCAKA;sBAGmB;0BAInB;oBAEgE;sBAClD;oCACc;AAE5B,eAAeA,gBACpBC,IAAU,EACVC,MAA6B,EAC7BC,YAAY,KAAK;QAUMC;IARvB,MAAMC,QAA6B,EAAE;IAErC,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,IAAAA,gCAAwB,EAC7DR,MACAC,OAAOQ,OAAO;IAGhB,MAAMN,SAASO,IAAAA,kBAAU,EAACV;IAC1B,MAAMW,kBAAiBR,kBAAAA,OAAOS,OAAO,qBAAdT,gBAAgBU,IAAI,CACzC,CAACC,IACC,AAAC,CAAA,OAAOA,MAAM,WACVA,MAAM,oBACNA,EAAEC,MAAM,KAAK,iBAAgB,KAAMb;IAE3C,IAAI,CAACS,gBAAgB;YAEjBV,oBAAAA;QADF,MAAMe,aACJf,CAAAA,OAAAA,CAAAA,qBAAAA,OAAOe,UA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6BC,uCAA6B;YAC5D;QACF;YACE,OAAO;gBACL,uBAAuBD,iCAAuB;YAChD;IACJ;AACF;MAEA,WAAejE"}
|
|
@@ -35,8 +35,8 @@ async function updateBuildDir(tree) {
|
|
|
35
35
|
let configContents = tree.read(config, 'utf-8');
|
|
36
36
|
configContents = (0, _editbuildconfig.updateBuildOutDirAndRoot)(options, configContents, projectConfig, targetName, tree, projectName, config);
|
|
37
37
|
configContents = (0, _edittestconfig.updateTestConfig)(configContents, projectConfig, config);
|
|
38
|
-
if (((_options_fileReplacements = options
|
|
39
|
-
configContents = (0, _addfilereplacements.addFileReplacements)(configContents, options
|
|
38
|
+
if (((_options_fileReplacements = options['fileReplacements']) == null ? void 0 : _options_fileReplacements.length) > 0) {
|
|
39
|
+
configContents = (0, _addfilereplacements.addFileReplacements)(configContents, options['fileReplacements'], config);
|
|
40
40
|
}
|
|
41
41
|
tree.write(config, configContents);
|
|
42
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-17-2-0/update-vite-config.ts"],"sourcesContent":["import {\n Tree,\n formatFiles,\n getProjects,\n joinPathFragments,\n logger,\n} from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { ViteBuildExecutorOptions } from '../../executors/build/schema';\nimport { updateBuildOutDirAndRoot } from './lib/edit-build-config';\nimport { updateTestConfig } from './lib/edit-test-config';\nimport { addFileReplacements } from './lib/add-file-replacements';\nimport { tsquery } from '@phenomnomnominal/tsquery';\nimport ts = require('typescript');\n\nexport default async function updateBuildDir(tree: Tree) {\n const projects = getProjects(tree);\n forEachExecutorOptions<ViteBuildExecutorOptions>(\n tree,\n '@nx/vite:build',\n (options, projectName, targetName) => {\n const projectConfig = projects.get(projectName);\n const config =\n options.configFile || findViteConfig(tree, projectConfig.root);\n if (!config || !tree.exists(config)) {\n return;\n }\n let configContents = tree.read(config, 'utf-8');\n\n configContents = updateBuildOutDirAndRoot(\n options,\n configContents,\n projectConfig,\n targetName,\n tree,\n projectName,\n config\n );\n\n configContents = updateTestConfig(configContents, projectConfig, config);\n\n if (options
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-17-2-0/update-vite-config.ts"],"sourcesContent":["import {\n Tree,\n formatFiles,\n getProjects,\n joinPathFragments,\n logger,\n} from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { ViteBuildExecutorOptions } from '../../executors/build/schema';\nimport { updateBuildOutDirAndRoot } from './lib/edit-build-config';\nimport { updateTestConfig } from './lib/edit-test-config';\nimport { addFileReplacements } from './lib/add-file-replacements';\nimport { tsquery } from '@phenomnomnominal/tsquery';\nimport ts = require('typescript');\n\nexport default async function updateBuildDir(tree: Tree) {\n const projects = getProjects(tree);\n forEachExecutorOptions<ViteBuildExecutorOptions>(\n tree,\n '@nx/vite:build',\n (options, projectName, targetName) => {\n const projectConfig = projects.get(projectName);\n const config =\n options.configFile || findViteConfig(tree, projectConfig.root);\n if (!config || !tree.exists(config)) {\n return;\n }\n let configContents = tree.read(config, 'utf-8');\n\n configContents = updateBuildOutDirAndRoot(\n options,\n configContents,\n projectConfig,\n targetName,\n tree,\n projectName,\n config\n );\n\n configContents = updateTestConfig(configContents, projectConfig, config);\n\n if (options['fileReplacements']?.length > 0) {\n configContents = addFileReplacements(\n configContents,\n options['fileReplacements'],\n config\n );\n }\n\n tree.write(config, configContents);\n }\n );\n\n await formatFiles(tree);\n}\n\nfunction findViteConfig(tree: Tree, searchRoot: string) {\n const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];\n\n for (const ext of allowsExt) {\n if (tree.exists(joinPathFragments(searchRoot, `vite.config.${ext}`))) {\n return joinPathFragments(searchRoot, `vite.config.${ext}`);\n }\n }\n}\n\nexport function getConfigNode(configFileContents: string): ts.Node | undefined {\n if (!configFileContents) {\n return;\n }\n let configNode = tsquery.query(\n configFileContents,\n `ObjectLiteralExpression`\n )?.[0];\n\n const arrowFunctionReturnStatement = tsquery.query(\n configFileContents,\n `ArrowFunction Block ReturnStatement ObjectLiteralExpression`\n )?.[0];\n\n if (arrowFunctionReturnStatement) {\n configNode = arrowFunctionReturnStatement;\n }\n\n return configNode;\n}\n\nexport function notFoundWarning(configPath: string) {\n logger.warn(`\n Could not migrate your ${configPath} file.\n Please add the build.outDir and root options in your ${configPath} file.\n You can find more information on how to configure vite for Nx here:\n \n https://nx.dev/recipes/vite/configure-vite\n `);\n}\n"],"names":["updateBuildDir","getConfigNode","notFoundWarning","ts","tree","projects","getProjects","forEachExecutorOptions","options","projectName","targetName","projectConfig","get","config","configFile","findViteConfig","root","exists","configContents","read","updateBuildOutDirAndRoot","updateTestConfig","length","addFileReplacements","write","formatFiles","searchRoot","allowsExt","ext","joinPathFragments","configFileContents","tsquery","configNode","query","arrowFunctionReturnStatement","configPath","logger","warn"],"mappings":";;;;;;;;IAeA,OAuCC;eAvC6BA;;IAmDdC,aAAa;eAAbA;;IAqBAC,eAAe;eAAfA;;;wBAjFT;sCACgC;iCAEE;gCACR;qCACG;yBACZ;AACxB,MAAOC,aAAa;AAEL,eAAeH,eAAeI,IAAU;IACrD,MAAMC,WAAWC,IAAAA,mBAAW,EAACF;IAC7BG,IAAAA,4CAAsB,EACpBH,MACA,kBACA,CAACI,SAASC,aAAaC;YAqBjBF;QApBJ,MAAMG,gBAAgBN,SAASO,GAAG,CAACH;QACnC,MAAMI,SACJL,QAAQM,UAAU,IAAIC,eAAeX,MAAMO,cAAcK,IAAI;QAC/D,IAAI,CAACH,UAAU,CAACT,KAAKa,MAAM,CAACJ,SAAS;YACnC;QACF;QACA,IAAIK,iBAAiBd,KAAKe,IAAI,CAACN,QAAQ;QAEvCK,iBAAiBE,IAAAA,yCAAwB,EACvCZ,SACAU,gBACAP,eACAD,YACAN,MACAK,aACAI;QAGFK,iBAAiBG,IAAAA,gCAAgB,EAACH,gBAAgBP,eAAeE;QAEjE,IAAIL,EAAAA,4BAAAA,OAAO,CAAC,mBAAmB,qBAA3BA,0BAA6Bc,MAAM,IAAG,GAAG;YAC3CJ,iBAAiBK,IAAAA,wCAAmB,EAClCL,gBACAV,OAAO,CAAC,mBAAmB,EAC3BK;QAEJ;QAEAT,KAAKoB,KAAK,CAACX,QAAQK;IACrB;IAGF,MAAMO,IAAAA,mBAAW,EAACrB;AACpB;AAEA,SAASW,eAAeX,IAAU,EAAEsB,UAAkB;IACpD,MAAMC,YAAY;QAAC;QAAM;QAAO;QAAM;QAAO;QAAO;KAAM;IAE1D,KAAK,MAAMC,OAAOD,UAAW;QAC3B,IAAIvB,KAAKa,MAAM,CAACY,IAAAA,yBAAiB,EAACH,YAAY,CAAC,YAAY,EAAEE,IAAI,CAAC,IAAI;YACpE,OAAOC,IAAAA,yBAAiB,EAACH,YAAY,CAAC,YAAY,EAAEE,IAAI,CAAC;QAC3D;IACF;AACF;AAEO,SAAS3B,cAAc6B,kBAA0B;QAIrCC,gBAKoBA;IARrC,IAAI,CAACD,oBAAoB;QACvB;IACF;IACA,IAAIE,cAAaD,iBAAAA,gBAAO,CAACE,KAAK,CAC5BH,oBACA,CAAC,uBAAuB,CAAC,sBAFVC,cAGd,CAAC,EAAE;IAEN,MAAMG,gCAA+BH,kBAAAA,gBAAO,CAACE,KAAK,CAChDH,oBACA,CAAC,2DAA2D,CAAC,sBAF1BC,eAGlC,CAAC,EAAE;IAEN,IAAIG,8BAA8B;QAChCF,aAAaE;IACf;IAEA,OAAOF;AACT;AAEO,SAAS9B,gBAAgBiC,UAAkB;IAChDC,cAAM,CAACC,IAAI,CAAC,CAAC;yBACU,EAAEF,WAAW;uDACiB,EAAEA,WAAW;;;;EAIlE,CAAC;AACH"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -65,16 +65,20 @@ async function buildViteTargets(configFilePath, projectRoot, options, context) {
|
|
|
65
65
|
command: 'build',
|
|
66
66
|
mode: 'production'
|
|
67
67
|
}, configFilePath);
|
|
68
|
-
const { buildOutputs, testOutputs } = getOutputs(viteConfig == null ? void 0 : viteConfig.config, projectRoot);
|
|
68
|
+
const { buildOutputs, testOutputs, hasTest } = getOutputs(viteConfig == null ? void 0 : viteConfig.config, projectRoot);
|
|
69
69
|
const namedInputs = (0, _getnamedinputs.getNamedInputs)(projectRoot, context);
|
|
70
70
|
const targets = {};
|
|
71
|
+
// If file is not vitest.config, create targets for build, serve, preview and serve-static
|
|
71
72
|
if (!configFilePath.includes('vitest.config')) {
|
|
72
73
|
targets[options.buildTargetName] = await buildTarget(options.buildTargetName, namedInputs, buildOutputs, projectRoot);
|
|
73
74
|
targets[options.serveTargetName] = serveTarget(projectRoot);
|
|
74
75
|
targets[options.previewTargetName] = previewTarget(projectRoot);
|
|
75
76
|
targets[options.serveStaticTargetName] = serveStaticTarget(options);
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
+
// if file is vitest.config or vite.config has definition for test, create target for test
|
|
79
|
+
if (configFilePath.includes('vitest.config') || hasTest) {
|
|
80
|
+
targets[options.testTargetName] = await testTarget(namedInputs, testOutputs, projectRoot);
|
|
81
|
+
}
|
|
78
82
|
return targets;
|
|
79
83
|
}
|
|
80
84
|
async function buildTarget(buildTargetName, namedInputs, outputs, projectRoot) {
|
|
@@ -166,7 +170,8 @@ function getOutputs(viteConfig, projectRoot) {
|
|
|
166
170
|
],
|
|
167
171
|
testOutputs: [
|
|
168
172
|
reportsDirectoryPath
|
|
169
|
-
]
|
|
173
|
+
],
|
|
174
|
+
hasTest: !!test
|
|
170
175
|
};
|
|
171
176
|
}
|
|
172
177
|
function normalizeOutputPath(outputPath, projectRoot, path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n detectPackageManager,\n joinPathFragments,\n readJsonFile,\n TargetConfiguration,\n workspaceRoot,\n writeJsonFile,\n} from '@nx/devkit';\nimport { dirname, isAbsolute, join, relative } from 'path';\nimport { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';\nimport { existsSync, readdirSync } from 'fs';\nimport { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';\nimport { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\nconst cachePath = join(projectGraphCacheDirectory, 'vite.hash');\nconst targetsCache = existsSync(cachePath) ? readTargetsCache() : {};\n\nconst calculatedTargets: Record<\n string,\n Record<string, TargetConfiguration>\n> = {};\n\nfunction readTargetsCache(): Record<\n string,\n Record<string, TargetConfiguration>\n> {\n return readJsonFile(cachePath);\n}\n\nfunction writeTargetsToCache(\n targets: Record<string, Record<string, TargetConfiguration>>\n) {\n writeJsonFile(cachePath, targets);\n}\n\nexport const createDependencies: CreateDependencies = () => {\n writeTargetsToCache(calculatedTargets);\n return [];\n};\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}',\n async (configFilePath, options, context) => {\n const projectRoot = dirname(configFilePath);\n // Do not create a project if package.json and project.json isn't there.\n const siblingFiles = readdirSync(join(context.workspaceRoot, projectRoot));\n if (\n !siblingFiles.includes('package.json') &&\n !siblingFiles.includes('project.json')\n ) {\n return {};\n }\n\n options = normalizeOptions(options);\n\n const hash = calculateHashForCreateNodes(projectRoot, options, context, [\n getLockFileName(detectPackageManager(context.workspaceRoot)),\n ]);\n const targets = targetsCache[hash]\n ? targetsCache[hash]\n : await buildViteTargets(configFilePath, projectRoot, options, context);\n\n calculatedTargets[hash] = targets;\n\n return {\n projects: {\n [projectRoot]: {\n root: projectRoot,\n targets,\n },\n },\n };\n },\n];\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n) {\n const { loadConfigFromFile } = await loadViteDynamicImport();\n const viteConfig = await loadConfigFromFile(\n {\n command: 'build',\n mode: 'production',\n },\n configFilePath\n );\n\n const { buildOutputs, testOutputs } = getOutputs(\n viteConfig?.config,\n projectRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n if (!configFilePath.includes('vitest.config')) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n targets[options.serveTargetName] = serveTarget(projectRoot);\n\n targets[options.previewTargetName] = previewTarget(projectRoot);\n\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\n\n targets[options.testTargetName] = await testTarget(\n namedInputs,\n testOutputs,\n projectRoot\n );\n\n return targets;\n}\n\nasync function buildTarget(\n buildTargetName: string,\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vite build`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n dependsOn: [`^${buildTargetName}`],\n inputs: [\n ...('production' in namedInputs\n ? ['production', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vite'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nfunction previewTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite preview`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nasync function testTarget(\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vitest run`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n inputs: [\n ...('production' in namedInputs\n ? ['default', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vitest'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n 'dist'\n );\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n path: 'coverage' | 'dist'\n): string | undefined {\n if (!outputPath) {\n if (projectRoot === '.') {\n return `{projectRoot}/${path}`;\n } else {\n return `{workspaceRoot}/${path}/{projectRoot}`;\n }\n } else {\n if (isAbsolute(outputPath)) {\n return `{workspaceRoot}/${relative(workspaceRoot, outputPath)}`;\n } else {\n if (outputPath.startsWith('..')) {\n return join('{workspaceRoot}', join(projectRoot, outputPath));\n } else {\n return join('{projectRoot}', outputPath);\n }\n }\n }\n}\n\nfunction normalizeOptions(options: VitePluginOptions): VitePluginOptions {\n options ??= {};\n options.buildTargetName ??= 'build';\n options.serveTargetName ??= 'serve';\n options.previewTargetName ??= 'preview';\n options.testTargetName ??= 'test';\n options.serveStaticTargetName ??= 'serve-static';\n return options;\n}\n"],"names":["createDependencies","createNodes","cachePath","join","projectGraphCacheDirectory","targetsCache","existsSync","readTargetsCache","calculatedTargets","readJsonFile","writeTargetsToCache","targets","writeJsonFile","configFilePath","options","context","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizeOptions","hash","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","projects","root","loadConfigFromFile","loadViteDynamicImport","viteConfig","command","mode","buildOutputs","testOutputs","getOutputs","config","namedInputs","getNamedInputs","buildTargetName","buildTarget","serveTargetName","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","cwd","joinPathFragments","cache","dependsOn","inputs","externalDependencies","targetConfig","executor","test","build","buildOutputPath","normalizeOutputPath","outDir","reportsDirectoryPath","coverage","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"mappings":";;;;;;;;IAgDaA,kBAAkB;eAAlBA;;IAKAC,WAAW;eAAXA;;;wBA3CN;sBAC6C;gCACrB;oBACS;6CACI;gCACD;oBACX;+BACM;AAUtC,MAAMC,YAAYC,IAAAA,UAAI,EAACC,0CAA0B,EAAE;AACnD,MAAMC,eAAeC,IAAAA,cAAU,EAACJ,aAAaK,qBAAqB,CAAC;AAEnE,MAAMC,oBAGF,CAAC;AAEL,SAASD;IAIP,OAAOE,IAAAA,oBAAY,EAACP;AACtB;AAEA,SAASQ,oBACPC,OAA4D;IAE5DC,IAAAA,qBAAa,EAACV,WAAWS;AAC3B;AAEO,MAAMX,qBAAyC;IACpDU,oBAAoBF;IACpB,OAAO,EAAE;AACX;AAEO,MAAMP,cAA8C;IACzD;IACA,OAAOY,gBAAgBC,SAASC;QAC9B,MAAMC,cAAcC,IAAAA,aAAO,EAACJ;QAC5B,wEAAwE;QACxE,MAAMK,eAAeC,IAAAA,eAAW,EAAChB,IAAAA,UAAI,EAACY,QAAQK,aAAa,EAAEJ;QAC7D,IACE,CAACE,aAAaG,QAAQ,CAAC,mBACvB,CAACH,aAAaG,QAAQ,CAAC,iBACvB;YACA,OAAO,CAAC;QACV;QAEAP,UAAUQ,iBAAiBR;QAE3B,MAAMS,OAAOC,IAAAA,wDAA2B,EAACR,aAAaF,SAASC,SAAS;YACtEU,IAAAA,mBAAe,EAACC,IAAAA,4BAAoB,EAACX,QAAQK,aAAa;SAC3D;QACD,MAAMT,UAAUN,YAAY,CAACkB,KAAK,GAC9BlB,YA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gB,EAChCnD,aACA;IAGF,OAAO;QACLmB,cAAc;YAAC2B;SAAgB;QAC/B1B,aAAa;YAAC6B;SAAqB;IACrC;AACF;AAEA,SAASF,oBACPK,UAA8B,EAC9BpD,WAAmB,EACnBqD,IAAyB;IAEzB,IAAI,CAACD,YAAY;QACf,IAAIpD,gBAAgB,KAAK;YACvB,OAAO,CAAC,cAAc,EAAEqD,KAAK,CAAC;QAChC,OAAO;YACL,OAAO,CAAC,gBAAgB,EAAEA,KAAK,cAAc,CAAC;QAChD;IACF,OAAO;QACL,IAAIC,IAAAA,gBAAU,EAACF,aAAa;YAC1B,OAAO,CAAC,gBAAgB,EAAEG,IAAAA,cAAQ,EAACnD,qBAAa,EAAEgD,YAAY,CAAC;QACjE,OAAO;YACL,IAAIA,WAAWI,UAAU,CAAC,OAAO;gBAC/B,OAAOrE,IAAAA,UAAI,EAAC,mBAAmBA,IAAAA,UAAI,EAACa,aAAaoD;YACnD,OAAO;gBACL,OAAOjE,IAAAA,UAAI,EAAC,iBAAiBiE;YAC/B;QACF;IACF;AACF;AAEA,SAAS9C,iBAAiBR,OAA0B;QAElDA,UACAA,WACAA,WACAA,WACAA;IALAA,kBAAAA,UAAAA,UAAY,CAAC;;IACbA,qBAAAA,WAAAA,SAAQ2B,8CAAR3B,SAAQ2B,kBAAoB;;IAC5B3B,qBAAAA,YAAAA,SAAQ6B,8CAAR7B,UAAQ6B,kBAAoB;;IAC5B7B,uBAAAA,YAAAA,SAAQ+B,kDAAR/B,UAAQ+B,oBAAsB;;IAC9B/B,oBAAAA,YAAAA,SAAQmC,4CAARnC,UAAQmC,iBAAmB;;IAC3BnC,2BAAAA,YAAAA,SAAQiC,0DAARjC,UAAQiC,wBAA0B;IAClC,OAAOjC;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n detectPackageManager,\n joinPathFragments,\n readJsonFile,\n TargetConfiguration,\n workspaceRoot,\n writeJsonFile,\n} from '@nx/devkit';\nimport { dirname, isAbsolute, join, relative } from 'path';\nimport { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';\nimport { existsSync, readdirSync } from 'fs';\nimport { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';\nimport { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\nconst cachePath = join(projectGraphCacheDirectory, 'vite.hash');\nconst targetsCache = existsSync(cachePath) ? readTargetsCache() : {};\n\nconst calculatedTargets: Record<\n string,\n Record<string, TargetConfiguration>\n> = {};\n\nfunction readTargetsCache(): Record<\n string,\n Record<string, TargetConfiguration>\n> {\n return readJsonFile(cachePath);\n}\n\nfunction writeTargetsToCache(\n targets: Record<string, Record<string, TargetConfiguration>>\n) {\n writeJsonFile(cachePath, targets);\n}\n\nexport const createDependencies: CreateDependencies = () => {\n writeTargetsToCache(calculatedTargets);\n return [];\n};\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}',\n async (configFilePath, options, context) => {\n const projectRoot = dirname(configFilePath);\n // Do not create a project if package.json and project.json isn't there.\n const siblingFiles = readdirSync(join(context.workspaceRoot, projectRoot));\n if (\n !siblingFiles.includes('package.json') &&\n !siblingFiles.includes('project.json')\n ) {\n return {};\n }\n\n options = normalizeOptions(options);\n\n const hash = calculateHashForCreateNodes(projectRoot, options, context, [\n getLockFileName(detectPackageManager(context.workspaceRoot)),\n ]);\n const targets = targetsCache[hash]\n ? targetsCache[hash]\n : await buildViteTargets(configFilePath, projectRoot, options, context);\n\n calculatedTargets[hash] = targets;\n\n return {\n projects: {\n [projectRoot]: {\n root: projectRoot,\n targets,\n },\n },\n };\n },\n];\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n) {\n const { loadConfigFromFile } = await loadViteDynamicImport();\n const viteConfig = await loadConfigFromFile(\n {\n command: 'build',\n mode: 'production',\n },\n configFilePath\n );\n\n const { buildOutputs, testOutputs, hasTest } = getOutputs(\n viteConfig?.config,\n projectRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n // If file is not vitest.config, create targets for build, serve, preview and serve-static\n if (!configFilePath.includes('vitest.config')) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n targets[options.serveTargetName] = serveTarget(projectRoot);\n\n targets[options.previewTargetName] = previewTarget(projectRoot);\n\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\n\n // if file is vitest.config or vite.config has definition for test, create target for test\n if (configFilePath.includes('vitest.config') || hasTest) {\n targets[options.testTargetName] = await testTarget(\n namedInputs,\n testOutputs,\n projectRoot\n );\n }\n\n return targets;\n}\n\nasync function buildTarget(\n buildTargetName: string,\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vite build`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n dependsOn: [`^${buildTargetName}`],\n inputs: [\n ...('production' in namedInputs\n ? ['production', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vite'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nfunction previewTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite preview`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nasync function testTarget(\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vitest run`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n inputs: [\n ...('production' in namedInputs\n ? ['default', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vitest'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n hasTest: boolean;\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n 'dist'\n );\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n hasTest: !!test,\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n path: 'coverage' | 'dist'\n): string | undefined {\n if (!outputPath) {\n if (projectRoot === '.') {\n return `{projectRoot}/${path}`;\n } else {\n return `{workspaceRoot}/${path}/{projectRoot}`;\n }\n } else {\n if (isAbsolute(outputPath)) {\n return `{workspaceRoot}/${relative(workspaceRoot, outputPath)}`;\n } else {\n if (outputPath.startsWith('..')) {\n return join('{workspaceRoot}', join(projectRoot, outputPath));\n } else {\n return join('{projectRoot}', outputPath);\n }\n }\n }\n}\n\nfunction normalizeOptions(options: VitePluginOptions): VitePluginOptions {\n options ??= {};\n options.buildTargetName ??= 'build';\n options.serveTargetName ??= 'serve';\n options.previewTargetName ??= 'preview';\n options.testTargetName ??= 'test';\n options.serveStaticTargetName ??= 'serve-static';\n return options;\n}\n"],"names":["createDependencies","createNodes","cachePath","join","projectGraphCacheDirectory","targetsCache","existsSync","readTargetsCache","calculatedTargets","readJsonFile","writeTargetsToCache","targets","writeJsonFile","configFilePath","options","context","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizeOptions","hash","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","projects","root","loadConfigFromFile","loadViteDynamicImport","viteConfig","command","mode","buildOutputs","testOutputs","hasTest","getOutputs","config","namedInputs","getNamedInputs","buildTargetName","buildTarget","serveTargetName","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","cwd","joinPathFragments","cache","dependsOn","inputs","externalDependencies","targetConfig","executor","test","build","buildOutputPath","normalizeOutputPath","outDir","reportsDirectoryPath","coverage","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"mappings":";;;;;;;;IAgDaA,kBAAkB;eAAlBA;;IAKAC,WAAW;eAAXA;;;wBA3CN;sBAC6C;gCACrB;oBACS;6CACI;gCACD;oBACX;+BACM;AAUtC,MAAMC,YAAYC,IAAAA,UAAI,EAACC,0CAA0B,EAAE;AACnD,MAAMC,eAAeC,IAAAA,cAAU,EAACJ,aAAaK,qBAAqB,CAAC;AAEnE,MAAMC,oBAGF,CAAC;AAEL,SAASD;IAIP,OAAOE,IAAAA,oBAAY,EAACP;AACtB;AAEA,SAASQ,oBACPC,OAA4D;IAE5DC,IAAAA,qBAAa,EAACV,WAAWS;AAC3B;AAEO,MAAMX,qBAAyC;IACpDU,oBAAoBF;IACpB,OAAO,EAAE;AACX;AAEO,MAAMP,cAA8C;IACzD;IACA,OAAOY,gBAAgBC,SAASC;QAC9B,MAAMC,cAAcC,IAAAA,aAAO,EAACJ;QAC5B,wEAAwE;QACxE,MAAMK,eAAeC,IAAAA,eAAW,EAAChB,IAAAA,UAAI,EAACY,QAAQK,aAAa,EAAEJ;QAC7D,IACE,CAACE,aAAaG,QAAQ,CAAC,mBACvB,CAACH,aAAaG,QAAQ,CAAC,iBACvB;YACA,OAAO,CAAC;QACV;QAEAP,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A,SAAQgC,kDAARhC,UAAQgC,oBAAsB;;IAC9BhC,oBAAAA,YAAAA,SAAQoC,4CAARpC,UAAQoC,iBAAmB;;IAC3BpC,2BAAAA,YAAAA,SAAQkC,0DAARlC,UAAQkC,wBAA0B;IAClC,OAAOlC;AACT"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
export type EnsureDependenciesOptions = {
|
|
3
|
+
uiFramework: 'react' | 'none';
|
|
4
|
+
compiler?: 'babel' | 'swc';
|
|
5
|
+
includeLib?: boolean;
|
|
6
|
+
testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
|
|
7
|
+
};
|
|
8
|
+
export declare function ensureDependencies(host: Tree, schema: EnsureDependenciesOptions): GeneratorCallback;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "ensureDependencies", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return ensureDependencies;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const _devkit = require("@nx/devkit");
|
|
9
|
+
const _versions = require("./versions");
|
|
10
|
+
function ensureDependencies(host, schema) {
|
|
11
|
+
const devDependencies = {};
|
|
12
|
+
if (schema.testEnvironment === 'jsdom') {
|
|
13
|
+
devDependencies['jsdom'] = _versions.jsdomVersion;
|
|
14
|
+
} else if (schema.testEnvironment === 'happy-dom') {
|
|
15
|
+
devDependencies['happy-dom'] = _versions.happyDomVersion;
|
|
16
|
+
} else if (schema.testEnvironment === 'edge-runtime') {
|
|
17
|
+
devDependencies['@edge-runtime/vm'] = _versions.edgeRuntimeVmVersion;
|
|
18
|
+
} else if (schema.testEnvironment !== 'node' && schema.testEnvironment) {
|
|
19
|
+
_devkit.logger.info(`A custom environment was provided: ${schema.testEnvironment}. You need to install it manually.`);
|
|
20
|
+
}
|
|
21
|
+
if (schema.uiFramework === 'react') {
|
|
22
|
+
if (schema.compiler === 'swc') {
|
|
23
|
+
devDependencies['@vitejs/plugin-react-swc'] = _versions.vitePluginReactSwcVersion;
|
|
24
|
+
} else {
|
|
25
|
+
devDependencies['@vitejs/plugin-react'] = _versions.vitePluginReactVersion;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (schema.includeLib) {
|
|
29
|
+
devDependencies['vite-plugin-dts'] = _versions.vitePluginDtsVersion;
|
|
30
|
+
}
|
|
31
|
+
return (0, _devkit.addDependenciesToPackageJson)(host, {}, devDependencies);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=ensure-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/ensure-dependencies.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n logger,\n type GeneratorCallback,\n type Tree,\n} from '@nx/devkit';\nimport {\n edgeRuntimeVmVersion,\n happyDomVersion,\n jsdomVersion,\n vitePluginDtsVersion,\n vitePluginReactSwcVersion,\n vitePluginReactVersion,\n} from './versions';\n\nexport type EnsureDependenciesOptions = {\n uiFramework: 'react' | 'none';\n compiler?: 'babel' | 'swc';\n includeLib?: boolean;\n testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;\n};\n\nexport function ensureDependencies(\n host: Tree,\n schema: EnsureDependenciesOptions\n): GeneratorCallback {\n const devDependencies: Record<string, string> = {};\n\n if (schema.testEnvironment === 'jsdom') {\n devDependencies['jsdom'] = jsdomVersion;\n } else if (schema.testEnvironment === 'happy-dom') {\n devDependencies['happy-dom'] = happyDomVersion;\n } else if (schema.testEnvironment === 'edge-runtime') {\n devDependencies['@edge-runtime/vm'] = edgeRuntimeVmVersion;\n } else if (schema.testEnvironment !== 'node' && schema.testEnvironment) {\n logger.info(\n `A custom environment was provided: ${schema.testEnvironment}. You need to install it manually.`\n );\n }\n\n if (schema.uiFramework === 'react') {\n if (schema.compiler === 'swc') {\n devDependencies['@vitejs/plugin-react-swc'] = vitePluginReactSwcVersion;\n } else {\n devDependencies['@vitejs/plugin-react'] = vitePluginReactVersion;\n }\n }\n\n if (schema.includeLib) {\n devDependencies['vite-plugin-dts'] = vitePluginDtsVersion;\n }\n\n return addDependenciesToPackageJson(host, {}, devDependencies);\n}\n"],"names":["ensureDependencies","host","schema","devDependencies","testEnvironment","jsdomVersion","happyDomVersion","edgeRuntimeVmVersion","logger","info","uiFramework","compiler","vitePluginReactSwcVersion","vitePluginReactVersion","includeLib","vitePluginDtsVersion","addDependenciesToPackageJson"],"mappings":";+BAsBgBA;;;eAAAA;;;wBAjBT;0BAQA;AASA,SAASA,mBACdC,IAAU,EACVC,MAAiC;IAEjC,MAAMC,kBAA0C,CAAC;IAEjD,IAAID,OAAOE,eAAe,KAAK,SAAS;QACtCD,eAAe,CAAC,QAAQ,GAAGE,sBAAY;IACzC,OAAO,IAAIH,OAAOE,eAAe,KAAK,aAAa;QACjDD,eAAe,CAAC,YAAY,GAAGG,yBAAe;IAChD,OAAO,IAAIJ,OAAOE,eAAe,KAAK,gBAAgB;QACpDD,eAAe,CAAC,mBAAmB,GAAGI,8BAAoB;IAC5D,OAAO,IAAIL,OAAOE,eAAe,KAAK,UAAUF,OAAOE,eAAe,EAAE;QACtEI,cAAM,CAACC,IAAI,CACT,CAAC,mCAAmC,EAAEP,OAAOE,eAAe,CAAC,kCAAkC,CAAC;IAEpG;IAEA,IAAIF,OAAOQ,WAAW,KAAK,SAAS;QAClC,IAAIR,OAAOS,QAAQ,KAAK,OAAO;YAC7BR,eAAe,CAAC,2BAA2B,GAAGS,mCAAyB;QACzE,OAAO;YACLT,eAAe,CAAC,uBAAuB,GAAGU,gCAAsB;QAClE;IACF;IAEA,IAAIX,OAAOY,UAAU,EAAE;QACrBX,eAAe,CAAC,kBAAkB,GAAGY,8BAAoB;IAC3D;IAEA,OAAOC,IAAAA,oCAA4B,EAACf,MAAM,CAAC,GAAGE;AAChD"}
|
|
@@ -187,12 +187,10 @@ function addOrChangeBuildTarget(tree, options, target) {
|
|
|
187
187
|
var _targets;
|
|
188
188
|
(_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
|
|
189
189
|
if (project.targets[target]) {
|
|
190
|
-
var _project_targets_target_options;
|
|
191
|
-
buildOptions.fileReplacements = (_project_targets_target_options = project.targets[target].options) == null ? void 0 : _project_targets_target_options.fileReplacements;
|
|
192
190
|
if (project.targets[target].executor === '@nxext/vite:build') {
|
|
193
|
-
var
|
|
194
|
-
buildOptions['base'] = (
|
|
195
|
-
buildOptions['sourcemap'] = (
|
|
191
|
+
var _project_targets_target_options, _project_targets_target_options1;
|
|
192
|
+
buildOptions['base'] = (_project_targets_target_options = project.targets[target].options) == null ? void 0 : _project_targets_target_options.baseHref;
|
|
193
|
+
buildOptions['sourcemap'] = (_project_targets_target_options1 = project.targets[target].options) == null ? void 0 : _project_targets_target_options1.sourcemaps;
|
|
196
194
|
}
|
|
197
195
|
project.targets[target].options = _extends._({}, buildOptions);
|
|
198
196
|
project.targets[target].executor = '@nx/vite:build';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const reportsDirectory = joinPathFragments(\n offsetFromRoot(project.root),\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n reportsDirectory,\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n project.targets[target].executor = '@nx/vite:test';\n delete project.targets[target].options?.jestConfig;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:test',\n outputs: ['{options.reportsDirectory}'],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions['base'] = project.targets[target].options?.baseHref;\n buildOptions['sourcemap'] = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions['https'] = target.options?.https;\n previewOptions['open'] = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type='module' src='${mainPath}'></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type='module' src='${mainPath}'></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang='en'>\n <head>\n <meta charset='UTF-8' />\n <link rel='icon' href='/favicon.ico' />\n <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n <title>Vite</title>\n </head>\n <body>\n <div id='root'></div>\n <script type='module' src='${mainPath}'></script>\n </body>\n </html>`\n );\n }\n}\n\nexport interface ViteConfigFileOptions {\n project: string;\n includeLib?: boolean;\n includeVitest?: boolean;\n inSourceTests?: boolean;\n testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;\n rollupOptionsExternal?: string[];\n imports?: string[];\n plugins?: string[];\n coverageProvider?: 'v8' | 'istanbul' | 'custom';\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigFileOptions,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags,\n vitestFileName?: boolean\n) {\n const { root: projectRoot } = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = vitestFileName\n ? `${projectRoot}/vitest.config.ts`\n : `${projectRoot}/vite.config.ts`;\n\n const buildOutDir =\n projectRoot === '.'\n ? `./dist/${options.project}`\n : `${offsetFromRoot(projectRoot)}dist/${projectRoot}`;\n\n const buildOption = onlyVitest\n ? ''\n : options.includeLib\n ? `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n outDir: '${buildOutDir}',\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: '${options.project}',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [${options.rollupOptionsExternal ?? ''}]\n },\n },`\n : `\n build: {\n outDir: '${buildOutDir}',\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n },\n `;\n\n const imports: string[] = options.imports ? options.imports : [];\n\n if (!onlyVitest && options.includeLib) {\n imports.push(\n `import dts from 'vite-plugin-dts'`,\n `import * as path from 'path'`\n );\n }\n\n let viteConfigContent = '';\n\n const plugins = options.plugins\n ? [...options.plugins, `nxViteTsPaths()`]\n : [`nxViteTsPaths()`];\n\n if (!onlyVitest && options.includeLib) {\n plugins.push(\n `dts({ entryRoot: 'src', tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true })`\n );\n }\n\n const reportsDirectory =\n projectRoot === '.'\n ? `./coverage/${options.project}`\n : `${offsetFromRoot(projectRoot)}coverage/${projectRoot}`;\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectRoot)}node_modules/.vitest'\n },\n environment: '${options.testEnvironment ?? 'jsdom'}',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n ${\n options.inSourceTests\n ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],`\n : ''\n }\n reporters: ['default'],\n coverage: {\n reportsDirectory: '${reportsDirectory}',\n provider: ${\n options.coverageProvider ? `'${options.coverageProvider}'` : `'v8'`\n },\n }\n },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const devServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n server:{\n port: 4200,\n host: 'localhost',\n },`;\n\n const previewServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n preview:{\n port: 4300,\n host: 'localhost',\n },`;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [ nxViteTsPaths() ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectRoot\n )}node_modules/.vite/${projectRoot}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n buildOutDir,\n imports,\n plugins,\n testOption,\n reportsDirectory,\n cacheDir,\n offsetFromRoot(projectRoot),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types='vitest' />\n import { defineConfig } from 'vite';\n ${imports.join(';\\n')}${imports.length ? ';' : ''}\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n \n export default defineConfig({\n root: __dirname,\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n \n plugins: [${plugins.join(',\\n')}],\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigFileOptions,\n buildOption: string,\n buildOutDir: string,\n imports: string[],\n plugins: string[],\n testOption: string,\n reportsDirectory: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (\n projectAlreadyHasViteTargets?.build &&\n projectAlreadyHasViteTargets?.test\n ) {\n return;\n }\n\n if (process.env.NX_VERBOSE_LOGGING === 'true') {\n logger.info(\n `vite.config.ts already exists for project ${options.project}.`\n );\n }\n\n const buildOptionObject = options.includeLib\n ? {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: options.rollupOptionsExternal ?? [],\n },\n outDir: buildOutDir,\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n }\n : {\n outDir: buildOutDir,\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: options.testEnvironment ?? 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n reporters: ['default'],\n coverage: {\n reportsDirectory: reportsDirectory,\n provider: `${options.coverageProvider ?? 'v8'}`,\n },\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n imports,\n plugins,\n testOption,\n testOptionObject,\n cacheDir,\n projectAlreadyHasViteTargets ?? {}\n );\n\n if (!changed) {\n logger.warn(\n `Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):\n \n ${buildOption}\n \n `\n );\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","reportsDirectory","joinPathFragments","offsetFromRoot","root","testOptions","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","baseHref","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","proxyConfig","hmr","previewOptions","https","open","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","vitestFileName","viteConfigPath","buildOutDir","buildOption","includeLib","rollupOptionsExternal","imports","push","viteConfigContent","plugins","testOption","includeVitest","testEnvironment","inSourceTests","coverageProvider","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_VERBOSE_LOGGING","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","outDir","reportCompressedSize","commonjsOptions","transformMixedEsModules","testOptionObject","globals","cache","dir","environment","reporters","coverage","provider","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAgCAC,sBAAsB;eAAtBA;;IA8CAC,sBAAsB;eAAtBA;;IAkDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA+EAC,sBAAsB;eAAtBA;;IAmLAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,sBAAsB;eAAtBA;;;;wBApvBf;qCAMmC;AAOnC,SAASZ,6BACda,OAEC,EACDC,mBAA4C;IAO5C,MAAMC,SAA0D;QAC9DC,sBAAsB,CAAC;QACvBC,oCAAoC;QACpCC,iCAAiC,CAAC;QAClCC,yBAAyB,CAAC;IAC5B;IAEA,MAAMC,qBAAqB;QACzBC,OAAO;YACL;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,OAAO;YACL;YACA;YACA;SACD;QACDC,MAAM;YAAC;YAAiB;YAAmB;SAAuB;IACpE;IAEA,MAAMC,uBAAuB;QAC3B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,oDAAoD;IACpD,0EAA0E;IAC1E,kFAAkF;IAElF,SAASC,wBAAwBC,MAAc;QAC7C,IAAIZ,uCAAAA,mBAAqB,CAACY,OAAO,EAAE;gBAG7Bb;YAFJ,IACEO,kBAAkB,CAACM,OAAO,CAACC,QAAQ,EACjCd,sCAAAA,OAAO,CAAC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EA,MAAMsI,UAAUC,IAAAA,8CAAyB,EACvCxI,MACAwE,gBACAE,aACA2C,mBACAxC,SACAG,SACAC,YACA8C,kBACArC,UACApB,uCAAAA,+BAAgC,CAAC;IAGnC,IAAI,CAACiE,SAAS;QACZjC,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAE/B,eAAe;;QAExF,EAAEE,YAAY;;QAEd,CAAC;IAEP;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const reportsDirectory = joinPathFragments(\n offsetFromRoot(project.root),\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n reportsDirectory,\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n project.targets[target].executor = '@nx/vite:test';\n delete project.targets[target].options?.jestConfig;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:test',\n outputs: ['{options.reportsDirectory}'],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions['base'] = project.targets[target].options?.baseHref;\n buildOptions['sourcemap'] = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions['https'] = target.options?.https;\n previewOptions['open'] = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type='module' src='${mainPath}'></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type='module' src='${mainPath}'></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang='en'>\n <head>\n <meta charset='UTF-8' />\n <link rel='icon' href='/favicon.ico' />\n <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n <title>Vite</title>\n </head>\n <body>\n <div id='root'></div>\n <script type='module' src='${mainPath}'></script>\n </body>\n </html>`\n );\n }\n}\n\nexport interface ViteConfigFileOptions {\n project: string;\n includeLib?: boolean;\n includeVitest?: boolean;\n inSourceTests?: boolean;\n testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;\n rollupOptionsExternal?: string[];\n imports?: string[];\n plugins?: string[];\n coverageProvider?: 'v8' | 'istanbul' | 'custom';\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigFileOptions,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags,\n vitestFileName?: boolean\n) {\n const { root: projectRoot } = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = vitestFileName\n ? `${projectRoot}/vitest.config.ts`\n : `${projectRoot}/vite.config.ts`;\n\n const buildOutDir =\n projectRoot === '.'\n ? `./dist/${options.project}`\n : `${offsetFromRoot(projectRoot)}dist/${projectRoot}`;\n\n const buildOption = onlyVitest\n ? ''\n : options.includeLib\n ? `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n outDir: '${buildOutDir}',\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: '${options.project}',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forget to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [${options.rollupOptionsExternal ?? ''}]\n },\n },`\n : `\n build: {\n outDir: '${buildOutDir}',\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n },\n `;\n\n const imports: string[] = options.imports ? options.imports : [];\n\n if (!onlyVitest && options.includeLib) {\n imports.push(\n `import dts from 'vite-plugin-dts'`,\n `import * as path from 'path'`\n );\n }\n\n let viteConfigContent = '';\n\n const plugins = options.plugins\n ? [...options.plugins, `nxViteTsPaths()`]\n : [`nxViteTsPaths()`];\n\n if (!onlyVitest && options.includeLib) {\n plugins.push(\n `dts({ entryRoot: 'src', tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), skipDiagnostics: true })`\n );\n }\n\n const reportsDirectory =\n projectRoot === '.'\n ? `./coverage/${options.project}`\n : `${offsetFromRoot(projectRoot)}coverage/${projectRoot}`;\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectRoot)}node_modules/.vitest'\n },\n environment: '${options.testEnvironment ?? 'jsdom'}',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n ${\n options.inSourceTests\n ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],`\n : ''\n }\n reporters: ['default'],\n coverage: {\n reportsDirectory: '${reportsDirectory}',\n provider: ${\n options.coverageProvider ? `'${options.coverageProvider}'` : `'v8'`\n },\n }\n },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const devServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n server:{\n port: 4200,\n host: 'localhost',\n },`;\n\n const previewServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n preview:{\n port: 4300,\n host: 'localhost',\n },`;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [ nxViteTsPaths() ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectRoot\n )}node_modules/.vite/${projectRoot}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n buildOutDir,\n imports,\n plugins,\n testOption,\n reportsDirectory,\n cacheDir,\n offsetFromRoot(projectRoot),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types='vitest' />\n import { defineConfig } from 'vite';\n ${imports.join(';\\n')}${imports.length ? ';' : ''}\n import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n \n export default defineConfig({\n root: __dirname,\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n \n plugins: [${plugins.join(',\\n')}],\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigFileOptions,\n buildOption: string,\n buildOutDir: string,\n imports: string[],\n plugins: string[],\n testOption: string,\n reportsDirectory: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (\n projectAlreadyHasViteTargets?.build &&\n projectAlreadyHasViteTargets?.test\n ) {\n return;\n }\n\n if (process.env.NX_VERBOSE_LOGGING === 'true') {\n logger.info(\n `vite.config.ts already exists for project ${options.project}.`\n );\n }\n\n const buildOptionObject = options.includeLib\n ? {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: options.rollupOptionsExternal ?? [],\n },\n outDir: buildOutDir,\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n }\n : {\n outDir: buildOutDir,\n reportCompressedSize: true,\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: options.testEnvironment ?? 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n reporters: ['default'],\n coverage: {\n reportsDirectory: reportsDirectory,\n provider: `${options.coverageProvider ?? 'v8'}`,\n },\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n imports,\n plugins,\n testOption,\n testOptionObject,\n cacheDir,\n projectAlreadyHasViteTargets ?? {}\n );\n\n if (!changed) {\n logger.warn(\n `Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):\n \n ${buildOption}\n \n `\n );\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","reportsDirectory","joinPathFragments","offsetFromRoot","root","testOptions","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","baseHref","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","proxyConfig","hmr","previewOptions","https","open","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","vitestFileName","viteConfigPath","buildOutDir","buildOption","includeLib","rollupOptionsExternal","imports","push","viteConfigContent","plugins","testOption","includeVitest","testEnvironment","inSourceTests","coverageProvider","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_VERBOSE_LOGGING","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","outDir","reportCompressedSize","commonjsOptions","transformMixedEsModules","testOptionObject","globals","cache","dir","environment","reporters","coverage","provider","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAgCAC,sBAAsB;eAAtBA;;IA2CAC,sBAAsB;eAAtBA;;IAkDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA+EAC,sBAAsB;eAAtBA;;IAmLAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBM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