@nx/vite 18.0.4 → 18.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/migrations.json +21 -0
- package/package.json +5 -5
- package/src/executors/test/lib/utils.d.ts +2 -2
- package/src/executors/test/lib/utils.js +22 -12
- package/src/executors/test/lib/utils.js.map +1 -1
- package/src/executors/test/schema.d.ts +1 -0
- package/src/executors/test/schema.json +4 -0
- package/src/executors/test/vitest.impl.js +3 -3
- package/src/executors/test/vitest.impl.js.map +1 -1
- package/src/generators/configuration/configuration.js +6 -68
- package/src/generators/configuration/configuration.js.map +1 -1
- package/src/generators/configuration/lib/convert-non-vite.d.ts +5 -0
- package/src/generators/configuration/lib/convert-non-vite.js +62 -0
- package/src/generators/configuration/lib/convert-non-vite.js.map +1 -0
- package/src/generators/configuration/schema.d.ts +0 -3
- package/src/generators/configuration/schema.json +0 -12
- package/src/generators/vitest/vitest-generator.js +2 -2
- package/src/generators/vitest/vitest-generator.js.map +1 -1
- package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js +2 -16
- package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js.map +1 -1
- package/src/migrations/update-17-2-0/update-vite-config.js +2 -16
- package/src/migrations/update-17-2-0/update-vite-config.js.map +1 -1
- package/src/utils/executor-utils.d.ts +1 -0
- package/src/utils/executor-utils.js +6 -0
- package/src/utils/executor-utils.js.map +1 -1
- package/src/{migrations/update-17-2-0/lib → utils}/find-vite-config.d.ts +1 -0
- package/src/utils/find-vite-config.js +46 -0
- package/src/utils/find-vite-config.js.map +1 -0
- package/src/utils/generator-utils.d.ts +8 -11
- package/src/utils/generator-utils.js +71 -186
- package/src/utils/generator-utils.js.map +1 -1
- package/src/utils/test-utils.js +8 -16
- package/src/utils/test-utils.js.map +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/utils/versions.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/find-vite-config.js +0 -25
- package/src/migrations/update-17-2-0/lib/find-vite-config.js.map +0 -1
- package/src/utils/test-files/react-project.config.json +0 -82
- package/src/utils/test-files/web-project.config.json +0 -69
|
@@ -8,12 +8,13 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
const _devkit = require("@nx/devkit");
|
|
9
9
|
const _executoroptionsutils = require("@nx/devkit/src/generators/executor-options-utils");
|
|
10
10
|
const _tsquery = require("@phenomnomnominal/tsquery");
|
|
11
|
+
const _findviteconfig = require("../../utils/find-vite-config");
|
|
11
12
|
function update(tree) {
|
|
12
13
|
const projects = (0, _devkit.getProjects)(tree);
|
|
13
14
|
(0, _executoroptionsutils.forEachExecutorOptions)(tree, '@nx/vite:build', (options, projectName)=>{
|
|
14
15
|
var _oldTsConfigPathPlugin__importClause_name, _oldTsConfigPathPlugin__importClause, _oldTsConfigPathPlugin_;
|
|
15
16
|
const projectConfig = projects.get(projectName);
|
|
16
|
-
const config = options.configFile || findViteConfig(tree, projectConfig.root);
|
|
17
|
+
const config = options.configFile || (0, _findviteconfig.findViteConfig)(tree, projectConfig.root);
|
|
17
18
|
if (!config || !tree.exists(config)) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
@@ -34,20 +35,5 @@ function update(tree) {
|
|
|
34
35
|
tree.write(config, withImportChange);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
function findViteConfig(tree, searchRoot) {
|
|
38
|
-
const allowsExt = [
|
|
39
|
-
'js',
|
|
40
|
-
'mjs',
|
|
41
|
-
'ts',
|
|
42
|
-
'cjs',
|
|
43
|
-
'mts',
|
|
44
|
-
'cts'
|
|
45
|
-
];
|
|
46
|
-
for (const ext of allowsExt){
|
|
47
|
-
if (tree.exists((0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`))) {
|
|
48
|
-
return (0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
38
|
|
|
53
39
|
//# sourceMappingURL=change-ts-paths-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.ts"],"sourcesContent":["import { Tree, getProjects, joinPathFragments } from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { ViteBuildExecutorOptions } from '../../executors/build/schema';\nimport { tsquery } from '@phenomnomnominal/tsquery';\n\nexport default function update(tree: Tree) {\n const projects = getProjects(tree);\n forEachExecutorOptions<ViteBuildExecutorOptions>(\n tree,\n '@nx/vite:build',\n (options, projectName) => {\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\n const configContents = tree.read(config, 'utf-8');\n\n const oldTsConfigPathPlugin =\n tsquery.query(\n configContents,\n 'ImportDeclaration:has(StringLiteral[value=\"vite-tsconfig-paths\"])'\n ) ?? [];\n\n if (oldTsConfigPathPlugin.length === 0) {\n return;\n }\n\n const importName =\n oldTsConfigPathPlugin[0]?.['importClause']?.name?.text ??\n 'viteTsConfigPaths';\n const updatedContent = tsquery.replace(\n configContents,\n `PropertyAssignment:has(Identifier[name=\"plugins\"]) CallExpression:has(Identifier[name=\"${importName}\"])`,\n () => {\n return `nxViteTsPaths()`;\n }\n );\n\n const withImportChange = tsquery.replace(\n updatedContent,\n 'ImportDeclaration:has(StringLiteral[value=\"vite-tsconfig-paths\"])',\n () => {\n return \"import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\";\n }\n );\n\n tree.write(config, withImportChange);\n }\n );\n}\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.ts"],"sourcesContent":["import { Tree, getProjects, joinPathFragments } from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { ViteBuildExecutorOptions } from '../../executors/build/schema';\nimport { tsquery } from '@phenomnomnominal/tsquery';\nimport { findViteConfig } from '../../utils/find-vite-config';\n\nexport default function update(tree: Tree) {\n const projects = getProjects(tree);\n forEachExecutorOptions<ViteBuildExecutorOptions>(\n tree,\n '@nx/vite:build',\n (options, projectName) => {\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\n const configContents = tree.read(config, 'utf-8');\n\n const oldTsConfigPathPlugin =\n tsquery.query(\n configContents,\n 'ImportDeclaration:has(StringLiteral[value=\"vite-tsconfig-paths\"])'\n ) ?? [];\n\n if (oldTsConfigPathPlugin.length === 0) {\n return;\n }\n\n const importName =\n oldTsConfigPathPlugin[0]?.['importClause']?.name?.text ??\n 'viteTsConfigPaths';\n const updatedContent = tsquery.replace(\n configContents,\n `PropertyAssignment:has(Identifier[name=\"plugins\"]) CallExpression:has(Identifier[name=\"${importName}\"])`,\n () => {\n return `nxViteTsPaths()`;\n }\n );\n\n const withImportChange = tsquery.replace(\n updatedContent,\n 'ImportDeclaration:has(StringLiteral[value=\"vite-tsconfig-paths\"])',\n () => {\n return \"import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';\";\n }\n );\n\n tree.write(config, withImportChange);\n }\n );\n}\n"],"names":["update","tree","projects","getProjects","forEachExecutorOptions","options","projectName","oldTsConfigPathPlugin","projectConfig","get","config","configFile","findViteConfig","root","exists","configContents","read","tsquery","query","length","importName","name","text","updatedContent","replace","withImportChange","write"],"mappings":";+BAMA;;;eAAwBA;;;wBAN6B;sCACd;yBAEf;gCACO;AAEhB,SAASA,OAAOC,IAAU;IACvC,MAAMC,WAAWC,IAAAA,mBAAW,EAACF;IAC7BG,IAAAA,4CAAsB,EACpBH,MACA,kBACA,CAACI,SAASC;YAqBNC,2CAAAA,sCAAAA;QApBF,MAAMC,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;QAEA,MAAMK,iBAAiBd,KAAKe,IAAI,CAACN,QAAQ;YAGvCO;QADF,MAAMV,wBACJU,CAAAA,iBAAAA,gBAAO,CAACC,KAAK,CACXH,gBACA,gFAFFE,iBAGK,EAAE;QAET,IAAIV,sBAAsBY,MAAM,KAAK,GAAG;YACtC;QACF;YAGEZ;QADF,MAAMa,aACJb,CAAAA,kDAAAA,0BAAAA,qBAAqB,CAAC,EAAE,sBAAxBA,uCAAAA,uBAA0B,CAAC,eAAe,sBAA1CA,4CAAAA,qCAA4Cc,IAAI,qBAAhDd,0CAAkDe,IAAI,YAAtDf,iDACA;QACF,MAAMgB,iBAAiBN,gBAAO,CAACO,OAAO,CACpCT,gBACA,CAAC,uFAAuF,EAAEK,WAAW,GAAG,CAAC,EACzG;YACE,OAAO,CAAC,eAAe,CAAC;QAC1B;QAGF,MAAMK,mBAAmBR,gBAAO,CAACO,OAAO,CACtCD,gBACA,qEACA;YACE,OAAO;QACT;QAGFtB,KAAKyB,KAAK,CAAChB,QAAQe;IACrB;AAEJ"}
|
|
@@ -22,13 +22,14 @@ const _editbuildconfig = require("./lib/edit-build-config");
|
|
|
22
22
|
const _edittestconfig = require("./lib/edit-test-config");
|
|
23
23
|
const _addfilereplacements = require("./lib/add-file-replacements");
|
|
24
24
|
const _tsquery = require("@phenomnomnominal/tsquery");
|
|
25
|
+
const _findviteconfig = require("../../utils/find-vite-config");
|
|
25
26
|
const ts = require("typescript");
|
|
26
27
|
async function updateBuildDir(tree) {
|
|
27
28
|
const projects = (0, _devkit.getProjects)(tree);
|
|
28
29
|
(0, _executoroptionsutils.forEachExecutorOptions)(tree, '@nx/vite:build', (options, projectName, targetName)=>{
|
|
29
30
|
var _options_fileReplacements;
|
|
30
31
|
const projectConfig = projects.get(projectName);
|
|
31
|
-
const config = options.configFile || findViteConfig(tree, projectConfig.root);
|
|
32
|
+
const config = options.configFile || (0, _findviteconfig.findViteConfig)(tree, projectConfig.root);
|
|
32
33
|
if (!config || !tree.exists(config)) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -42,21 +43,6 @@ async function updateBuildDir(tree) {
|
|
|
42
43
|
});
|
|
43
44
|
await (0, _devkit.formatFiles)(tree);
|
|
44
45
|
}
|
|
45
|
-
function findViteConfig(tree, searchRoot) {
|
|
46
|
-
const allowsExt = [
|
|
47
|
-
'js',
|
|
48
|
-
'mjs',
|
|
49
|
-
'ts',
|
|
50
|
-
'cjs',
|
|
51
|
-
'mts',
|
|
52
|
-
'cts'
|
|
53
|
-
];
|
|
54
|
-
for (const ext of allowsExt){
|
|
55
|
-
if (tree.exists((0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`))) {
|
|
56
|
-
return (0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
46
|
function getConfigNode(configFileContents) {
|
|
61
47
|
var _tsquery_query, _tsquery_query1;
|
|
62
48
|
if (!configFileContents) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-17-2-0/update-vite-config.ts"],"sourcesContent":["import {\n Tree,\n formatFiles,\n getProjects,\n joinPathFragments,\n logger,\n} from '@nx/devkit';\nimport { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils';\nimport { ViteBuildExecutorOptions } from '../../executors/build/schema';\nimport { updateBuildOutDirAndRoot } from './lib/edit-build-config';\nimport { updateTestConfig } from './lib/edit-test-config';\nimport { addFileReplacements } from './lib/add-file-replacements';\nimport { tsquery } from '@phenomnomnominal/tsquery';\nimport ts = require('typescript');\n\nexport default async function updateBuildDir(tree: Tree) {\n const projects = getProjects(tree);\n forEachExecutorOptions<ViteBuildExecutorOptions>(\n tree,\n '@nx/vite:build',\n (options, projectName, targetName) => {\n const projectConfig = projects.get(projectName);\n const config =\n options.configFile || findViteConfig(tree, projectConfig.root);\n if (!config || !tree.exists(config)) {\n return;\n }\n let configContents = tree.read(config, 'utf-8');\n\n configContents = updateBuildOutDirAndRoot(\n options,\n configContents,\n projectConfig,\n targetName,\n tree,\n projectName,\n config\n );\n\n configContents = updateTestConfig(configContents, projectConfig, config);\n\n if (options['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\
|
|
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 configFileContents,\n `ArrowFunction Block ReturnStatement ObjectLiteralExpression`\n )?.[0];\n\n if (arrowFunctionReturnStatement) {\n configNode = arrowFunctionReturnStatement;\n }\n\n return configNode;\n}\n\nexport function notFoundWarning(configPath: string) {\n logger.warn(`\n Could not migrate your ${configPath} file.\n Please add the build.outDir and root options in your ${configPath} file.\n You can find more information on how to configure vite for Nx here:\n \n https://nx.dev/recipes/vite/configure-vite\n `);\n}\n"],"names":["updateBuildDir","getConfigNode","notFoundWarning","ts","tree","projects","getProjects","forEachExecutorOptions","options","projectName","targetName","projectConfig","get","config","configFile","findViteConfig","root","exists","configContents","read","updateBuildOutDirAndRoot","updateTestConfig","length","addFileReplacements","write","formatFiles","configFileContents","tsquery","configNode","query","arrowFunctionReturnStatement","configPath","logger","warn"],"mappings":";;;;;;;;IAgBA,OAuCC;eAvC6BA;;IAyCdC,aAAa;eAAbA;;IAqBAC,eAAe;eAAfA;;;wBAxET;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,gBAKoBA;IARrC,IAAI,CAACD,oBAAoB;QACvB;IACF;IACA,IAAIE,cAAaD,iBAAAA,gBAAO,CAACE,KAAK,CAC5BH,oBACA,CAAC,uBAAuB,CAAC,sBAFVC,cAGd,CAAC,EAAE;IAEN,MAAMG,gCAA+BH,kBAAAA,gBAAO,CAACE,KAAK,CAChDH,oBACA,CAAC,2DAA2D,CAAC,sBAF1BC,eAGlC,CAAC,EAAE;IAEN,IAAIG,8BAA8B;QAChCF,aAAaE;IACf;IAEA,OAAOF;AACT;AAEO,SAAS1B,gBAAgB6B,UAAkB;IAChDC,cAAM,CAACC,IAAI,CAAC,CAAC;yBACU,EAAEF,WAAW;uDACiB,EAAEA,WAAW;;;;EAIlE,CAAC;AACH"}
|
|
@@ -8,3 +8,4 @@ export declare function validateTypes(opts: {
|
|
|
8
8
|
}): Promise<void>;
|
|
9
9
|
export declare function createBuildableTsConfig(projectRoot: string, options: ViteBuildExecutorOptions | ViteDevServerExecutorOptions, context: ExecutorContext): void;
|
|
10
10
|
export declare function loadViteDynamicImport(): Promise<typeof import("vite")>;
|
|
11
|
+
export declare function loadVitestDynamicImport(): Promise<typeof import("vitest/node")>;
|
|
@@ -14,6 +14,9 @@ _export(exports, {
|
|
|
14
14
|
},
|
|
15
15
|
loadViteDynamicImport: function() {
|
|
16
16
|
return loadViteDynamicImport;
|
|
17
|
+
},
|
|
18
|
+
loadVitestDynamicImport: function() {
|
|
19
|
+
return loadVitestDynamicImport;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
22
|
const _js = require("@nx/js");
|
|
@@ -49,5 +52,8 @@ function createBuildableTsConfig(projectRoot, options, context) {
|
|
|
49
52
|
function loadViteDynamicImport() {
|
|
50
53
|
return Function('return import("vite")')();
|
|
51
54
|
}
|
|
55
|
+
function loadVitestDynamicImport() {
|
|
56
|
+
return Function('return import("vitest/node")')();
|
|
57
|
+
}
|
|
52
58
|
|
|
53
59
|
//# sourceMappingURL=executor-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"sourcesContent":["import { printDiagnostics, runTypeCheck } from '@nx/js';\nimport { join } from 'path';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ExecutorContext } from '@nx/devkit';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport {\n calculateProjectBuildableDependencies,\n createTmpTsConfig,\n} from '@nx/js/src/utils/buildable-libs-utils';\nimport { getProjectTsConfigPath } from './options-utils';\n\nexport async function validateTypes(opts: {\n workspaceRoot: string;\n projectRoot: string;\n tsconfig: string;\n}): Promise<void> {\n const result = await runTypeCheck({\n workspaceRoot: opts.workspaceRoot,\n tsConfigPath: join(opts.workspaceRoot, opts.tsconfig),\n mode: 'noEmit',\n });\n\n await printDiagnostics(result.errors, result.warnings);\n\n if (result.errors.length > 0) {\n throw new Error('Found type errors. See above.');\n }\n}\n\nexport function createBuildableTsConfig(\n projectRoot: string,\n options: ViteBuildExecutorOptions | ViteDevServerExecutorOptions,\n context: ExecutorContext\n) {\n const tsConfig = getProjectTsConfigPath(projectRoot);\n options['buildLibsFromSource'] ??= true;\n\n if (!options['buildLibsFromSource']) {\n const { dependencies } = calculateProjectBuildableDependencies(\n context.taskGraph,\n context.projectGraph,\n context.root,\n context.projectName,\n // When using incremental building and the serve target is called\n // we need to get the deps for the 'build' target instead.\n context.targetName === 'serve' ? 'build' : context.targetName,\n context.configurationName\n );\n // This tsconfig is used via the Vite ts paths plugin.\n // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).\n const tmpTsConfigPath = createTmpTsConfig(\n tsConfig,\n context.root,\n projectRoot,\n dependencies\n );\n process.env.NX_TSCONFIG_PATH = tmpTsConfigPath;\n }\n}\n\nexport function loadViteDynamicImport() {\n return Function('return import(\"vite\")')() as Promise<typeof import('vite')>;\n}\n"],"names":["validateTypes","createBuildableTsConfig","loadViteDynamicImport","opts","result","runTypeCheck","workspaceRoot","tsConfigPath","join","tsconfig","mode","printDiagnostics","errors","warnings","length","Error","projectRoot","options","context","tsConfig","getProjectTsConfigPath","dependencies","calculateProjectBuildableDependencies","taskGraph","projectGraph","root","projectName","targetName","configurationName","tmpTsConfigPath","createTmpTsConfig","process","env","NX_TSCONFIG_PATH","Function"],"mappings":";;;;;;;;IAWsBA,aAAa;eAAbA;;IAkBNC,uBAAuB;eAAvBA;;IA+BAC,qBAAqB;eAArBA;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"sourcesContent":["import { printDiagnostics, runTypeCheck } from '@nx/js';\nimport { join } from 'path';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ExecutorContext } from '@nx/devkit';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport {\n calculateProjectBuildableDependencies,\n createTmpTsConfig,\n} from '@nx/js/src/utils/buildable-libs-utils';\nimport { getProjectTsConfigPath } from './options-utils';\n\nexport async function validateTypes(opts: {\n workspaceRoot: string;\n projectRoot: string;\n tsconfig: string;\n}): Promise<void> {\n const result = await runTypeCheck({\n workspaceRoot: opts.workspaceRoot,\n tsConfigPath: join(opts.workspaceRoot, opts.tsconfig),\n mode: 'noEmit',\n });\n\n await printDiagnostics(result.errors, result.warnings);\n\n if (result.errors.length > 0) {\n throw new Error('Found type errors. See above.');\n }\n}\n\nexport function createBuildableTsConfig(\n projectRoot: string,\n options: ViteBuildExecutorOptions | ViteDevServerExecutorOptions,\n context: ExecutorContext\n) {\n const tsConfig = getProjectTsConfigPath(projectRoot);\n options['buildLibsFromSource'] ??= true;\n\n if (!options['buildLibsFromSource']) {\n const { dependencies } = calculateProjectBuildableDependencies(\n context.taskGraph,\n context.projectGraph,\n context.root,\n context.projectName,\n // When using incremental building and the serve target is called\n // we need to get the deps for the 'build' target instead.\n context.targetName === 'serve' ? 'build' : context.targetName,\n context.configurationName\n );\n // This tsconfig is used via the Vite ts paths plugin.\n // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).\n const tmpTsConfigPath = createTmpTsConfig(\n tsConfig,\n context.root,\n projectRoot,\n dependencies\n );\n process.env.NX_TSCONFIG_PATH = tmpTsConfigPath;\n }\n}\n\nexport function loadViteDynamicImport() {\n return Function('return import(\"vite\")')() as Promise<typeof import('vite')>;\n}\n\nexport function loadVitestDynamicImport() {\n return Function('return import(\"vitest/node\")')() as Promise<\n typeof import('vitest/node')\n >;\n}\n"],"names":["validateTypes","createBuildableTsConfig","loadViteDynamicImport","loadVitestDynamicImport","opts","result","runTypeCheck","workspaceRoot","tsConfigPath","join","tsconfig","mode","printDiagnostics","errors","warnings","length","Error","projectRoot","options","context","tsConfig","getProjectTsConfigPath","dependencies","calculateProjectBuildableDependencies","taskGraph","projectGraph","root","projectName","targetName","configurationName","tmpTsConfigPath","createTmpTsConfig","process","env","NX_TSCONFIG_PATH","Function"],"mappings":";;;;;;;;IAWsBA,aAAa;eAAbA;;IAkBNC,uBAAuB;eAAvBA;;IA+BAC,qBAAqB;eAArBA;;IAIAC,uBAAuB;eAAvBA;;;oBAhE+B;sBAC1B;oCAOd;8BACgC;AAEhC,eAAeH,cAAcI,IAInC;IACC,MAAMC,SAAS,MAAMC,IAAAA,gBAAY,EAAC;QAChCC,eAAeH,KAAKG,aAAa;QACjCC,cAAcC,IAAAA,UAAI,EAACL,KAAKG,aAAa,EAAEH,KAAKM,QAAQ;QACpDC,MAAM;IACR;IAEA,MAAMC,IAAAA,oBAAgB,EAACP,OAAOQ,MAAM,EAAER,OAAOS,QAAQ;IAErD,IAAIT,OAAOQ,MAAM,CAACE,MAAM,GAAG,GAAG;QAC5B,MAAM,IAAIC,MAAM;IAClB;AACF;AAEO,SAASf,wBACdgB,WAAmB,EACnBC,OAAgE,EAChEC,OAAwB;QAGxBD,UAAQ;IADR,MAAME,WAAWC,IAAAA,oCAAsB,EAACJ;;IACxCC,MAAAA,WAAAA,QAAO,CAAC,uBAAA,sBAAsB,gBAA9BA,QAAO,CAAC,qBAAsB,GAAK;IAEnC,IAAI,CAACA,OAAO,CAAC,sBAAsB,EAAE;QACnC,MAAM,EAAEI,YAAY,EAAE,GAAGC,IAAAA,yDAAqC,EAC5DJ,QAAQK,SAAS,EACjBL,QAAQM,YAAY,EACpBN,QAAQO,IAAI,EACZP,QAAQQ,WAAW,EACnB,iEAAiE;QACjE,0DAA0D;QAC1DR,QAAQS,UAAU,KAAK,UAAU,UAAUT,QAAQS,UAAU,EAC7DT,QAAQU,iBAAiB;QAE3B,sDAAsD;QACtD,qGAAqG;QACrG,MAAMC,kBAAkBC,IAAAA,qCAAiB,EACvCX,UACAD,QAAQO,IAAI,EACZT,aACAK;QAEFU,QAAQC,GAAG,CAACC,gBAAgB,GAAGJ;IACjC;AACF;AAEO,SAAS5B;IACd,OAAOiC,SAAS;AAClB;AAEO,SAAShC;IACd,OAAOgC,SAAS;AAGlB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _export(target, all) {
|
|
3
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: all[name]
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
_export(exports, {
|
|
9
|
+
findViteConfig: function() {
|
|
10
|
+
return findViteConfig;
|
|
11
|
+
},
|
|
12
|
+
findWebpackConfig: function() {
|
|
13
|
+
return findWebpackConfig;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const _devkit = require("@nx/devkit");
|
|
17
|
+
function findViteConfig(tree, searchRoot) {
|
|
18
|
+
const allowsExt = [
|
|
19
|
+
'js',
|
|
20
|
+
'mjs',
|
|
21
|
+
'ts',
|
|
22
|
+
'cjs',
|
|
23
|
+
'mts',
|
|
24
|
+
'cts'
|
|
25
|
+
];
|
|
26
|
+
for (const ext of allowsExt){
|
|
27
|
+
if (tree.exists((0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`))) {
|
|
28
|
+
return (0, _devkit.joinPathFragments)(searchRoot, `vite.config.${ext}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function findWebpackConfig(tree, searchRoot) {
|
|
33
|
+
const allowsExt = [
|
|
34
|
+
'js',
|
|
35
|
+
'ts',
|
|
36
|
+
'mjs',
|
|
37
|
+
'cjs'
|
|
38
|
+
];
|
|
39
|
+
for (const ext of allowsExt){
|
|
40
|
+
if (tree.exists((0, _devkit.joinPathFragments)(searchRoot, `webpack.config.${ext}`))) {
|
|
41
|
+
return (0, _devkit.joinPathFragments)(searchRoot, `webpack.config.${ext}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=find-vite-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/find-vite-config.ts"],"sourcesContent":["import { Tree, joinPathFragments } from '@nx/devkit';\n\nexport function findViteConfig(tree: Tree, searchRoot: string) {\n const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];\n\n for (const ext of allowsExt) {\n if (tree.exists(joinPathFragments(searchRoot, `vite.config.${ext}`))) {\n return joinPathFragments(searchRoot, `vite.config.${ext}`);\n }\n }\n}\n\nexport function findWebpackConfig(tree: Tree, searchRoot: string) {\n const allowsExt = ['js', 'ts', 'mjs', 'cjs'];\n\n for (const ext of allowsExt) {\n if (tree.exists(joinPathFragments(searchRoot, `webpack.config.${ext}`))) {\n return joinPathFragments(searchRoot, `webpack.config.${ext}`);\n }\n }\n}\n"],"names":["findViteConfig","findWebpackConfig","tree","searchRoot","allowsExt","ext","exists","joinPathFragments"],"mappings":";;;;;;;;IAEgBA,cAAc;eAAdA;;IAUAC,iBAAiB;eAAjBA;;;wBAZwB;AAEjC,SAASD,eAAeE,IAAU,EAAEC,UAAkB;IAC3D,MAAMC,YAAY;QAAC;QAAM;QAAO;QAAM;QAAO;QAAO;KAAM;IAE1D,KAAK,MAAMC,OAAOD,UAAW;QAC3B,IAAIF,KAAKI,MAAM,CAACC,IAAAA,yBAAiB,EAACJ,YAAY,CAAC,YAAY,EAAEE,IAAI,CAAC,IAAI;YACpE,OAAOE,IAAAA,yBAAiB,EAACJ,YAAY,CAAC,YAAY,EAAEE,IAAI,CAAC;QAC3D;IACF;AACF;AAEO,SAASJ,kBAAkBC,IAAU,EAAEC,UAAkB;IAC9D,MAAMC,YAAY;QAAC;QAAM;QAAM;QAAO;KAAM;IAE5C,KAAK,MAAMC,OAAOD,UAAW;QAC3B,IAAIF,KAAKI,MAAM,CAACC,IAAAA,yBAAiB,EAACJ,YAAY,CAAC,eAAe,EAAEE,IAAI,CAAC,IAAI;YACvE,OAAOE,IAAAA,yBAAiB,EAACJ,YAAY,CAAC,eAAe,EAAEE,IAAI,CAAC;QAC9D;IACF;AACF"}
|
|
@@ -4,29 +4,26 @@ export type Target = 'build' | 'serve' | 'test' | 'preview';
|
|
|
4
4
|
export type TargetFlags = Partial<Record<Target, boolean>>;
|
|
5
5
|
export type UserProvidedTargetName = Partial<Record<Target, string>>;
|
|
6
6
|
export type ValidFoundTargetName = Partial<Record<Target, string>>;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function findExistingJsBuildTargetInProject(targets: {
|
|
8
8
|
[targetName: string]: TargetConfiguration;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
userProvidedTargetIsUnsupported: TargetFlags;
|
|
13
|
-
alreadyHasNxViteTargets: TargetFlags;
|
|
9
|
+
}): {
|
|
10
|
+
supported?: string;
|
|
11
|
+
unsupported?: string;
|
|
14
12
|
};
|
|
15
13
|
export declare function addOrChangeTestTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
14
|
+
export declare function addBuildTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
|
|
15
|
+
export declare function addServeTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, target: string): void;
|
|
18
16
|
/**
|
|
19
17
|
* Adds a target for the preview server.
|
|
20
18
|
*
|
|
21
19
|
* @param tree
|
|
22
20
|
* @param options
|
|
23
21
|
* @param serveTarget An existing serve target.
|
|
24
|
-
* @param previewTarget The preview target to create.
|
|
25
22
|
*/
|
|
26
23
|
export declare function addPreviewTarget(tree: Tree, options: ViteConfigurationGeneratorSchema, serveTarget: string): void;
|
|
27
24
|
export declare function editTsConfig(tree: Tree, options: ViteConfigurationGeneratorSchema): void;
|
|
28
25
|
export declare function deleteWebpackConfig(tree: Tree, projectRoot: string, webpackConfigFilePath?: string): void;
|
|
29
|
-
export declare function moveAndEditIndexHtml(tree: Tree, options: ViteConfigurationGeneratorSchema
|
|
26
|
+
export declare function moveAndEditIndexHtml(tree: Tree, options: ViteConfigurationGeneratorSchema): void;
|
|
30
27
|
export interface ViteConfigFileOptions {
|
|
31
28
|
project: string;
|
|
32
29
|
includeLib?: boolean;
|
|
@@ -42,4 +39,4 @@ export declare function createOrEditViteConfig(tree: Tree, options: ViteConfigFi
|
|
|
42
39
|
export declare function normalizeViteConfigFilePathWithTree(tree: Tree, projectRoot: string, configFile?: string): string;
|
|
43
40
|
export declare function getViteConfigPathForProject(tree: Tree, projectName: string, target?: string): string;
|
|
44
41
|
export declare function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported: TargetFlags, userProvidedTargetName: UserProvidedTargetName, validFoundTargetName: ValidFoundTargetName): Promise<void>;
|
|
45
|
-
export declare function
|
|
42
|
+
export declare function handleUnknownConfiguration(projectName: string): Promise<void>;
|