@nx/vite 19.0.3 → 19.0.5
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/src/generators/init/init.js +1 -1
- package/src/generators/init/init.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.d.ts +1 -0
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.js +73 -0
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.js.map +1 -0
- package/src/migrations/update-17-2-0/update-vite-config.js +8 -5
- package/src/migrations/update-17-2-0/update-vite-config.js.map +1 -1
- package/src/utils/generator-utils.js +2 -0
- 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": "19.0.
|
|
3
|
+
"version": "19.0.5",
|
|
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": "19.0.
|
|
32
|
+
"@nx/devkit": "19.0.5",
|
|
33
33
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
34
34
|
"@swc/helpers": "~0.5.0",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "19.0.
|
|
36
|
+
"@nx/js": "19.0.5",
|
|
37
37
|
"tsconfig-paths": "^4.1.2",
|
|
38
|
-
"@nrwl/vite": "19.0.
|
|
38
|
+
"@nrwl/vite": "19.0.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"vite": "^5.0.0",
|
|
@@ -61,7 +61,7 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
61
61
|
var _addPlugin;
|
|
62
62
|
(_addPlugin = (_schema = schema).addPlugin) != null ? _addPlugin : _schema.addPlugin = addPluginDefault;
|
|
63
63
|
if (schema.addPlugin) {
|
|
64
|
-
await (0, _addplugin.addPlugin)(tree, '@nx/vite/plugin', _plugin.createNodes, {
|
|
64
|
+
await (0, _addplugin.addPlugin)(tree, await (0, _devkit.createProjectGraphAsync)(), '@nx/vite/plugin', _plugin.createNodes, {
|
|
65
65
|
buildTargetName: [
|
|
66
66
|
'build',
|
|
67
67
|
'vite:build',
|
|
@@ -1 +1 @@
|
|
|
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';\nimport { addPlugin } from '@nx/devkit/src/utils/add-plugin';\n\nimport { createNodes } from '../../plugins/plugin';\nimport { InitGeneratorSchema } from './schema';\nimport { checkDependenciesInstalled, moveToDevDependencies } 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 function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n return initGeneratorInternal(tree, { addPlugin: false, ...schema });\n}\n\nexport async function initGeneratorInternal(\n tree: Tree,\n schema: InitGeneratorSchema\n) {\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n\n if (schema.addPlugin) {\n await addPlugin(\n tree,\n '@nx/vite/plugin',\n createNodes,\n {\n buildTargetName: ['build', 'vite:build', 'vite-build'],\n testTargetName: ['test', 'vite:test', 'vite-test'],\n serveTargetName: ['serve', 'vite:serve', 'vite-serve'],\n previewTargetName: ['preview', 'vite:preview', 'vite-preview'],\n serveStaticTargetName: [\n 'serve-static',\n 'vite:serve-static',\n 'vite-serve-static',\n ],\n },\n schema.updatePackageScripts\n );\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","initGeneratorInternal","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","addPlugin","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","createNodes","buildTargetName","testTargetName","serveTargetName","previewTargetName","serveStaticTargetName","updatePackageScripts","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n createProjectGraphAsync,\n formatFiles,\n GeneratorCallback,\n readNxJson,\n runTasksInSerial,\n Tree,\n updateNxJson,\n} from '@nx/devkit';\nimport { addPlugin } from '@nx/devkit/src/utils/add-plugin';\n\nimport { createNodes } from '../../plugins/plugin';\nimport { InitGeneratorSchema } from './schema';\nimport { checkDependenciesInstalled, moveToDevDependencies } 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 function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n return initGeneratorInternal(tree, { addPlugin: false, ...schema });\n}\n\nexport async function initGeneratorInternal(\n tree: Tree,\n schema: InitGeneratorSchema\n) {\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n\n if (schema.addPlugin) {\n await addPlugin(\n tree,\n await createProjectGraphAsync(),\n '@nx/vite/plugin',\n createNodes,\n {\n buildTargetName: ['build', 'vite:build', 'vite-build'],\n testTargetName: ['test', 'vite:test', 'vite-test'],\n serveTargetName: ['serve', 'vite:serve', 'vite-serve'],\n previewTargetName: ['preview', 'vite:preview', 'vite-preview'],\n serveStaticTargetName: [\n 'serve-static',\n 'vite:serve-static',\n 'vite-serve-static',\n ],\n },\n schema.updatePackageScripts\n );\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","initGeneratorInternal","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","addPlugin","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","createProjectGraphAsync","createNodes","buildTargetName","testTargetName","serveTargetName","previewTargetName","serveStaticTargetName","updatePackageScripts","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IAegBA,oBAAoB;eAApBA;;IAgCAC,aAAa;eAAbA;;IAIMC,qBAAqB;eAArBA;;IA8CtB,OAA6B;eAA7B;;;;wBAzFO;2BACmB;wBAEE;uBAEsC;AAE3D,SAASF,qBAAqBG,IAAU;QAGnBC,qBAURA;IAZlB,MAAMA,SAASC,IAAAA,kBAAU,EAACF;IAE1B,MAAMG,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;IAEA,MAAMO,aAAYT,kBAAAA,OAAOU,OAAO,qBAAdV,gBAAgBW,IAAI,CAAC,CAACC,IACtC,OAAOA,MAAM,WACTA,MAAM,oBACNA,EAAEC,MAAM,KAAK;IAGnB,IAAI,CAACJ,WAAW;YACdT,SACAA,wBAAsB,aACtBA,mCACAA;;QAHAA,oBAAAA,UAAAA,QAAOc,4CAAPd,QAAOc,iBAAmB,CAAC;;QAC3Bd,MAAAA,yBAAAA,OA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;IAC9C;IAEA,IAAI,CAACA,OAAOmB,UAAU,EAAE;QACtB,MAAMC,IAAAA,mBAAW,EAACvC;IACpB;IAEA,OAAOwC,IAAAA,wBAAgB,KAAIN;AAC7B;MAEA,WAAepC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const viteConfigFixture = "/// <reference types=\"vitest\" />\nimport react from '@vitejs/plugin-react';\nimport dns from 'dns';\nimport { PluginOption, defineConfig } from 'vite';\nimport { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\ndns.setDefaultResultOrder('verbatim');\nconst BASE_HREF = '/app';\n\n/**\n * Adds <base href=\"/app\">` to the head of the index.html\n * The reason why the `base` configuration property doesn't work is because it makes\n * all assets served under `/app` of `/` and this impacts the download zip service worker\n * We only want to the service worker to listen to events related to downloads, but not capture any other events\n * and the only way to do this is make sure all assets are served from the root, but we still want our app path to be `/app`\n *\n * This mimics the same behavior we had with webpack before migrating to vite\n */\nconst baseHrefPlugin: () => PluginOption = () => {\n return {\n name: 'html-transform',\n transformIndexHtml(html) {\n return html.replace('<head>', `<head>\\n <base href=\"${BASE_HREF}\">`);\n },\n };\n};\n\nexport default defineConfig({\n cacheDir: '../../node_modules/.vite/jetstream',\n envPrefix: 'NX',\n\n server: {\n port: 4200,\n host: 'localhost',\n },\n\n build: {\n // Put all assets at the root of the app instead of under /assets\n assetsDir: './',\n sourcemap: true,\n rollupOptions: {\n output: {\n sourcemap: true,\n },\n },\n },\n\n plugins: [\n react({\n jsxImportSource: '@emotion/react',\n babel: {\n plugins: ['@emotion/babel-plugin'],\n },\n }),\n nxViteTsPaths(),\n baseHrefPlugin(),\n ],\n\n worker: {\n plugins: [\n nxViteTsPaths(),\n ],\n },\n});";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "viteConfigFixture", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return viteConfigFixture;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const viteConfigFixture = `/// <reference types="vitest" />
|
|
9
|
+
import react from '@vitejs/plugin-react';
|
|
10
|
+
import dns from 'dns';
|
|
11
|
+
import { PluginOption, defineConfig } from 'vite';
|
|
12
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
13
|
+
|
|
14
|
+
dns.setDefaultResultOrder('verbatim');
|
|
15
|
+
const BASE_HREF = '/app';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Adds <base href="/app">\` to the head of the index.html
|
|
19
|
+
* The reason why the \`base\` configuration property doesn't work is because it makes
|
|
20
|
+
* all assets served under \`/app\` of \`/\` and this impacts the download zip service worker
|
|
21
|
+
* We only want to the service worker to listen to events related to downloads, but not capture any other events
|
|
22
|
+
* and the only way to do this is make sure all assets are served from the root, but we still want our app path to be \`/app\`
|
|
23
|
+
*
|
|
24
|
+
* This mimics the same behavior we had with webpack before migrating to vite
|
|
25
|
+
*/
|
|
26
|
+
const baseHrefPlugin: () => PluginOption = () => {
|
|
27
|
+
return {
|
|
28
|
+
name: 'html-transform',
|
|
29
|
+
transformIndexHtml(html) {
|
|
30
|
+
return html.replace('<head>', \`<head>\\n <base href="\${BASE_HREF}">\`);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
cacheDir: '../../node_modules/.vite/jetstream',
|
|
37
|
+
envPrefix: 'NX',
|
|
38
|
+
|
|
39
|
+
server: {
|
|
40
|
+
port: 4200,
|
|
41
|
+
host: 'localhost',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
build: {
|
|
45
|
+
// Put all assets at the root of the app instead of under /assets
|
|
46
|
+
assetsDir: './',
|
|
47
|
+
sourcemap: true,
|
|
48
|
+
rollupOptions: {
|
|
49
|
+
output: {
|
|
50
|
+
sourcemap: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
plugins: [
|
|
56
|
+
react({
|
|
57
|
+
jsxImportSource: '@emotion/react',
|
|
58
|
+
babel: {
|
|
59
|
+
plugins: ['@emotion/babel-plugin'],
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
nxViteTsPaths(),
|
|
63
|
+
baseHrefPlugin(),
|
|
64
|
+
],
|
|
65
|
+
|
|
66
|
+
worker: {
|
|
67
|
+
plugins: [
|
|
68
|
+
nxViteTsPaths(),
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
});`;
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=vite-config-with-additional-js.fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/vite/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.ts"],"sourcesContent":["export const viteConfigFixture = `/// <reference types=\"vitest\" />\nimport react from '@vitejs/plugin-react';\nimport dns from 'dns';\nimport { PluginOption, defineConfig } from 'vite';\nimport { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\n\ndns.setDefaultResultOrder('verbatim');\nconst BASE_HREF = '/app';\n\n/**\n * Adds <base href=\"/app\">\\` to the head of the index.html\n * The reason why the \\`base\\` configuration property doesn't work is because it makes\n * all assets served under \\`/app\\` of \\`/\\` and this impacts the download zip service worker\n * We only want to the service worker to listen to events related to downloads, but not capture any other events\n * and the only way to do this is make sure all assets are served from the root, but we still want our app path to be \\`/app\\`\n *\n * This mimics the same behavior we had with webpack before migrating to vite\n */\nconst baseHrefPlugin: () => PluginOption = () => {\n return {\n name: 'html-transform',\n transformIndexHtml(html) {\n return html.replace('<head>', \\`<head>\\\\n <base href=\"\\${BASE_HREF}\">\\`);\n },\n };\n};\n\nexport default defineConfig({\n cacheDir: '../../node_modules/.vite/jetstream',\n envPrefix: 'NX',\n\n server: {\n port: 4200,\n host: 'localhost',\n },\n\n build: {\n // Put all assets at the root of the app instead of under /assets\n assetsDir: './',\n sourcemap: true,\n rollupOptions: {\n output: {\n sourcemap: true,\n },\n },\n },\n\n plugins: [\n react({\n jsxImportSource: '@emotion/react',\n babel: {\n plugins: ['@emotion/babel-plugin'],\n },\n }),\n nxViteTsPaths(),\n baseHrefPlugin(),\n ],\n\n worker: {\n plugins: [\n nxViteTsPaths(),\n ],\n },\n});`;\n"],"names":["viteConfigFixture"],"mappings":";+BAAaA;;;eAAAA;;;AAAN,MAAMA,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+D/B,CAAC"}
|
|
@@ -44,14 +44,17 @@ async function updateBuildDir(tree) {
|
|
|
44
44
|
await (0, _devkit.formatFiles)(tree);
|
|
45
45
|
}
|
|
46
46
|
function getConfigNode(configFileContents) {
|
|
47
|
-
var _tsquery_query
|
|
47
|
+
var _tsquery_query;
|
|
48
48
|
if (!configFileContents) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
let configNode = (_tsquery_query = _tsquery.tsquery.query(configFileContents, `ObjectLiteralExpression`)) == null ? void 0 : _tsquery_query[0];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
let configNode = (_tsquery_query = _tsquery.tsquery.query(configFileContents, `CallExpression:has(Identifier[name=defineConfig]) > ObjectLiteralExpression`)) == null ? void 0 : _tsquery_query[0];
|
|
52
|
+
if (!configNode) {
|
|
53
|
+
var _tsquery_query1;
|
|
54
|
+
const arrowFunctionReturnStatement = (_tsquery_query1 = _tsquery.tsquery.query(configFileContents, `ArrowFunction Block ReturnStatement ObjectLiteralExpression`)) == null ? void 0 : _tsquery_query1[0];
|
|
55
|
+
if (arrowFunctionReturnStatement) {
|
|
56
|
+
configNode = arrowFunctionReturnStatement;
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
return configNode;
|
|
57
60
|
}
|
|
@@ -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');\nimport { findViteConfig } from '../../utils/find-vite-config';\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\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
|
|
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');\nimport { findViteConfig } from '../../utils/find-vite-config';\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\nexport function getConfigNode(configFileContents: string): ts.Node | undefined {\n if (!configFileContents) {\n return;\n }\n let configNode = tsquery.query(\n configFileContents,\n `CallExpression:has(Identifier[name=defineConfig]) > ObjectLiteralExpression`\n )?.[0];\n\n if (!configNode) {\n const arrowFunctionReturnStatement = tsquery.query(\n configFileContents,\n `ArrowFunction Block ReturnStatement ObjectLiteralExpression`\n )?.[0];\n\n if (arrowFunctionReturnStatement) {\n configNode = arrowFunctionReturnStatement;\n }\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","configFileContents","tsquery","configNode","query","arrowFunctionReturnStatement","configPath","logger","warn"],"mappings":";;;;;;;;IAgBA,OAuCC;eAvC6BA;;IAyCdC,aAAa;eAAbA;;IAuBAC,eAAe;eAAfA;;;wBA1ET;sCACgC;iCAEE;gCACR;qCACG;yBACZ;gCAEO;AAD/B,MAAOC,aAAa;AAGL,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,IAAAA,8BAAc,EAACX,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;AAEO,SAASH,cAAcyB,kBAA0B;QAIrCC;IAHjB,IAAI,CAACD,oBAAoB;QACvB;IACF;IACA,IAAIE,cAAaD,iBAAAA,gBAAO,CAACE,KAAK,CAC5BH,oBACA,CAAC,2EAA2E,CAAC,sBAF9DC,cAGd,CAAC,EAAE;IAEN,IAAI,CAACC,YAAY;YACsBD;QAArC,MAAMG,gCAA+BH,kBAAAA,gBAAO,CAACE,KAAK,CAChDH,oBACA,CAAC,2DAA2D,CAAC,sBAF1BC,eAGlC,CAAC,EAAE;QAEN,IAAIG,8BAA8B;YAChCF,aAAaE;QACf;IACF;IAEA,OAAOF;AACT;AAEO,SAAS1B,gBAAgB6B,UAAkB;IAChDC,cAAM,CAACC,IAAI,CAAC,CAAC;yBACU,EAAEF,WAAW;uDACiB,EAAEA,WAAW;;;;EAIlE,CAAC;AACH"}
|
|
@@ -288,6 +288,7 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
288
288
|
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
289
289
|
build: {
|
|
290
290
|
outDir: '${buildOutDir}',
|
|
291
|
+
emptyOutDir: true,
|
|
291
292
|
reportCompressedSize: true,
|
|
292
293
|
commonjsOptions: {
|
|
293
294
|
transformMixedEsModules: true,
|
|
@@ -308,6 +309,7 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
308
309
|
},` : `
|
|
309
310
|
build: {
|
|
310
311
|
outDir: '${buildOutDir}',
|
|
312
|
+
emptyOutDir: true,
|
|
311
313
|
reportCompressedSize: true,
|
|
312
314
|
commonjsOptions: {
|
|
313
315
|
transformMixedEsModules: true,
|
|
@@ -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 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', 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 globals: true,\n cache: {\n dir: '${normalizedJoinPaths(\n offsetFromRoot(projectRoot),\n 'node_modules',\n '.vitest',\n projectRoot === '.' ? options.project : projectRoot\n )}'\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: '${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 cache: {\n dir: normalizedJoinPaths(\n offsetFromRoot,\n 'node_modules',\n '.vitest',\n projectRoot === '.' ? options.project : projectRoot\n ),\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\nfunction normalizedJoinPaths(...paths: string[]): string {\n const path = joinPathFragments(...paths);\n\n return path.startsWith('.') ? path : `./${path}`;\n}\n"],"names":["findExistingJsBuildTargetInProject","addOrChangeTestTarget","addBuildTarget","addServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownConfiguration","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","normalizedJoinPaths","testEnvironment","inSourceTests","coverageProvider","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","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","cache","dir","environment","include","reporters","coverage","provider","changed","ensureViteConfigIsCorrect","paths","path","startsWith"],"mappings":";;;;;;;;IAuBgBA,kCAAkC;eAAlCA;;IAyDAC,qBAAqB;eAArBA;;IAgCAC,cAAc;eAAdA;;IAgCAC,cAAc;eAAdA;;IAqCAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAoCAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA0EAC,sBAAsB;eAAtBA;;IA4LAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,0BAA0B;eAA1BA;;;wBAtnBf;qCAKmC;wCACH;AAOhC,SAASZ,mCAAmCa,OAElD;IAIC,MAAMC,SAGF,CAAC;IAEL,MAAMC,qBAAqB;QACzBC,OAAO;YAAC;YAAgB;YAAc;SAAoB;IAC5D;IACA,MAAMC,uBAAuB;Q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A2D,gBACAE,aACAiD,mBACA9C,SACAG,SACAC,YACAqD,kBACA3C,UACArB,uCAAAA,+BAAgC,CAAC;IAGnC,IAAI,CAACyE,SAAS;QACZpC,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAEpC,eAAe;;QAExF,EAAEE,YAAY;;QAEd,CAAC;IAEP;AACF;AAEA,SAASS,oBAAoB,GAAG8D,KAAe;IAC7C,MAAMC,OAAOhI,IAAAA,yBAAiB,KAAI+H;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/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 globals: true,\n cache: {\n dir: '${normalizedJoinPaths(\n offsetFromRoot(projectRoot),\n 'node_modules',\n '.vitest',\n projectRoot === '.' ? options.project : projectRoot\n )}'\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: '${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 cache: {\n dir: normalizedJoinPaths(\n offsetFromRoot,\n 'node_modules',\n '.vitest',\n projectRoot === '.' ? options.project : projectRoot\n ),\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\nfunction normalizedJoinPaths(...paths: string[]): string {\n const path = joinPathFragments(...paths);\n\n return path.startsWith('.') ? path : `./${path}`;\n}\n"],"names":["findExistingJsBuildTargetInProject","addOrChangeTestTarget","addBuildTarget","addServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownConfiguration","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","normalizedJoinPaths","testEnvironment","inSourceTests","coverageProvider","defineOption","devServerOption","previewServerOption","workerOption","cacheDir","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","cache","dir","environment","include","reporters","coverage","provider","changed","ensureViteConfigIsCorrect","paths","path","startsWith"],"mappings":";;;;;;;;IAuBgBA,kCAAkC;eAAlCA;;IAyDAC,qBAAqB;eAArBA;;IAgCAC,cAAc;eAAdA;;IAgCAC,cAAc;eAAdA;;IAqCAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAoCAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IA0EAC,sBAAsB;eAAtBA;;IA8LAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,0BAA0B;eAA1BA;;;wBAxnBf;qCAKmC;wCACH;AAOhC,SAASZ,mCAAmCa,OAElD;IAIC,MAAMC,SAGF,CAAC;IAEL,MAAMC,qBAAqB;QACzBC,OAAO;YAAC;YAAgB;YAAc;SAAoB;IAC5D;IACA,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;KACD;IAED,kEAAkE;IAClE,wDAAwD;IACxD,IAAK,MAAMC,UAAUL,QAAS;QAC5B,MAAMM,eAAeN,OAAO,CAACK,OAAO,CAACE,QAAQ;QAC7C,IAAIL,mBAAmBC,KAAK,CAACK,QAAQ,CAACF,eAAe;YACnDL,OAAOQ,SAAS,GAAGJ;QACrB,OAAO,IAAID,qBAAqBI,QAAQ,CAACF,eAAe;YACtDL,OAAOS,WAAW,GAAGL;QACvB;IACF;IACA,OAAO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