@nx/vite 16.1.4 → 16.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/executors/build/build.impl.js +15 -2
- package/src/executors/build/build.impl.js.map +1 -1
- package/src/executors/build/schema.d.ts +2 -0
- package/src/executors/build/schema.json +8 -0
- package/src/executors/test/vitest.impl.js +3 -3
- package/src/executors/test/vitest.impl.js.map +1 -1
- package/src/utils/generator-utils.js +2 -2
- package/src/utils/generator-utils.js.map +1 -1
- package/src/utils/options-utils.js +2 -2
- package/src/utils/options-utils.js.map +1 -1
- package/src/utils/test-files/test-vite-configs.d.ts +3 -3
- package/src/utils/test-files/test-vite-configs.js +4 -4
- package/src/utils/test-files/test-vite-configs.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"migrations": "./migrations.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@nrwl/vite": "16.
|
|
33
|
-
"@nx/devkit": "16.
|
|
34
|
-
"@nx/js": "16.
|
|
32
|
+
"@nrwl/vite": "16.2.0-beta.0",
|
|
33
|
+
"@nx/devkit": "16.2.0-beta.0",
|
|
34
|
+
"@nx/js": "16.2.0-beta.0",
|
|
35
35
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
36
36
|
"@swc/helpers": "~0.5.0",
|
|
37
37
|
"dotenv": "~10.0.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"./src/executors/*.impl": "./src/executors/*.impl.js",
|
|
60
60
|
"./src/executors/*/compat": "./src/executors/*/compat.js"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "f7ba85e8ec9c074eaee81731a20aee7ea6dbc8aa"
|
|
63
63
|
}
|
|
@@ -15,6 +15,7 @@ _export(exports, {
|
|
|
15
15
|
});
|
|
16
16
|
const _extends = require("@swc/helpers/_/_extends");
|
|
17
17
|
require("dotenv/config");
|
|
18
|
+
const _devkit = require("@nx/devkit");
|
|
18
19
|
const _vite = require("vite");
|
|
19
20
|
const _optionsutils = require("../../utils/options-utils");
|
|
20
21
|
const _js = require("@nx/js");
|
|
@@ -33,8 +34,20 @@ async function* viteBuildExecutor(options, context) {
|
|
|
33
34
|
const libraryPackageJson = (0, _path.resolve)(projectRoot, 'package.json');
|
|
34
35
|
const rootPackageJson = (0, _path.resolve)(context.root, 'package.json');
|
|
35
36
|
const distPackageJson = (0, _path.resolve)(normalizedOptions.outputPath, 'package.json');
|
|
36
|
-
//
|
|
37
|
-
if (
|
|
37
|
+
// Generate a package.json if option has been set.
|
|
38
|
+
if (options.generatePackageJson) {
|
|
39
|
+
const builtPackageJson = (0, _js.createPackageJson)(context.projectName, context.projectGraph, {
|
|
40
|
+
target: context.targetName,
|
|
41
|
+
root: context.root,
|
|
42
|
+
isProduction: !options.includeDevDependenciesInPackageJson
|
|
43
|
+
});
|
|
44
|
+
builtPackageJson.type = 'module';
|
|
45
|
+
(0, _devkit.writeJsonFile)(`${options.outputPath}/package.json`, builtPackageJson);
|
|
46
|
+
const lockFile = (0, _js.createLockFile)(builtPackageJson);
|
|
47
|
+
(0, _fs.writeFileSync)(`${options.outputPath}/${(0, _js.getLockFileName)()}`, lockFile, {
|
|
48
|
+
encoding: 'utf-8'
|
|
49
|
+
});
|
|
50
|
+
} else if (!(0, _fs.existsSync)(distPackageJson) && (0, _fs.existsSync)(libraryPackageJson) && rootPackageJson !== libraryPackageJson) {
|
|
38
51
|
await (0, _js.copyAssets)({
|
|
39
52
|
outputPath: normalizedOptions.outputPath,
|
|
40
53
|
assets: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import 'dotenv/config';\nimport { ExecutorContext } from '@nx/devkit';\nimport { build, InlineConfig, mergeConfig } from 'vite';\nimport {\n getViteBuildOptions,\n getViteSharedConfig,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from './schema';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import 'dotenv/config';\nimport { ExecutorContext, writeJsonFile } from '@nx/devkit';\nimport { build, InlineConfig, mergeConfig } from 'vite';\nimport {\n getViteBuildOptions,\n getViteSharedConfig,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from './schema';\nimport {\n copyAssets,\n createLockFile,\n createPackageJson,\n getLockFileName,\n} from '@nx/js';\nimport { existsSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';\n\nimport { registerTsConfigPaths } from '@nx/js/src/internal';\n\nexport async function* viteBuildExecutor(\n options: ViteBuildExecutorOptions,\n context: ExecutorContext\n) {\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n\n registerTsConfigPaths(resolve(projectRoot, 'tsconfig.json'));\n\n const normalizedOptions = normalizeOptions(options);\n\n const buildConfig = mergeConfig(\n getViteSharedConfig(normalizedOptions, false, context),\n {\n build: getViteBuildOptions(normalizedOptions, context),\n }\n );\n\n const watcherOrOutput = await runInstance(buildConfig);\n\n const libraryPackageJson = resolve(projectRoot, 'package.json');\n const rootPackageJson = resolve(context.root, 'package.json');\n const distPackageJson = resolve(normalizedOptions.outputPath, 'package.json');\n\n // Generate a package.json if option has been set.\n if (options.generatePackageJson) {\n const builtPackageJson = createPackageJson(\n context.projectName,\n context.projectGraph,\n {\n target: context.targetName,\n root: context.root,\n isProduction: !options.includeDevDependenciesInPackageJson, // By default we remove devDependencies since this is a production build.\n }\n );\n\n builtPackageJson.type = 'module';\n\n writeJsonFile(`${options.outputPath}/package.json`, builtPackageJson);\n\n const lockFile = createLockFile(builtPackageJson);\n writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {\n encoding: 'utf-8',\n });\n }\n // For buildable libs, copy package.json if it exists.\n else if (\n !existsSync(distPackageJson) &&\n existsSync(libraryPackageJson) &&\n rootPackageJson !== libraryPackageJson\n ) {\n await copyAssets(\n {\n outputPath: normalizedOptions.outputPath,\n assets: [\n {\n input: projectRoot,\n output: '.',\n glob: 'package.json',\n },\n ],\n },\n context\n );\n }\n\n if ('on' in watcherOrOutput) {\n const iterable = createAsyncIterable<{ success: boolean }>(({ next }) => {\n let success = true;\n watcherOrOutput.on('event', (event) => {\n if (event.code === 'START') {\n success = true;\n } else if (event.code === 'ERROR') {\n success = false;\n } else if (event.code === 'END') {\n next({ success });\n }\n // result must be closed when present.\n // see https://rollupjs.org/guide/en/#rollupwatch\n if ('result' in event) {\n event.result.close();\n }\n });\n });\n yield* iterable;\n } else {\n const output = watcherOrOutput?.['output'] || watcherOrOutput?.[0]?.output;\n const fileName = output?.[0]?.fileName || 'main.cjs';\n const outfile = resolve(normalizedOptions.outputPath, fileName);\n yield { success: true, outfile };\n }\n}\n\nfunction runInstance(options: InlineConfig) {\n return build({\n ...options,\n });\n}\n\nfunction normalizeOptions(options: ViteBuildExecutorOptions) {\n const normalizedOptions = { ...options };\n\n // coerce watch to null or {} to match with Vite's watch config\n if (options.watch === false) {\n normalizedOptions.watch = null;\n } else if (options.watch === true) {\n normalizedOptions.watch = {};\n }\n\n return normalizedOptions;\n}\n\nexport default viteBuildExecutor;\n"],"names":["viteBuildExecutor","options","context","projectRoot","projectsConfigurations","projects","projectName","root","registerTsConfigPaths","resolve","normalizedOptions","normalizeOptions","buildConfig","mergeConfig","getViteSharedConfig","build","getViteBuildOptions","watcherOrOutput","runInstance","libraryPackageJson","rootPackageJson","distPackageJson","outputPath","generatePackageJson","builtPackageJson","createPackageJson","projectGraph","target","targetName","isProduction","includeDevDependenciesInPackageJson","type","writeJsonFile","lockFile","createLockFile","writeFileSync","getLockFileName","encoding","existsSync","copyAssets","assets","input","output","glob","iterable","createAsyncIterable","next","success","on","event","code","result","close","fileName","outfile","watch"],"mappings":";;;;;;;;IAoBuBA,iBAAiB;eAAjBA;;IAgHvB,OAAiC;eAAjC;;;;QApIO;wBACwC;sBACE;8BAI1C;oBAOA;oBACmC;sBAClB;+BACY;0BAEE;AAE/B,gBAAgBA,kBACrBC,OAAiC,EACjCC,OAAwB,EACxB;IACA,MAAMC,cACJD,QAAQE,sBAAsB,CAACC,QAAQ,CAACH,QAAQI,WAAW,CAAC,CAACC,IAAI;IAEnEC,IAAAA,+BAAqB,EAACC,IAAAA,aAAO,EAACN,aAAa;IAE3C,MAAMO,oBAAoBC,iBAAiBV;IAE3C,MAAMW,cAAcC,IAAAA,iBAAW,EAC7BC,IAAAA,iCAAmB,EAACJ,mBAAmB,KAAK,EAAER,UAC9C;QACEa,OAAOC,IAAAA,iCAAmB,EAACN,mBAAmBR;IAChD;IAGF,MAAMe,kBAAkB,MAAMC,YAAYN;IAE1C,MAAMO,qBAAqBV,IAAAA,aAAO,EAACN,aAAa;IAChD,MAAMiB,kBAAkBX,IAAAA,aAAO,EAACP,QAAQK,IAAI,EAAE;IAC9C,MAAMc,kBAAkBZ,IAAAA,aAAO,EAACC,kBAAkBY,UAAU,EAAE;IAE9D,kDAAkD;IAClD,IAAIrB,QAAQsB,mBAAmB,EAAE;QAC/B,MAAMC,mBAAmBC,IAAAA,qBAAiB,EACxCvB,QAAQI,WAAW,EACnBJ,QAAQwB,YAAY,EACpB;YACEC,QAAQzB,QAAQ0B,UAAU;YAC1BrB,MAAML,QAAQK,IAAI;YAClBsB,cAAc,CAAC5B,QAAQ6B,mCAAmC;QAC5D;QAGFN,iBAAiBO,IAAI,GAAG;QAExBC,IAAAA,qBAAa,EAAC,CAAC,EAAE/B,QAAQqB,UAAU,CAAC,aAAa,CAAC,EA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A,CAAAA,WAAAA,MAAQ,CAAC,EAAE,YAAXA,KAAAA,IAAAA,SAAaW,QAAF,AAAD,KAAe;QAC1C,MAAMC,UAAU7C,IAAAA,aAAO,EAACC,kBAAkBY,UAAU,EAAE+B;QACtD,MAAM;YAAEN,SAAS,IAAI;YAAEO;QAAQ;IACjC,CAAC;AACH;AAEA,SAASpC,YAAYjB,OAAqB,EAAE;IAC1C,OAAOc,IAAAA,WAAK,EAAC,eACRd;AAEP;AAEA,SAASU,iBAAiBV,OAAiC,EAAE;IAC3D,MAAMS,oBAAoB,eAAKT;IAE/B,+DAA+D;IAC/D,IAAIA,QAAQsD,KAAK,KAAK,KAAK,EAAE;QAC3B7C,kBAAkB6C,KAAK,GAAG,IAAI;IAChC,OAAO,IAAItD,QAAQsD,KAAK,KAAK,IAAI,EAAE;QACjC7C,kBAAkB6C,KAAK,GAAG,CAAC;IAC7B,CAAC;IAED,OAAO7C;AACT;MAEA,WAAeV"}
|
|
@@ -139,6 +139,14 @@
|
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
"default": false
|
|
142
|
+
},
|
|
143
|
+
"generatePackageJson": {
|
|
144
|
+
"description": "Generate a package.json for the build output.",
|
|
145
|
+
"type": "boolean"
|
|
146
|
+
},
|
|
147
|
+
"includeDevDependenciesInPackageJson": {
|
|
148
|
+
"description": "Include devDependencies in the generated package.json.",
|
|
149
|
+
"type": "boolean"
|
|
142
150
|
}
|
|
143
151
|
},
|
|
144
152
|
"definitions": {},
|
|
@@ -91,7 +91,7 @@ async function getSettings(options, context) {
|
|
|
91
91
|
reportsDirectory: options.reportsDirectory,
|
|
92
92
|
provider: 'c8'
|
|
93
93
|
} : {};
|
|
94
|
-
const viteConfigPath = options.config ? (0,
|
|
94
|
+
const viteConfigPath = options.config ? (0, _devkit.joinPathFragments)(context.root, options.config) : findViteConfig((0, _devkit.joinPathFragments)(context.root, projectRoot));
|
|
95
95
|
const resolved = await (0, _vite.loadConfigFromFile)({
|
|
96
96
|
mode: options.mode,
|
|
97
97
|
command: 'serve'
|
|
@@ -128,8 +128,8 @@ function findViteConfig(projectRootFullPath) {
|
|
|
128
128
|
'cts'
|
|
129
129
|
];
|
|
130
130
|
for (const ext of allowsExt){
|
|
131
|
-
if ((0, _fs.existsSync)((0,
|
|
132
|
-
return (0,
|
|
131
|
+
if ((0, _fs.existsSync)((0, _devkit.joinPathFragments)(projectRootFullPath, `vite.config.${ext}`))) {
|
|
132
|
+
return (0, _devkit.joinPathFragments)(projectRootFullPath, `vite.config.${ext}`);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/test/vitest.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n logger,\n stripIndents,\n workspaceRoot,\n} from '@nx/devkit';\nimport { CoverageOptions, File, Reporter } from 'vitest';\nimport { loadConfigFromFile } from 'vite';\nimport { VitestExecutorOptions } from './schema';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/test/vitest.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n logger,\n stripIndents,\n workspaceRoot,\n} from '@nx/devkit';\nimport { CoverageOptions, File, Reporter } from 'vitest';\nimport { loadConfigFromFile } from 'vite';\nimport { VitestExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { existsSync } from 'fs';\n\nclass NxReporter implements Reporter {\n deferred: {\n promise: Promise<boolean>;\n resolve: (val: boolean) => void;\n };\n\n constructor(private watch: boolean) {\n this.setupDeferred();\n }\n\n async *[Symbol.asyncIterator]() {\n do {\n const hasErrors = await this.deferred.promise;\n yield { hasErrors };\n this.setupDeferred();\n } while (this.watch);\n }\n\n private setupDeferred() {\n let resolve: (val: boolean) => void;\n this.deferred = {\n promise: new Promise((res) => {\n resolve = res;\n }),\n resolve,\n };\n }\n\n onFinished(files: File[], errors?: unknown[]) {\n const hasErrors =\n files.some((f) => f.result?.state === 'fail') || errors?.length > 0;\n this.deferred.resolve(hasErrors);\n }\n}\n\nexport async function* vitestExecutor(\n options: VitestExecutorOptions,\n context: ExecutorContext\n) {\n const { startVitest } = await (Function(\n 'return import(\"vitest/node\")'\n )() as Promise<typeof import('vitest/node')>);\n\n const nxReporter = new NxReporter(options.watch);\n const settings = await getSettings(options, context);\n settings.reporters.push(nxReporter);\n const cliFilters = options.testFile ? [options.testFile] : [];\n\n const ctx = await startVitest(options.mode, cliFilters, settings);\n\n let hasErrors = false;\n\n const processExit = () => {\n ctx.exit();\n if (hasErrors) {\n process.exit(1);\n } else {\n process.exit(0);\n }\n };\n\n if (options.watch) {\n process.on('SIGINT', processExit);\n process.on('SIGTERM', processExit);\n process.on('exit', processExit);\n }\n\n for await (const report of nxReporter) {\n // vitest sets the exitCode = 1 when code coverage isn't met\n hasErrors =\n report.hasErrors || (process.exitCode && process.exitCode !== 0);\n }\n\n return {\n success: !hasErrors,\n };\n}\n\nasync function getSettings(\n options: VitestExecutorOptions,\n context: ExecutorContext\n) {\n const projectRoot = context.projectGraph.nodes[context.projectName].data.root;\n const offset = relative(workspaceRoot, context.cwd);\n // if reportsDirectory is not provided vitest will remove all files in the project root\n // when coverage is enabled in the vite.config.ts\n const coverage: CoverageOptions = options.reportsDirectory\n ? {\n enabled: options.coverage,\n reportsDirectory: options.reportsDirectory,\n provider: 'c8',\n }\n : ({} as CoverageOptions);\n\n const viteConfigPath = options.config\n ? joinPathFragments(context.root, options.config)\n : findViteConfig(joinPathFragments(context.root, projectRoot));\n\n const resolved = await loadConfigFromFile(\n {\n mode: options.mode,\n command: 'serve',\n },\n viteConfigPath\n );\n\n if (!viteConfigPath || !resolved?.config?.['test']) {\n logger.warn(stripIndents`Unable to load test config from config file ${\n resolved?.path ?? viteConfigPath\n }\nSome settings may not be applied as expected.\nYou can manually set the config in the project, ${\n context.projectName\n }, configuration.\n `);\n }\n\n const settings = {\n ...options,\n // when running nx from the project root, the root will get appended to the cwd.\n // creating an invalid path and no tests will be found.\n // instead if we are not at the root, let the cwd be root.\n root: offset === '' ? projectRoot : '',\n reporters: [\n ...(options.reporters ?? []),\n ...((resolved?.config?.['test']?.reporters as string[]) ?? []),\n 'default',\n ] as (string | Reporter)[],\n coverage: { ...coverage, ...resolved?.config?.['test']?.coverage },\n };\n\n return settings;\n}\n\nfunction findViteConfig(projectRootFullPath: string): string {\n const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];\n\n for (const ext of allowsExt) {\n if (\n existsSync(joinPathFragments(projectRootFullPath, `vite.config.${ext}`))\n ) {\n return joinPathFragments(projectRootFullPath, `vite.config.${ext}`);\n }\n }\n}\n\nexport default vitestExecutor;\n"],"names":["vitestExecutor","NxReporter","Symbol","asyncIterator","hasErrors","deferred","promise","setupDeferred","watch","resolve","Promise","res","onFinished","files","errors","some","f","result","state","length","constructor","options","context","startVitest","Function","nxReporter","settings","getSettings","reporters","push","cliFilters","testFile","ctx","mode","processExit","exit","process","on","report","exitCode","success","resolved","projectRoot","projectGraph","nodes","projectName","data","root","offset","relative","workspaceRoot","cwd","coverage","reportsDirectory","enabled","provider","viteConfigPath","config","joinPathFragments","findViteConfig","loadConfigFromFile","command","logger","warn","stripIndents","path","projectRootFullPath","allowsExt","ext","existsSync"],"mappings":";;;;;;;;IAgDuBA,cAAc;eAAdA;;IA+GvB,OAA8B;eAA9B;;;;wBAzJO;sBAE4B;sBAEV;oBACE;AAE3B,IAAA,AAAMC,aAAN,MAAMA;IAUJ,OAAO,CAACC,OAAOC,aAAa,CAAC,GAAG;QAC9B,GAAG;YACD,MAAMC,YAAY,MAAM,IAAI,CAACC,QAAQ,CAACC,OAAO;YAC7C,MAAM;gBAAEF;YAAU;YAClB,IAAI,CAACG,aAAa;QACpB,QAAS,IAAI,CAACC,KAAK,CAAE;IACvB;IAEQD,gBAAgB;QACtB,IAAIE;QACJ,IAAI,CAACJ,QAAQ,GAAG;YACdC,SAAS,IAAII,QAAQ,CAACC,MAAQ;gBAC5BF,U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W,KAAKN,cAAc,EAAE;QACtCd,WAAW;eACLP,CAAAA,qBAAAA,QAAQO,SAAS,YAAjBP,qBAAqB,EAAE;eACvB,CAAA,OAACoB,mBAAAA,KAAAA,IAAAA,CAAAA,oBAAAA,SAAUgB,MAAM,YAAhBhB,KAAAA,IAAAA,yBAAAA,iBAAkB,CAAC,OAAO,YAA1BA,KAAAA,0BAA4Bb,SAAZ,YAAjB,OAAuD,EAAE;YAC7D;SACD;QACDwB,UAAU,eAAKA,UAAaX,mBAAAA,KAAAA,IAAAA,CAAAA,oBAAAA,SAAUgB,MAAM,YAAhBhB,KAAAA,IAAAA,0BAAAA,iBAAkB,CAAC,OAAO,YAA1BA,KAAAA,2BAA4BW,QAAZ;;IAG9C,OAAO1B;AACT;AAEA,SAASiC,eAAeO,mBAA2B,EAAU;IAC3D,MAAMC,YAAY;QAAC;QAAM;QAAO;QAAM;QAAO;QAAO;KAAM;IAE1D,KAAK,MAAMC,OAAOD,UAAW;QAC3B,IACEE,IAAAA,cAAU,EAACX,IAAAA,yBAAiB,EAACQ,qBAAqB,CAAC,YAAY,EAAEE,IAAI,CAAC,IACtE;YACA,OAAOV,IAAAA,yBAAiB,EAACQ,qBAAqB,CAAC,YAAY,EAAEE,IAAI,CAAC;QACpE,CAAC;IACH;AACF;MAEA,WAAepE"}
|
|
@@ -418,10 +418,10 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
418
418
|
},` : ``;
|
|
419
419
|
const dtsPlugin = onlyVitest ? '' : options.includeLib ? `dts({
|
|
420
420
|
entryRoot: 'src',
|
|
421
|
-
tsConfigFilePath:
|
|
421
|
+
tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),
|
|
422
422
|
skipDiagnostics: true,
|
|
423
423
|
}),` : '';
|
|
424
|
-
const dtsImportLine = onlyVitest ? '' : options.includeLib ? `import dts from 'vite-plugin-dts';\nimport {
|
|
424
|
+
const dtsImportLine = onlyVitest ? '' : options.includeLib ? `import dts from 'vite-plugin-dts';\nimport { joinPathFragments } from '@nx/devkit';` : '';
|
|
425
425
|
let viteConfigContent = '';
|
|
426
426
|
const testOption = options.includeVitest ? `test: {
|
|
427
427
|
globals: 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 { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const coveragePath = joinPathFragments(\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n passWithNoTests: true,\n // vitest runs in the project root so we have to offset to the workspaceRoot\n reportsDirectory: joinPathFragments(\n offsetFromRoot(project.root),\n coveragePath\n ),\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: [coveragePath],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions.base = project.targets[target].options?.baseHref;\n buildOptions.sourcemap = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n https: project.targets[target].options?.https,\n hmr: project.targets[target].options?.hmr,\n open: project.targets[target].options?.open,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions.https = target.options?.https;\n previewOptions.open = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type=\"module\" src=\"${mainPath}\"></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type=\"module\" src=\"${mainPath}\"></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" href=\"/favicon.ico\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"${mainPath}\"></script>\n </body>\n </html>`\n );\n }\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = `${projectConfig.root}/vite.config.ts`;\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 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 forgot 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: [${\n options.uiFramework === 'react'\n ? \"'react', 'react-dom', 'react/jsx-runtime'\"\n : ''\n }]\n }\n },`\n : ``;\n\n const dtsPlugin = onlyVitest\n ? ''\n : options.includeLib\n ? `dts({\n entryRoot: 'src',\n tsConfigFilePath: join(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),`\n : '';\n\n const dtsImportLine = onlyVitest\n ? ''\n : options.includeLib\n ? `import dts from 'vite-plugin-dts';\\nimport { join } from 'path';`\n : '';\n\n let viteConfigContent = '';\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectConfig.root)}node_modules/.vitest'\n },\n environment: '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 },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const reactPluginImportLine =\n options.uiFramework === 'react'\n ? `import react from '@vitejs/plugin-react';`\n : '';\n\n const reactPlugin = options.uiFramework === 'react' ? `react(),` : '';\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 pluginOption = `\n plugins: [\n ${dtsPlugin}\n ${reactPlugin}\n viteTsConfigPaths({\n root: '${offsetFromRoot(projectConfig.root)}',\n }),\n ],\n `;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [\n // viteTsConfigPaths({\n // root: '${offsetFromRoot(projectConfig.root)}',\n // }),\n // ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectConfig.root\n )}node_modules/.vite/${options.project}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\n testOption,\n cacheDir,\n offsetFromRoot(projectConfig.root),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n ${reactPluginImportLine}\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n ${dtsImportLine}\n \n export default defineConfig({\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n ${pluginOption}\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigurationGeneratorSchema,\n buildOption: string,\n dtsPlugin: string,\n dtsImportLine: string,\n pluginOption: string,\n testOption: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (projectAlreadyHasViteTargets.build && projectAlreadyHasViteTargets.test) {\n return;\n }\n\n logger.info(`vite.config.ts already exists for project ${options.project}.`);\n const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external:\n options.uiFramework === 'react'\n ? ['react', 'react-dom', 'react/jsx-runtime']\n : [],\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\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 } else {\n logger.info(`\n Vite configuration file (${viteConfigPath}) has been updated with the required settings for the new target(s).\n `);\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","coveragePath","joinPathFragments","root","testOptions","passWithNoTests","reportsDirectory","offsetFromRoot","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","base","baseHref","sourcemap","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","https","hmr","open","proxyConfig","previewOptions","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","viteConfigPath","buildOption","includeLib","dtsPlugin","dtsImportLine","viteConfigContent","testOption","includeVitest","inSourceTests","defineOption","reactPluginImportLine","reactPlugin","devServerOption","previewServerOption","pluginOption","workerOption","cacheDir","handleViteConfigFileExists","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","testOptionObject","globals","cache","dir","environment","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAoCAC,sBAAsB;eAAtBA;;IA6CAC,sBAAsB;eAAtBA;;IAqDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IAmEAC,sBAAsB;eAAtBA;;IAsKAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,sBAAsB;eAAtBA;;;;wBAjuBf;qCAMmC;AAOnC,SAASZ,6BACda,OAEC,EACDC,mBAA4C,EAM5C;IACA,MAAMC,SAA0D;QAC9DC,sBAAsB,CAAC;QACvBC,oCAAoC,KAAK;QACzCC,iCAAiC,CAAC;QAClCC,yBAAyB,CAAC;IAC5B;IAEA,MAAMC,qBAAqB;QACzBC,OAAO;YACL;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,OAAO;YACL;YACA;YACA;SACD;QACDC,MAAM;YAAC;YAAiB;YAAmB;SAAuB;IACpE;IAEA,MAAMC,uBAAuB;QAC3B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,oDAAoD;IACpD,0EAA0E;IAC1E,kFAAkF;IAElF,SAASC,wBAAwBC,MAAc,EAAE;QAC/C,IAAIZ,8BAAAA,KAAAA,IAAAA,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K,CAAC,EAAEhH,eAAe,oBAAoB,CAAC;QAC9C;QACAiH,aAAa;QACbpE,SAAS;YAAC;SAAuD;IACnE;IAEA,MAAMqE,UAAUC,IAAAA,8CAAyB,EACvC7H,MACA2E,gBACAC,aACAqC,mBACAnC,WACAC,eACAU,cACAR,YACAsC,kBACA5B,UACAjB;IAGF,IAAI,CAACkD,SAAS;QACZvB,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAE3B,eAAe;;QAExF,EAAEC,YAAY;;QAEd,CAAC;IAEP,OAAO;QACLyB,cAAM,CAACW,IAAI,CAAC,CAAC;+BACc,EAAErC,eAAe;MAC1C,CAAC;IACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nx/js:babel',\n '@nx/js:swc',\n '@nx/webpack:webpack',\n '@nx/rollup:rollup',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: [\n '@nxext/vite:dev',\n '@nx/webpack:dev-server',\n '@nrwl/webpack:dev-server',\n ],\n test: ['@nx/jest:jest', '@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nx/angular:ng-packagr-lite',\n '@nx/angular:package',\n '@nx/angular:webpack-browser',\n '@nx/esbuild:esbuild',\n '@nx/react-native:run-ios',\n '@nx/react-native:start',\n '@nx/react-native:run-android',\n '@nx/react-native:bundle',\n '@nx/react-native:build-android',\n '@nx/react-native:bundle',\n '@nx/next:build',\n '@nx/next:server',\n '@nx/js:tsc',\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||=\n executorName === '@nx/vite:build' || executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||=\n executorName === '@nx/vite:dev-server' ||\n executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||=\n executorName === '@nx/vite:test' || executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||=\n executorName === '@nx/vite:preview-server' ||\n executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const coveragePath = joinPathFragments(\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n passWithNoTests: true,\n // vitest runs in the project root so we have to offset to the workspaceRoot\n reportsDirectory: joinPathFragments(\n offsetFromRoot(project.root),\n coveragePath\n ),\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: [coveragePath],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions.base = project.targets[target].options?.baseHref;\n buildOptions.sourcemap = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nx/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nx/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n https: project.targets[target].options?.https,\n hmr: project.targets[target].options?.hmr,\n open: project.targets[target].options?.open,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nx/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nx/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions.https = target.options?.https;\n previewOptions.open = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nx/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type=\"module\" src=\"${mainPath}\"></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type=\"module\" src=\"${mainPath}\"></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" href=\"/favicon.ico\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"${mainPath}\"></script>\n </body>\n </html>`\n );\n }\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = `${projectConfig.root}/vite.config.ts`;\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 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 forgot 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: [${\n options.uiFramework === 'react'\n ? \"'react', 'react-dom', 'react/jsx-runtime'\"\n : ''\n }]\n }\n },`\n : ``;\n\n const dtsPlugin = onlyVitest\n ? ''\n : options.includeLib\n ? `dts({\n entryRoot: 'src',\n tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),`\n : '';\n\n const dtsImportLine = onlyVitest\n ? ''\n : options.includeLib\n ? `import dts from 'vite-plugin-dts';\\nimport { joinPathFragments } from '@nx/devkit';`\n : '';\n\n let viteConfigContent = '';\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectConfig.root)}node_modules/.vitest'\n },\n environment: '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 },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const reactPluginImportLine =\n options.uiFramework === 'react'\n ? `import react from '@vitejs/plugin-react';`\n : '';\n\n const reactPlugin = options.uiFramework === 'react' ? `react(),` : '';\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 pluginOption = `\n plugins: [\n ${dtsPlugin}\n ${reactPlugin}\n viteTsConfigPaths({\n root: '${offsetFromRoot(projectConfig.root)}',\n }),\n ],\n `;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [\n // viteTsConfigPaths({\n // root: '${offsetFromRoot(projectConfig.root)}',\n // }),\n // ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectConfig.root\n )}node_modules/.vite/${options.project}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\n testOption,\n cacheDir,\n offsetFromRoot(projectConfig.root),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n ${reactPluginImportLine}\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n ${dtsImportLine}\n \n export default defineConfig({\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n ${pluginOption}\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) =>\n config.executor === '@nrwl/nx:build' ||\n config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nx/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nx/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nx/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nx/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigurationGeneratorSchema,\n buildOption: string,\n dtsPlugin: string,\n dtsImportLine: string,\n pluginOption: string,\n testOption: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (projectAlreadyHasViteTargets.build && projectAlreadyHasViteTargets.test) {\n return;\n }\n\n logger.info(`vite.config.ts already exists for project ${options.project}.`);\n const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external:\n options.uiFramework === 'react'\n ? ['react', 'react-dom', 'react/jsx-runtime']\n : [],\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\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 } else {\n logger.info(`\n Vite configuration file (${viteConfigPath}) has been updated with the required settings for the new target(s).\n `);\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","targets","userProvidedTargets","output","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","hasViteTargets","executorName","preview","foundTargets","tree","options","project","readProjectConfiguration","coveragePath","joinPathFragments","root","testOptions","passWithNoTests","reportsDirectory","offsetFromRoot","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","base","baseHref","sourcemap","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","https","hmr","open","proxyConfig","previewOptions","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","viteConfigPath","buildOption","includeLib","dtsPlugin","dtsImportLine","viteConfigContent","testOption","includeVitest","inSourceTests","defineOption","reactPluginImportLine","reactPlugin","devServerOption","previewServerOption","pluginOption","workerOption","cacheDir","handleViteConfigFileExists","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","testOptionObject","globals","cache","dir","environment","changed","ensureViteConfigIsCorrect"],"mappings":";;;;;;;;IAuBgBA,4BAA4B;eAA5BA;;IA8IAC,qBAAqB;eAArBA;;IAoCAC,sBAAsB;eAAtBA;;IA6CAC,sBAAsB;eAAtBA;;IAqDAC,gBAAgB;eAAhBA;;IAyCAC,YAAY;eAAZA;;IAsDAC,mBAAmB;eAAnBA;;IAkBAC,oBAAoB;eAApBA;;IAmEAC,sBAAsB;eAAtBA;;IAsKAC,mCAAmC;eAAnCA;;IAcAC,2BAA2B;eAA3BA;;IAqBMC,oCAAoC;eAApCA;;IAmEAC,sBAAsB;eAAtBA;;;;wBAjuBf;qCAMmC;AAOnC,SAASZ,6BACda,OAEC,EACDC,mBAA4C,EAM5C;IACA,MAAMC,SAA0D;QAC9DC,sBAAsB,CAAC;QACvBC,oCAAoC,KAAK;QACzCC,iCAAiC,CAAC;QAClCC,yBAAyB,CAAC;IAC5B;IAEA,MAAMC,qBAAqB;QACzBC,OAAO;YACL;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,OAAO;YACL;YACA;YACA;SACD;QACDC,MAAM;YAAC;YAAiB;YAAmB;SAA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M+G,oBAAoB;QACxBjE,KAAK;YACHkE,OAAO;YACPR,MAAMzG,QAAQC,OAAO;YACrBiH,UAAU;YACVC,SAAS;gBAAC;gBAAM;aAAM;QACxB;QACAC,eAAe;YACbC,UACErH,QAAQ6C,WAAW,KAAK,UACpB;gBAAC;gBAAS;gBAAa;aAAoB,GAC3C,EAAE;QACV;IACF;IAEA,MAAMyE,mBAAmB;QACvBC,SAAS,IAAI;QACbC,OAAO;YACLC,KAAK,CAAC,EAAEhH,eAAe,oBAAoB,CAAC;QAC9C;QACAiH,aAAa;QACbpE,SAAS;YAAC;SAAuD;IACnE;IAEA,MAAMqE,UAAUC,IAAAA,8CAAyB,EACvC7H,MACA2E,gBACAC,aACAqC,mBACAnC,WACAC,eACAU,cACAR,YACAsC,kBACA5B,UACAjB;IAGF,IAAI,CAACkD,SAAS;QACZvB,cAAM,CAACC,IAAI,CACT,CAAC,wEAAwE,EAAE3B,eAAe;;QAExF,EAAEC,YAAY;;QAEd,CAAC;IAEP,OAAO;QACLyB,cAAM,CAACW,IAAI,CAAC,CAAC;+BACc,EAAErC,eAAe;MAC1C,CAAC;IACL,CAAC;AACH"}
|
|
@@ -46,7 +46,7 @@ function normalizeViteConfigFilePath(projectRoot, configFile) {
|
|
|
46
46
|
function getViteServerProxyConfigPath(nxProxyConfig, context) {
|
|
47
47
|
if (nxProxyConfig) {
|
|
48
48
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
49
|
-
const proxyConfigPath = nxProxyConfig ? (0,
|
|
49
|
+
const proxyConfigPath = nxProxyConfig ? (0, _devkit.joinPathFragments)(context.root, nxProxyConfig) : (0, _devkit.joinPathFragments)(projectRoot, 'proxy.conf.json');
|
|
50
50
|
if ((0, _fs.existsSync)(proxyConfigPath)) {
|
|
51
51
|
return proxyConfigPath;
|
|
52
52
|
}
|
|
@@ -54,7 +54,7 @@ function getViteServerProxyConfigPath(nxProxyConfig, context) {
|
|
|
54
54
|
}
|
|
55
55
|
function getViteSharedConfig(options, clearScreen, context) {
|
|
56
56
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
57
|
-
const root = _path.relative(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
|
|
57
|
+
const root = (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
|
|
58
58
|
return {
|
|
59
59
|
mode: options.mode,
|
|
60
60
|
root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n logger,\n parseTargetString,\n readTargetOptions,\n} from '@nx/devkit';\nimport { existsSync } from 'fs';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n logger,\n parseTargetString,\n readTargetOptions,\n} from '@nx/devkit';\nimport { existsSync } from 'fs';\nimport { relative } from 'path';\nimport {\n BuildOptions,\n InlineConfig,\n PluginOption,\n PreviewOptions,\n searchForWorkspaceRoot,\n ServerOptions,\n} from 'vite';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport replaceFiles from '../../plugins/rollup-replace-files.plugin';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\n\n/**\n * Returns the path to the vite config file or undefined when not found.\n */\nexport function normalizeViteConfigFilePath(\n projectRoot: string,\n configFile?: string\n): string | undefined {\n if (configFile) {\n const normalized = joinPathFragments(configFile);\n if (!existsSync(normalized)) {\n throw new Error(\n `Could not find vite config at provided path \"${normalized}\".`\n );\n }\n return normalized;\n }\n return existsSync(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : existsSync(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\n/**\n * Returns the path to the proxy configuration file or undefined when not found.\n */\nexport function getViteServerProxyConfigPath(\n nxProxyConfig: string | undefined,\n context: ExecutorContext\n): string | undefined {\n if (nxProxyConfig) {\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n\n const proxyConfigPath = nxProxyConfig\n ? joinPathFragments(context.root, nxProxyConfig)\n : joinPathFragments(projectRoot, 'proxy.conf.json');\n\n if (existsSync(proxyConfigPath)) {\n return proxyConfigPath;\n }\n }\n}\n\n/**\n * Builds the shared options for vite.\n *\n * Most shared options are derived from the build target.\n */\nexport function getViteSharedConfig(\n options: ViteBuildExecutorOptions,\n clearScreen: boolean | undefined,\n context: ExecutorContext\n): InlineConfig {\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n\n const root = relative(\n context.cwd,\n joinPathFragments(context.root, projectRoot)\n );\n\n return {\n mode: options.mode,\n root,\n base: options.base,\n configFile: normalizeViteConfigFilePath(projectRoot, options.configFile),\n plugins: [replaceFiles(options.fileReplacements) as PluginOption],\n optimizeDeps: { force: options.force },\n clearScreen: clearScreen,\n logLevel: options.logLevel,\n };\n}\n\n/**\n * Builds the options for the vite dev server.\n */\nexport function getViteServerOptions(\n options: ViteDevServerExecutorOptions,\n context: ExecutorContext\n): ServerOptions {\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const serverOptions: ServerOptions = {\n host: options.host,\n port: options.port,\n https: options.https,\n hmr: options.hmr,\n open: options.open,\n cors: options.cors,\n fs: {\n allow: [\n searchForWorkspaceRoot(joinPathFragments(projectRoot)),\n joinPathFragments(context.root, 'node_modules/vite'),\n ],\n },\n };\n\n const proxyConfigPath = getViteServerProxyConfigPath(\n options.proxyConfig,\n context\n );\n if (proxyConfigPath) {\n logger.info(`Loading proxy configuration from: ${proxyConfigPath}`);\n serverOptions.proxy = require(proxyConfigPath);\n }\n\n return serverOptions;\n}\n\n/**\n * Builds the build options for the vite.\n */\nexport function getViteBuildOptions(\n options: ViteBuildExecutorOptions,\n context: ExecutorContext\n): BuildOptions {\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n\n return {\n outDir: relative(projectRoot, options.outputPath),\n emptyOutDir: options.emptyOutDir,\n reportCompressedSize: true,\n cssCodeSplit: true,\n target: options.target ?? 'esnext',\n commonjsOptions: {\n transformMixedEsModules: true,\n },\n sourcemap: options.sourcemap,\n minify: options.minify,\n manifest: options.manifest,\n ssrManifest: options.ssrManifest,\n ssr: options.ssr,\n watch: options.watch as BuildOptions['watch'],\n };\n}\n\n/**\n * Builds the options for the vite preview server.\n */\nexport function getVitePreviewOptions(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n): PreviewOptions {\n const serverOptions: ServerOptions = {\n host: options.host,\n port: options.port,\n https: options.https,\n open: options.open,\n };\n\n const proxyConfigPath = getViteServerProxyConfigPath(\n options.proxyConfig,\n context\n );\n if (proxyConfigPath) {\n logger.info(`Loading proxy configuration from: ${proxyConfigPath}`);\n serverOptions.proxy = require(proxyConfigPath);\n }\n\n return serverOptions;\n}\n\nexport function getNxTargetOptions(target: string, context: ExecutorContext) {\n const targetObj = parseTargetString(target, context.projectGraph);\n return readTargetOptions(targetObj, context);\n}\n"],"names":["normalizeViteConfigFilePath","getViteServerProxyConfigPath","getViteSharedConfig","getViteServerOptions","getViteBuildOptions","getVitePreviewOptions","getNxTargetOptions","projectRoot","configFile","normalized","joinPathFragments","existsSync","Error","undefined","nxProxyConfig","context","projectsConfigurations","projects","projectName","root","proxyConfigPath","options","clearScreen","relative","cwd","mode","base","plugins","replaceFiles","fileReplacements","optimizeDeps","force","logLevel","serverOptions","host","port","https","hmr","open","cors","fs","allow","searchForWorkspaceRoot","proxyConfig","logger","info","proxy","require","outDir","outputPath","emptyOutDir","reportCompressedSize","cssCodeSplit","target","commonjsOptions","transformMixedEsModules","sourcemap","minify","manifest","ssrManifest","ssr","watch","targetObj","parseTargetString","projectGraph","readTargetOptions"],"mappings":";;;;;;;;IAyBgBA,2BAA2B;eAA3BA;;IAu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;QAOzDE;IALV,OAAO;QACL2B,QAAQzB,IAAAA,cAAQ,EAAChB,aAAac,QAAQ4B,UAAU;QAChDC,aAAa7B,QAAQ6B,WAAW;QAChCC,sBAAsB,IAAI;QAC1BC,cAAc,IAAI;QAClBC,QAAQhC,CAAAA,kBAAAA,QAAQgC,MAAM,YAAdhC,kBAAkB,QAAQ;QAClCiC,iBAAiB;YACfC,yBAAyB,IAAI;QAC/B;QACAC,WAAWnC,QAAQmC,SAAS;QAC5BC,QAAQpC,QAAQoC,MAAM;QACtBC,UAAUrC,QAAQqC,QAAQ;QAC1BC,aAAatC,QAAQsC,WAAW;QAChCC,KAAKvC,QAAQuC,GAAG;QAChBC,OAAOxC,QAAQwC,KAAK;IACtB;AACF;AAKO,SAASxD,sBACdgB,OAAyC,EACzCN,OAAwB,EACR;IAChB,MAAMkB,gBAA+B;QACnCC,MAAMb,QAAQa,IAAI;QAClBC,MAAMd,QAAQc,IAAI;QAClBC,OAAOf,QAAQe,KAAK;QACpBE,MAAMjB,QAAQiB,IAAI;IACpB;IAEA,MAAMlB,kBAAkBnB,6BACtBoB,QAAQsB,WAAW,EACnB5B;IAEF,IAAIK,iBAAiB;QACnBwB,cAAM,CAACC,IAAI,CAAC,CAAC,kCAAkC,EAAEzB,gBAAgB,CAAC;QAClEa,cAAca,KAAK,GAAGC,QAAQ3B;IAChC,CAAC;IAED,OAAOa;AACT;AAEO,SAAS3B,mBAAmB+C,MAAc,EAAEtC,OAAwB,EAAE;IAC3E,MAAM+C,YAAYC,IAAAA,yBAAiB,EAACV,QAAQtC,QAAQiD,YAAY;IAChE,OAAOC,IAAAA,yBAAiB,EAACH,WAAW/C;AACtC"}
|
|
@@ -5,7 +5,7 @@ export declare const conditionalConfig = "\n /// <reference types=\"vitest\"
|
|
|
5
5
|
export declare const configNoDefineConfig = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default {\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n };\n ";
|
|
6
6
|
export declare const noBuildOptionsHasTestOption = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n ";
|
|
7
7
|
export declare const someBuildOptionsSomeTestOption = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n ";
|
|
8
|
-
export declare const hasEverything = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n import dts from 'vite-plugin-dts';\n import {
|
|
8
|
+
export declare const hasEverything = "\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n import dts from 'vite-plugin-dts';\n import { joinPathFragments } from '@nx/devkit';\n\n export default defineConfig({\n plugins: [\n dts({\n entryRoot: 'src',\n tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),\n react(),\n viteTsConfigPaths({\n root: '../../../',\n }),\n ],\n \n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'pure-libs-react-vite',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forgot 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: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n },\n \n test: {\n globals: true,\n cache: {\n dir: '../../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n });\n ";
|
|
9
9
|
export declare const buildOption = "\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forgot 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: [\"'react', 'react-dom', 'react/jsx-runtime'\"]\n }\n },";
|
|
10
10
|
export declare const buildOptionObject: {
|
|
11
11
|
lib: {
|
|
@@ -27,6 +27,6 @@ export declare const testOptionObject: {
|
|
|
27
27
|
environment: string;
|
|
28
28
|
include: string[];
|
|
29
29
|
};
|
|
30
|
-
export declare const dtsPlugin = "dts({\n entryRoot: 'src',\n tsConfigFilePath:
|
|
31
|
-
export declare const dtsImportLine = "import dts from 'vite-plugin-dts';\nimport {
|
|
30
|
+
export declare const dtsPlugin = "dts({\n entryRoot: 'src',\n tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),";
|
|
31
|
+
export declare const dtsImportLine = "import dts from 'vite-plugin-dts';\nimport { joinPathFragments } from '@nx/devkit';";
|
|
32
32
|
export declare const pluginOption: string;
|
|
@@ -201,13 +201,13 @@ const hasEverything = `
|
|
|
201
201
|
import react from '@vitejs/plugin-react';
|
|
202
202
|
import viteTsConfigPaths from 'vite-tsconfig-paths';
|
|
203
203
|
import dts from 'vite-plugin-dts';
|
|
204
|
-
import {
|
|
204
|
+
import { joinPathFragments } from '@nx/devkit';
|
|
205
205
|
|
|
206
206
|
export default defineConfig({
|
|
207
207
|
plugins: [
|
|
208
208
|
dts({
|
|
209
209
|
entryRoot: 'src',
|
|
210
|
-
tsConfigFilePath:
|
|
210
|
+
tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),
|
|
211
211
|
skipDiagnostics: true,
|
|
212
212
|
}),
|
|
213
213
|
react(),
|
|
@@ -298,10 +298,10 @@ const testOptionObject = {
|
|
|
298
298
|
};
|
|
299
299
|
const dtsPlugin = `dts({
|
|
300
300
|
entryRoot: 'src',
|
|
301
|
-
tsConfigFilePath:
|
|
301
|
+
tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),
|
|
302
302
|
skipDiagnostics: true,
|
|
303
303
|
}),`;
|
|
304
|
-
const dtsImportLine = `import dts from 'vite-plugin-dts';\nimport {
|
|
304
|
+
const dtsImportLine = `import dts from 'vite-plugin-dts';\nimport { joinPathFragments } from '@nx/devkit';`;
|
|
305
305
|
const pluginOption = `
|
|
306
306
|
plugins: [
|
|
307
307
|
${dtsPlugin}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/utils/test-files/test-vite-configs.ts"],"sourcesContent":["export const noBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const noContentDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({});\n `;\n\nexport const conditionalConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n export default defineConfig(({ command, mode, ssrBuild }) => {\n if (command === 'serve') {\n return {\n port: 4200,\n host: 'localhost',\n }\n } else {\n // command === 'build'\n return {\n my: 'option',\n }\n }\n })\n `;\n\nexport const configNoDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default {\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n };\n `;\n\nexport const noBuildOptionsHasTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptionsSomeTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const hasEverything = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n import dts from 'vite-plugin-dts';\n import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/utils/test-files/test-vite-configs.ts"],"sourcesContent":["export const noBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptions = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const noContentDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({});\n `;\n\nexport const conditionalConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n export default defineConfig(({ command, mode, ssrBuild }) => {\n if (command === 'serve') {\n return {\n port: 4200,\n host: 'localhost',\n }\n } else {\n // command === 'build'\n return {\n my: 'option',\n }\n }\n })\n `;\n\nexport const configNoDefineConfig = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default {\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n };\n `;\n\nexport const noBuildOptionsHasTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n globals: true,\n cache: {\n dir: '../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n\n });\n `;\n\nexport const someBuildOptionsSomeTestOption = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n\n export default defineConfig({\n plugins: [\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n\n test: {\n my: 'option',\n },\n\n build: {\n my: 'option',\n }\n\n });\n `;\n\nexport const hasEverything = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n import react from '@vitejs/plugin-react';\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n import dts from 'vite-plugin-dts';\n import { joinPathFragments } from '@nx/devkit';\n\n export default defineConfig({\n plugins: [\n dts({\n entryRoot: 'src',\n tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),\n react(),\n viteTsConfigPaths({\n root: '../../../',\n }),\n ],\n \n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'pure-libs-react-vite',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forgot 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: ['react', 'react-dom', 'react/jsx-runtime'],\n },\n },\n \n test: {\n globals: true,\n cache: {\n dir: '../../../node_modules/.vitest',\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },\n });\n `;\n\nexport const buildOption = `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forgot 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: [\"'react', 'react-dom', 'react/jsx-runtime'\"]\n }\n },`;\nexport const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: 'my-app',\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external: [\"'react', 'react-dom', 'react/jsx-runtime'\"],\n },\n};\n\nexport const testOption = `test: {\n globals: true,\n cache: {\n dir: '../node_modules/.vitest'\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n },`;\n\nexport const testOptionObject = {\n globals: true,\n cache: {\n dir: `../node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n};\n\nexport const dtsPlugin = `dts({\n entryRoot: 'src',\n tsConfigFilePath: joinPathFragments(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),`;\nexport const dtsImportLine = `import dts from 'vite-plugin-dts';\\nimport { joinPathFragments } from '@nx/devkit';`;\n\nexport const pluginOption = `\n plugins: [\n ${dtsPlugin}\n react(),\n viteTsConfigPaths({\n root: '../../',\n }),\n ],\n `;\n"],"names":["noBuildOptions","someBuildOptions","noContentDefineConfig","conditionalConfig","configNoDefineConfig","noBuildOptionsHasTestOption","someBuildOptionsSomeTestOption","hasEverything","buildOption","buildOptionObject","testOption","testOptionObject","dtsPlugin","dtsImportLine","pluginOption","lib","entry","name","fileName","formats","rollupOptions","external","globals","cache","dir","environment","include"],"mappings":";;;;;;;;IAAaA,cAAc;eAAdA;;IA0BAC,gBAAgB;eAAhBA;;IA8BAC,qBAAqB;eAArBA;;IASAC,iBAAiB;eAAjBA;;IAkBAC,oBAAoB;eAApBA;;IAgBAC,2BAA2B;eAA3BA;;IA0BAC,8BAA8B;eAA9BA;;IAyBAC,aAAa;eAAbA;;IAkDAC,WAAW;eAAXA;;IAkBAC,iBAAiB;eAAjBA;;IAYAC,UAAU;eAAVA;;IASAC,gBAAgB;eAAhBA;;IASAC,SAAS;eAATA;;IAKAC,aAAa;eAAbA;;IAEAC,YAAY;eAAZA;;;AA/PN,MAAMd,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;IAwB3B,CAAC;AAEE,MAAMC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4B7B,CAAC;AAEE,MAAMC,wBAAwB,CAAC;;;;;;;IAOlC,CAAC;AAEE,MAAMC,oBAAoB,CAAC;;;;;;;;;;;;;;;;IAgB9B,CAAC;AAEE,MAAMC,uBAAuB,CAAC;;;;;;;;;;;;;;IAcjC,CAAC;AAEE,MAAMC,8BAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;IAwBxC,CAAC;AAEE,MAAMC,iCAAiC,CAAC;;;;;;;;;;;;;;;;;;;;;;;IAuB3C,CAAC;AAEE,MAAMC,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgD1B,CAAC;AAEE,MAAMC,cAAc,CAAC;;;;;;;;;;;;;;;;;MAiBtB,CAAC;AACA,MAAMC,oBAAoB;IAC/BM,KAAK;QACHC,OAAO;QACPC,MAAM;QACNC,UAAU;QACVC,SAAS;Y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