@nx/vite 19.5.6 → 19.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +5 -0
- package/package.json +4 -4
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.d.ts +2 -0
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.js +25 -0
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.js.map +1 -0
- package/src/plugins/plugin.js +5 -2
- package/src/plugins/plugin.js.map +1 -1
- package/src/utils/generator-utils.js +5 -2
- package/src/utils/generator-utils.js.map +1 -1
package/migrations.json
CHANGED
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"version": "17.3.0-beta.0",
|
|
33
33
|
"description": "Move the vitest coverage thresholds in their own object if exists and add reporters.",
|
|
34
34
|
"implementation": "./src/migrations/update-17-3-0/vitest-coverage-and-reporters"
|
|
35
|
+
},
|
|
36
|
+
"update-19-6-0-add-depends-on-for-preview-server": {
|
|
37
|
+
"version": "19.6.0-beta.0",
|
|
38
|
+
"description": "Add dependsOn: [build] to preview targets using preview-server",
|
|
39
|
+
"implementation": "./src/migrations/update-19-6-0/add-depends-on-for-preview"
|
|
35
40
|
}
|
|
36
41
|
},
|
|
37
42
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.6.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nx/devkit": "19.
|
|
33
|
+
"@nx/devkit": "19.6.0-beta.0",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"@swc/helpers": "~0.5.0",
|
|
36
36
|
"enquirer": "~2.3.6",
|
|
37
|
-
"@nx/js": "19.
|
|
37
|
+
"@nx/js": "19.6.0-beta.0",
|
|
38
38
|
"tsconfig-paths": "^4.1.2",
|
|
39
|
-
"@nrwl/vite": "19.
|
|
39
|
+
"@nrwl/vite": "19.6.0-beta.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vite": "^5.0.0",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "default", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return _default;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const _devkit = require("@nx/devkit");
|
|
9
|
+
const _executoroptionsutils = require("@nx/devkit/src/generators/executor-options-utils");
|
|
10
|
+
async function _default(tree) {
|
|
11
|
+
(0, _executoroptionsutils.forEachExecutorOptions)(tree, '@nx/vite:preview-server', (_, projectName, targetName)=>{
|
|
12
|
+
var _project_targets_targetName;
|
|
13
|
+
const project = (0, _devkit.readProjectConfiguration)(tree, projectName);
|
|
14
|
+
var _dependsOn;
|
|
15
|
+
(_dependsOn = (_project_targets_targetName = project.targets[targetName]).dependsOn) != null ? _dependsOn : _project_targets_targetName.dependsOn = [];
|
|
16
|
+
if (project.targets[targetName].dependsOn.includes('build')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
project.targets[targetName].dependsOn.push('build');
|
|
20
|
+
(0, _devkit.updateProjectConfiguration)(tree, projectName, project);
|
|
21
|
+
});
|
|
22
|
+
await (0, _devkit.formatFiles)(tree);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=add-depends-on-for-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-19-6-0/add-depends-on-for-preview.ts"],"sourcesContent":["import {\n type Tree,\n formatFiles,\n readProjectConfiguration,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { VitePreviewServerExecutorOptions } from '../../executors/preview-server/schema';\n\nexport default async function (tree: Tree) {\n forEachExecutorOptions<VitePreviewServerExecutorOptions>(\n tree,\n '@nx/vite:preview-server',\n (_, projectName, targetName) => {\n const project = readProjectConfiguration(tree, projectName);\n project.targets[targetName].dependsOn ??= [];\n if (project.targets[targetName].dependsOn.includes('build')) {\n return;\n }\n project.targets[targetName].dependsOn.push('build');\n updateProjectConfiguration(tree, projectName, project);\n }\n );\n\n await formatFiles(tree);\n}\n"],"names":["tree","forEachExecutorOptions","_","projectName","targetName","project","readProjectConfiguration","targets","dependsOn","includes","push","updateProjectConfiguration","formatFiles"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":";+BASA;;;eAAA;;;wBAJO;sCACgC;AAGxB,eAAf,SAA+BA,IAAU;IACvCC,IAAAA,4CAAsB,EACpBD,MACA,2BACA,CAACE,GAAGC,aAAaC;YAEfC;QADA,MAAMA,UAAUC,IAAAA,gCAAwB,EAACN,MAAMG;;QAC/CE,eAAAA,8BAAAA,QAAQE,OAAO,CAACH,WAAW,EAACI,kCAA5BH,4BAA4BG,YAAc,EAAE;QAC5C,IAAIH,QAAQE,OAAO,CAACH,WAAW,CAACI,SAAS,CAACC,QAAQ,CAAC,UAAU;YAC3D;QACF;QACAJ,QAAQE,OAAO,CAACH,WAAW,CAACI,SAAS,CAACE,IAAI,CAAC;QAC3CC,IAAAA,kCAA0B,EAACX,MAAMG,aAAaE;IAChD;IAGF,MAAMO,IAAAA,mBAAW,EAACZ;AACpB"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -115,7 +115,7 @@ async function buildViteTargets(configFilePath, projectRoot, options, context) {
|
|
|
115
115
|
// If running in library mode, then there is nothing to serve.
|
|
116
116
|
if (!((_viteConfig_build = viteConfig.build) == null ? void 0 : _viteConfig_build.lib)) {
|
|
117
117
|
targets[options.serveTargetName] = serveTarget(projectRoot);
|
|
118
|
-
targets[options.previewTargetName] = previewTarget(projectRoot);
|
|
118
|
+
targets[options.previewTargetName] = previewTarget(projectRoot, options.buildTargetName);
|
|
119
119
|
targets[options.serveStaticTargetName] = serveStaticTarget(options);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -194,9 +194,12 @@ function serveTarget(projectRoot) {
|
|
|
194
194
|
};
|
|
195
195
|
return targetConfig;
|
|
196
196
|
}
|
|
197
|
-
function previewTarget(projectRoot) {
|
|
197
|
+
function previewTarget(projectRoot, buildTargetName) {
|
|
198
198
|
const targetConfig = {
|
|
199
199
|
command: `vite preview`,
|
|
200
|
+
dependsOn: [
|
|
201
|
+
buildTargetName
|
|
202
|
+
],
|
|
200
203
|
options: {
|
|
201
204
|
cwd: (0, _devkit.joinPathFragments)(projectRoot)
|
|
202
205
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n createNodesFromFiles,\n CreateNodesV2,\n detectPackageManager,\n getPackageManagerCommand,\n joinPathFragments,\n logger,\n ProjectConfiguration,\n readJsonFile,\n TargetConfiguration,\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 { workspaceDataDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\nimport { hashObject } from 'nx/src/hasher/file-hasher';\n\nconst pmc = getPackageManagerCommand();\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\ntype ViteTargets = Pick<ProjectConfiguration, 'targets' | 'metadata'>;\n\nfunction readTargetsCache(cachePath: string): Record<string, ViteTargets> {\n return existsSync(cachePath) ? readJsonFile(cachePath) : {};\n}\n\nfunction writeTargetsToCache(cachePath, results?: Record<string, ViteTargets>) {\n writeJsonFile(cachePath, results);\n}\n\n/**\n * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.\n */\nexport const createDependencies: CreateDependencies = () => {\n return [];\n};\n\nconst viteVitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';\n\nexport const createNodesV2: CreateNodesV2<VitePluginOptions> = [\n viteVitestConfigGlob,\n async (configFilePaths, options, context) => {\n const optionsHash = hashObject(options);\n const cachePath = join(workspaceDataDirectory, `vite-${optionsHash}.hash`);\n const targetsCache = readTargetsCache(cachePath);\n try {\n return await createNodesFromFiles(\n (configFile, options, context) =>\n createNodesInternal(configFile, options, context, targetsCache),\n configFilePaths,\n options,\n context\n );\n } finally {\n writeTargetsToCache(cachePath, targetsCache);\n }\n },\n];\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n viteVitestConfigGlob,\n async (configFilePath, options, context) => {\n logger.warn(\n '`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.'\n );\n return createNodesInternal(configFilePath, options, context, {});\n },\n];\n\nasync function createNodesInternal(\n configFilePath: string,\n options: VitePluginOptions,\n context: CreateNodesContext,\n targetsCache: Record<string, ViteTargets>\n) {\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 const normalizedOptions = normalizeOptions(options);\n\n // We do not want to alter how the hash is calculated, so appending the config file path to the hash\n // to prevent vite/vitest files overwriting the target cache created by the other\n const hash =\n (await calculateHashForCreateNodes(\n projectRoot,\n normalizedOptions,\n context,\n [getLockFileName(detectPackageManager(context.workspaceRoot))]\n )) + configFilePath;\n\n targetsCache[hash] ??= await buildViteTargets(\n configFilePath,\n projectRoot,\n normalizedOptions,\n context\n );\n\n const { targets, metadata } = targetsCache[hash];\n const project: ProjectConfiguration = {\n root: projectRoot,\n targets,\n metadata,\n };\n\n // If project is buildable, then the project type.\n // If it is not buildable, then leave it to other plugins/project.json to set the project type.\n if (project.targets[options.buildTargetName]) {\n project.projectType = project.targets[options.serveTargetName]\n ? 'application'\n : 'library';\n }\n\n return {\n projects: {\n [projectRoot]: project,\n },\n };\n}\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n): Promise<ViteTargets> {\n const absoluteConfigFilePath = joinPathFragments(\n context.workspaceRoot,\n configFilePath\n );\n // Workaround for the `build$3 is not a function` error that we sometimes see in agents.\n // This should be removed later once we address the issue properly\n try {\n const importEsbuild = () => new Function('return import(\"esbuild\")')();\n await importEsbuild();\n } catch {\n // do nothing\n }\n const { resolveConfig } = await loadViteDynamicImport();\n const viteConfig = await resolveConfig(\n {\n configFile: absoluteConfigFilePath,\n mode: 'development',\n },\n 'build'\n );\n\n const { buildOutputs, testOutputs, hasTest, isBuildable } = getOutputs(\n viteConfig,\n projectRoot,\n context.workspaceRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n // If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static\n const hasRemixPlugin =\n viteConfig.plugins && viteConfig.plugins.some((p) => p.name === 'remix');\n if (\n !configFilePath.includes('vitest.config') &&\n !hasRemixPlugin &&\n isBuildable\n ) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n // If running in library mode, then there is nothing to serve.\n if (!viteConfig.build?.lib) {\n targets[options.serveTargetName] = serveTarget(projectRoot);\n targets[options.previewTargetName] = previewTarget(projectRoot);\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\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 const metadata = {};\n return { targets, metadata };\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 metadata: {\n technologies: ['vite'],\n description: `Run Vite build`,\n help: {\n command: `${pmc.exec} vite build --help`,\n example: {\n options: {\n sourcemap: true,\n manifest: 'manifest.json',\n },\n },\n },\n },\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n metadata: {\n technologies: ['vite'],\n description: `Starts Vite dev server`,\n help: {\n command: `${pmc.exec} vite --help`,\n example: {\n options: {\n port: 3000,\n },\n },\n },\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 metadata: {\n technologies: ['vite'],\n description: `Locally preview Vite production build`,\n help: {\n command: `${pmc.exec} vite preview --help`,\n example: {\n options: {\n port: 3000,\n },\n },\n },\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`,\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 { env: 'CI' },\n ],\n outputs,\n metadata: {\n technologies: ['vite'],\n description: `Run Vite tests`,\n help: {\n command: `${pmc.exec} vitest --help`,\n example: {\n options: {\n bail: 1,\n coverage: true,\n },\n },\n },\n },\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n spa: true,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string,\n workspaceRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n hasTest: boolean;\n isBuildable: boolean;\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n workspaceRoot,\n 'dist'\n );\n\n const isBuildable =\n build?.lib ||\n build?.rollupOptions?.input ||\n existsSync(join(workspaceRoot, projectRoot, 'index.html'));\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n workspaceRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n hasTest: !!test,\n isBuildable,\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n workspaceRoot: 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","createNodesV2","pmc","getPackageManagerCommand","readTargetsCache","cachePath","existsSync","readJsonFile","writeTargetsToCache","results","writeJsonFile","viteVitestConfigGlob","configFilePaths","options","context","optionsHash","hashObject","join","workspaceDataDirectory","targetsCache","createNodesFromFiles","configFile","createNodesInternal","configFilePath","logger","warn","hash","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizedOptions","normalizeOptions","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","targets","metadata","project","root","buildTargetName","projectType","serveTargetName","projects","absoluteConfigFilePath","joinPathFragments","importEsbuild","Function","resolveConfig","loadViteDynamicImport","viteConfig","mode","buildOutputs","testOutputs","hasTest","isBuildable","getOutputs","namedInputs","getNamedInputs","hasRemixPlugin","plugins","some","p","name","buildTarget","build","lib","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","command","cwd","cache","dependsOn","inputs","externalDependencies","technologies","description","help","exec","example","sourcemap","manifest","targetConfig","port","env","bail","coverage","executor","spa","test","buildOutputPath","normalizeOutputPath","outDir","rollupOptions","input","reportsDirectoryPath","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAACyC;QACXxC;IACF;AACF;AAEA,SAAS0C,oBACPM,UAA8B,EAC9B/E,WAAmB,EACnBI,aAAqB,EACrB4E,IAAyB;IAEzB,IAAI,CAACD,YAAY;QACf,IAAI/E,gBAAgB,KAAK;YACvB,OAAO,CAAC,cAAc,EAAEgF,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,EAAC9E,eAAe2E,YAAY,CAAC;QACjE,OAAO;YACL,IAAIA,WAAWI,UAAU,CAAC,OAAO;gBAC/B,OAAO7F,IAAAA,UAAI,EAAC,mBAAmBA,IAAAA,UAAI,EAACU,aAAa+E;YACnD,OAAO;gBACL,OAAOzF,IAAAA,UAAI,EAAC,iBAAiByF;YAC/B;QACF;IACF;AACF;AAEA,SAASxE,iBAAiBrB,OAA0B;QAElDA,UACAA,WACAA,WACAA,WACAA;IALAA,kBAAAA,UAAAA,UAAY,CAAC;;IACbA,qBAAAA,WAAAA,SAAQ8B,8CAAR9B,SAAQ8B,kBAAoB;;IAC5B9B,qBAAAA,YAAAA,SAAQgC,8CAARhC,UAAQgC,kBAAoB;;IAC5BhC,uBAAAA,YAAAA,SAAQ0D,kDAAR1D,UAAQ0D,oBAAsB;;IAC9B1D,oBAAAA,YAAAA,SAAQ8D,4CAAR9D,UAAQ8D,iBAAmB;;IAC3B9D,2BAAAA,YAAAA,SAAQ4D,0DAAR5D,UAAQ4D,wBAA0B;IAClC,OAAO5D;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n createNodesFromFiles,\n CreateNodesV2,\n detectPackageManager,\n getPackageManagerCommand,\n joinPathFragments,\n logger,\n ProjectConfiguration,\n readJsonFile,\n TargetConfiguration,\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 { workspaceDataDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\nimport { hashObject } from 'nx/src/hasher/file-hasher';\n\nconst pmc = getPackageManagerCommand();\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\ntype ViteTargets = Pick<ProjectConfiguration, 'targets' | 'metadata'>;\n\nfunction readTargetsCache(cachePath: string): Record<string, ViteTargets> {\n return existsSync(cachePath) ? readJsonFile(cachePath) : {};\n}\n\nfunction writeTargetsToCache(cachePath, results?: Record<string, ViteTargets>) {\n writeJsonFile(cachePath, results);\n}\n\n/**\n * @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.\n */\nexport const createDependencies: CreateDependencies = () => {\n return [];\n};\n\nconst viteVitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';\n\nexport const createNodesV2: CreateNodesV2<VitePluginOptions> = [\n viteVitestConfigGlob,\n async (configFilePaths, options, context) => {\n const optionsHash = hashObject(options);\n const cachePath = join(workspaceDataDirectory, `vite-${optionsHash}.hash`);\n const targetsCache = readTargetsCache(cachePath);\n try {\n return await createNodesFromFiles(\n (configFile, options, context) =>\n createNodesInternal(configFile, options, context, targetsCache),\n configFilePaths,\n options,\n context\n );\n } finally {\n writeTargetsToCache(cachePath, targetsCache);\n }\n },\n];\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n viteVitestConfigGlob,\n async (configFilePath, options, context) => {\n logger.warn(\n '`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.'\n );\n return createNodesInternal(configFilePath, options, context, {});\n },\n];\n\nasync function createNodesInternal(\n configFilePath: string,\n options: VitePluginOptions,\n context: CreateNodesContext,\n targetsCache: Record<string, ViteTargets>\n) {\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 const normalizedOptions = normalizeOptions(options);\n\n // We do not want to alter how the hash is calculated, so appending the config file path to the hash\n // to prevent vite/vitest files overwriting the target cache created by the other\n const hash =\n (await calculateHashForCreateNodes(\n projectRoot,\n normalizedOptions,\n context,\n [getLockFileName(detectPackageManager(context.workspaceRoot))]\n )) + configFilePath;\n\n targetsCache[hash] ??= await buildViteTargets(\n configFilePath,\n projectRoot,\n normalizedOptions,\n context\n );\n\n const { targets, metadata } = targetsCache[hash];\n const project: ProjectConfiguration = {\n root: projectRoot,\n targets,\n metadata,\n };\n\n // If project is buildable, then the project type.\n // If it is not buildable, then leave it to other plugins/project.json to set the project type.\n if (project.targets[options.buildTargetName]) {\n project.projectType = project.targets[options.serveTargetName]\n ? 'application'\n : 'library';\n }\n\n return {\n projects: {\n [projectRoot]: project,\n },\n };\n}\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n): Promise<ViteTargets> {\n const absoluteConfigFilePath = joinPathFragments(\n context.workspaceRoot,\n configFilePath\n );\n // Workaround for the `build$3 is not a function` error that we sometimes see in agents.\n // This should be removed later once we address the issue properly\n try {\n const importEsbuild = () => new Function('return import(\"esbuild\")')();\n await importEsbuild();\n } catch {\n // do nothing\n }\n const { resolveConfig } = await loadViteDynamicImport();\n const viteConfig = await resolveConfig(\n {\n configFile: absoluteConfigFilePath,\n mode: 'development',\n },\n 'build'\n );\n\n const { buildOutputs, testOutputs, hasTest, isBuildable } = getOutputs(\n viteConfig,\n projectRoot,\n context.workspaceRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n // If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static\n const hasRemixPlugin =\n viteConfig.plugins && viteConfig.plugins.some((p) => p.name === 'remix');\n if (\n !configFilePath.includes('vitest.config') &&\n !hasRemixPlugin &&\n isBuildable\n ) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n // If running in library mode, then there is nothing to serve.\n if (!viteConfig.build?.lib) {\n targets[options.serveTargetName] = serveTarget(projectRoot);\n targets[options.previewTargetName] = previewTarget(\n projectRoot,\n options.buildTargetName\n );\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\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 const metadata = {};\n return { targets, metadata };\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 metadata: {\n technologies: ['vite'],\n description: `Run Vite build`,\n help: {\n command: `${pmc.exec} vite build --help`,\n example: {\n options: {\n sourcemap: true,\n manifest: 'manifest.json',\n },\n },\n },\n },\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n metadata: {\n technologies: ['vite'],\n description: `Starts Vite dev server`,\n help: {\n command: `${pmc.exec} vite --help`,\n example: {\n options: {\n port: 3000,\n },\n },\n },\n },\n };\n\n return targetConfig;\n}\n\nfunction previewTarget(projectRoot: string, buildTargetName) {\n const targetConfig: TargetConfiguration = {\n command: `vite preview`,\n dependsOn: [buildTargetName],\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n metadata: {\n technologies: ['vite'],\n description: `Locally preview Vite production build`,\n help: {\n command: `${pmc.exec} vite preview --help`,\n example: {\n options: {\n port: 3000,\n },\n },\n },\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`,\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 { env: 'CI' },\n ],\n outputs,\n metadata: {\n technologies: ['vite'],\n description: `Run Vite tests`,\n help: {\n command: `${pmc.exec} vitest --help`,\n example: {\n options: {\n bail: 1,\n coverage: true,\n },\n },\n },\n },\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n spa: true,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string,\n workspaceRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n hasTest: boolean;\n isBuildable: boolean;\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n workspaceRoot,\n 'dist'\n );\n\n const isBuildable =\n build?.lib ||\n build?.rollupOptions?.input ||\n existsSync(join(workspaceRoot, projectRoot, 'index.html'));\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n workspaceRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n hasTest: !!test,\n isBuildable,\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n workspaceRoot: 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","createNodesV2","pmc","getPackageManagerCommand","readTargetsCache","cachePath","existsSync","readJsonFile","writeTargetsToCache","results","writeJsonFile","viteVitestConfigGlob","configFilePaths","options","context","optionsHash","hashObject","join","workspaceDataDirectory","targetsCache","createNodesFromFiles","configFile","createNodesInternal","configFilePath","logger","warn","hash","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizedOptions","normalizeOptions","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","targets","metadata","project","root","buildTargetName","projectType","serveTargetName","projects","absoluteConfigFilePath","joinPathFragments","importEsbuild","Function","resolveConfig","loadViteDynamicImport","viteConfig","mode","buildOutputs","testOutputs","hasTest","isBuildable","getOutputs","namedInputs","getNamedInputs","hasRemixPlugin","plugins","some","p","name","buildTarget","build","lib","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","command","cwd","cache","dependsOn","inputs","externalDependencies","technologies","description","help","exec","example","sourcemap","manifest","targetConfig","port","env","bail","coverage","executor","spa","test","buildOutputPath","normalizeOutputPath","outDir","rollupOptions","input","reportsDirectoryPath","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IA+CaA,kBAAkB;eAAlBA;;IA0BAC,WAAW;eAAXA;;IApBAC,aAAa;eAAbA;;;wBAvCN;sBAC6C;gCACrB;oBACS;6CACI;gCACL;oBACP;+BACM;4BACX;AAE3B,MAAMC,MAAMC,IAAAA,gCAAwB;AAYpC,SAASC,iBAAiBC,SAAiB;IACzC,OAAOC,IAAAA,cAAU,EAACD,aAAaE,IAAAA,oBAAY,EAACF,aAAa,CAAC;AAC5D;AAEA,SAASG,oBAAoBH,SAAS,EAAEI,OAAqC;IAC3EC,IAAAA,qBAAa,EAACL,WAAWI;AAC3B;AAKO,MAAMV,qBAAyC;IACpD,OAAO,EAAE;AACX;AAEA,MAAMY,uBAAuB;AAEtB,MAAMV,gBAAkD;IAC7DU;IACA,OAAOC,iBAAiBC,SAASC;QAC/B,MAAMC,cAAcC,IAAAA,sBAAU,EAACH;QAC/B,MAAMR,YAAYY,IAAAA,UAAI,EAACC,sCAAsB,EAAE,CAAC,KAAK,EAAEH,YAAY,KAAK,CAAC;QACzE,MAAMI,eAAef,iBAAiBC;QACtC,IAAI;YACF,OAAO,MAAMe,IAAAA,4BAAoB,EAC/B,CAACC,YAAYR,SA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AAA,UAAY,CAAC;;IACbA,qBAAAA,WAAAA,SAAQ8B,8CAAR9B,SAAQ8B,kBAAoB;;IAC5B9B,qBAAAA,YAAAA,SAAQgC,8CAARhC,UAAQgC,kBAAoB;;IAC5BhC,uBAAAA,YAAAA,SAAQ0D,kDAAR1D,UAAQ0D,oBAAsB;;IAC9B1D,oBAAAA,YAAAA,SAAQ8D,4CAAR9D,UAAQ8D,iBAAmB;;IAC3B9D,2BAAAA,YAAAA,SAAQ4D,0DAAR5D,UAAQ4D,wBAA0B;IAClC,OAAO5D;AACT"}
|
|
@@ -48,7 +48,7 @@ _export(exports, {
|
|
|
48
48
|
});
|
|
49
49
|
const _devkit = require("@nx/devkit");
|
|
50
50
|
const _viteconfigeditutils = require("./vite-config-edit-utils");
|
|
51
|
-
const
|
|
51
|
+
const _targetdefaultsutils = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
52
52
|
function findExistingJsBuildTargetInProject(targets) {
|
|
53
53
|
const output = {};
|
|
54
54
|
const supportedExecutors = {
|
|
@@ -125,7 +125,7 @@ function addOrChangeTestTarget(tree, options, target) {
|
|
|
125
125
|
}
|
|
126
126
|
function addBuildTarget(tree, options, target) {
|
|
127
127
|
var _project;
|
|
128
|
-
(0,
|
|
128
|
+
(0, _targetdefaultsutils.addBuildTargetDefaults)(tree, '@nx/vite:build');
|
|
129
129
|
const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
|
|
130
130
|
const buildOptions = {
|
|
131
131
|
outputPath: (0, _devkit.joinPathFragments)('dist', project.root != '.' ? project.root : options.project)
|
|
@@ -194,6 +194,9 @@ function addPreviewTarget(tree, options, serveTarget) {
|
|
|
194
194
|
}
|
|
195
195
|
// Adds a preview target.
|
|
196
196
|
project.targets.preview = {
|
|
197
|
+
dependsOn: [
|
|
198
|
+
'build'
|
|
199
|
+
],
|
|
197
200
|
executor: '@nx/vite:preview-server',
|
|
198
201
|
defaultConfiguration: 'development',
|
|
199
202
|
options: previewOptions,
|
|
@@ -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 { 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';\nimport { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';\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 findExistingJsBuildTargetInProject(targets: {\n [targetName: string]: TargetConfiguration;\n}): {\n supported?: string;\n unsupported?: string;\n} {\n const output: {\n supported?: string;\n unsupported?: string;\n } = {};\n\n const supportedExecutors = {\n build: ['@nx/js:babel', '@nx/js:swc', '@nx/rollup:rollup'],\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/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/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:browser-esbuild',\n '@angular-devkit/build-angular:application',\n ];\n\n // We try to find the target that is using the supported executors\n // for build since this is the one we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n if (supportedExecutors.build.includes(executorName)) {\n output.supported = target;\n } else if (unsupportedExecutors.includes(executorName)) {\n output.unsupported = target;\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 addBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n addBuildTargetDefaults(tree, '@nx/vite:build');\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n project.targets ??= {};\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 updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\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 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 */\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 switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n jsx: 'react-jsx',\n allowJs: false,\n esModuleInterop: false,\n allowSyntheticDefaultImports: true,\n strict: true,\n };\n break;\n case 'none':\n config.compilerOptions = {\n module: 'commonjs',\n forceConsistentCasingInFileNames: true,\n strict: true,\n noImplicitOverride: true,\n noPropertyAccessFromIndexSignature: true,\n noImplicitReturns: true,\n noFallthroughCasesInSwitch: true,\n };\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) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath = `${projectConfig.root}/src/index.html`;\n let mainPath = `${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 emptyOutDir: true,\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 emptyOutDir: true,\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', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json') })`\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 watch: false,\n globals: true,\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: '${normalizedJoinPaths(\n offsetFromRoot(projectRoot),\n 'node_modules',\n '.vite',\n projectRoot === '.' ? options.project : projectRoot\n )}',`;\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 projectRoot,\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 handleUnknownConfiguration(projectName: string) {\n if (process.env.NX_INTERACTIVE === 'false') {\n return;\n }\n\n logger.warn(\n `\n We could not find any configuration in project ${projectName} that \n indicates whether we can definitely convert to Vite.\n \n If you still want to convert your project to use Vite,\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 Vite?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that your project can be converted to use Vite.\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 projectRoot: 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 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\nfunction normalizedJoinPaths(...paths: string[]): string {\n const path = joinPathFragments(...paths);\n\n return path.startsWith('.') ? path : `./${path}`;\n}\n"],"names":["addBuildTarget","addOrChangeTestTarget","addPreviewTarget","addServeTarget","createOrEditViteConfig","deleteWebpackConfig","editTsConfig","findExistingJsBuildTargetInProject","getViteConfigPathForProject","handleUnknownConfiguration","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","normalizeViteConfigFilePathWithTree","targets","output","supportedExecutors","build","unsupportedExecutors","target","executorName","executor","includes","supported","unsupported","tree","options","project","readProjectConfiguration","reportsDirectory","joinPathFragments","offsetFromRoot","root","testOptions","jestConfig","outputs","updateProjectConfiguration","addBuildTargetDefaults","buildOptions","outputPath","defaultConfiguration","configurations","development","mode","production","buildTarget","hmr","serveTarget","previewOptions","proxyConfig","https","open","preview","projectConfig","config","readJson","uiFramework","compilerOptions","jsx","allowJs","esModuleInterop","allowSyntheticDefaultImports","strict","module","forceConsistentCasingInFileNames","noImplicitOverride","noPropertyAccessFromIndexSignature","noImplicitReturns","noFallthroughCasesInSwitch","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","mainPath","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","normalizedJoinPaths","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetIsUnsupported","userProvidedTargetName","validFoundTargetName","handleUnsupportedUserProvidedTargetsErrors","serve","test","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_INTERACTIVE","NX_VERBOSE_LOGGING","info","buildOptionObject","lib","entry","fileName","formats","rollupOptions","external","outDir","reportCompressedSize","commonjsOptions","transformMixedEsModules","testOptionObject","globals","environment","include","reporters","coverage","provider","changed","ensureViteConfigIsCorrect","paths","path","startsWith"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAMlG,QAAQC,OAAO;YACrB+G,UAAU;YACVC,SAAS;gBAAC;gBAAM;aAAM;QACxB;QACAC,eAAe;YACbC,UAAUnH,CAAAA,iCAAAA,QAAQ8D,qBAAqB,YAA7B9D,iCAAiC,EAAE;QAC/C;QACAoH,QAAQzD;QACR0D,sBAAsB;QACtBC,iBAAiB;YACfC,yBAAyB;QAC3B;IACF,IACA;QACEH,QAAQzD;QACR0D,sBAAsB;QACtBC,iBAAiB;YACfC,yBAAyB;QAC3B;IACF;QAIWvH,0BAKEA;IAPjB,MAAMwH,mBAAmB;QACvBC,SAAS;QACTC,aAAa1H,CAAAA,2BAAAA,QAAQqE,eAAe,YAAvBrE,2BAA2B;QACxC2H,SAAS;YAAC;SAAuD;QACjEC,WAAW;YAAC;SAAU;QACtBC,UAAU;YACR1H,kBAAkBA;YAClB2H,UAAU,CAAC,EAAE9H,CAAAA,4BAAAA,QAAQuE,gBAAgB,YAAxBvE,4BAA4B,KAAK,CAAC;QACjD;IACF;IAEA,MAAM+H,UAAUC,IAAAA,8CAAyB,EACvCjI,MACA2D,gBACAE,aACAiD,mBACA9C,SACAG,SACAC,YACAqD,kBACA5C,UACApB,uCAAAA,+BAAgC,CAAC;IAGnC,IAAI,CAACuE,SAAS;QACZlC,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAEpC,eAAe;;QAExF,EAAEE,YAAY;;QAEd,CAAC;IAEP;AACF;AAEA,SAASiB,oBAAoB,GAAGoD,KAAe;IAC7C,MAAMC,OAAO9H,IAAAA,yBAAiB,KAAI6H;IAElC,OAAOC,KAAKC,UAAU,CAAC,OAAOD,OAAO,CAAC,EAAE,EAAEA,KAAK,CAAC;AAClD"}
|
|
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 { 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';\nimport { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-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 findExistingJsBuildTargetInProject(targets: {\n [targetName: string]: TargetConfiguration;\n}): {\n supported?: string;\n unsupported?: string;\n} {\n const output: {\n supported?: string;\n unsupported?: string;\n } = {};\n\n const supportedExecutors = {\n build: ['@nx/js:babel', '@nx/js:swc', '@nx/rollup:rollup'],\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/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/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:browser-esbuild',\n '@angular-devkit/build-angular:application',\n ];\n\n // We try to find the target that is using the supported executors\n // for build since this is the one we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n if (supportedExecutors.build.includes(executorName)) {\n output.supported = target;\n } else if (unsupportedExecutors.includes(executorName)) {\n output.unsupported = target;\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 addBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n addBuildTargetDefaults(tree, '@nx/vite:build');\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n project.targets ??= {};\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 updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\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 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 */\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 dependsOn: ['build'],\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 switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n jsx: 'react-jsx',\n allowJs: false,\n esModuleInterop: false,\n allowSyntheticDefaultImports: true,\n strict: true,\n };\n break;\n case 'none':\n config.compilerOptions = {\n module: 'commonjs',\n forceConsistentCasingInFileNames: true,\n strict: true,\n noImplicitOverride: true,\n noPropertyAccessFromIndexSignature: true,\n noImplicitReturns: true,\n noFallthroughCasesInSwitch: true,\n };\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) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath = `${projectConfig.root}/src/index.html`;\n let mainPath = `${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 emptyOutDir: true,\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 emptyOutDir: true,\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', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json') })`\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 watch: false,\n globals: true,\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: '${normalizedJoinPaths(\n offsetFromRoot(projectRoot),\n 'node_modules',\n '.vite',\n projectRoot === '.' ? options.project : projectRoot\n )}',`;\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 projectRoot,\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 handleUnknownConfiguration(projectName: string) {\n if (process.env.NX_INTERACTIVE === 'false') {\n return;\n }\n\n logger.warn(\n `\n We could not find any configuration in project ${projectName} that \n indicates whether we can definitely convert to Vite.\n \n If you still want to convert your project to use Vite,\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 Vite?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that your project can be converted to use Vite.\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 projectRoot: 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 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\nfunction normalizedJoinPaths(...paths: string[]): string {\n const path = joinPathFragments(...paths);\n\n return path.startsWith('.') ? path : `./${path}`;\n}\n"],"names":["addBuildTarget","addOrChangeTestTarget","addPreviewTarget","addServeTarget","createOrEditViteConfig","deleteWebpackConfig","editTsConfig","findExistingJsBuildTargetInProject","getViteConfigPathForProject","handleUnknownConfiguration","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","normalizeViteConfigFilePathWithTree","targets","output","supportedExecutors","build","unsupportedExecutors","target","executorName","executor","includes","supported","unsupported","tree","options","project","readProjectConfiguration","reportsDirectory","joinPathFragments","offsetFromRoot","root","testOptions","jestConfig","outputs","updateProjectConfiguration","addBuildTargetDefaults","buildOptions","outputPath","defaultConfiguration","configurations","development","mode","production","buildTarget","hmr","serveTarget","previewOptions","proxyConfig","https","open","preview","dependsOn","projectConfig","config","readJson","uiFramework","compilerOptions","jsx","allowJs","esModuleInterop","allowSyntheticDefaultImports","strict","module","forceConsistentCasingInFileNames","noImplicitOverride","noPropertyAccessFromIndexSignature","noImplicitReturns","noFallthroughCasesInSwitch","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","mainPath","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","normalizedJoinPaths","handleViteConfigFileExists","join","length","configFile","undefined","projectName","Object","values","find","userProvidedTargetIsUnsupported","userProvidedTargetName","validFoundTargetName","handleUnsupportedUserProvidedTargetsErrors","serve","test","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","process","env","NX_INTERACTIVE","NX_VERBOSE_LOGGING","info","buildOptionObject","lib","entry","fileName","formats","rollupOptions","external","outDir","reportCompressedSize","commonjsOptions","transformMixedEsModules","testOptionObject","globals","environment","include","reporters","coverage","provider","changed","ensureViteConfigIsCorrect","paths","path","startsWith"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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