@nx/vite 20.0.0 → 20.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/vite",
3
- "version": "20.0.0",
3
+ "version": "20.0.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for building and testing applications using Vite",
6
6
  "repository": {
@@ -30,11 +30,11 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nx/devkit": "20.0.0",
33
+ "@nx/devkit": "20.0.2",
34
34
  "@phenomnomnominal/tsquery": "~5.0.1",
35
35
  "@swc/helpers": "~0.5.0",
36
36
  "enquirer": "~2.3.6",
37
- "@nx/js": "20.0.0",
37
+ "@nx/js": "20.0.2",
38
38
  "tsconfig-paths": "^4.1.2",
39
39
  "minimatch": "9.0.3"
40
40
  },
@@ -15,7 +15,7 @@ function nxViteBuildCoordinationPlugin(options) {
15
15
  async function buildChangedProjects() {
16
16
  await new Promise((res)=>{
17
17
  activeBuildProcess = (0, _child_process.exec)(options.buildCommand, {
18
- windowsHide: true
18
+ windowsHide: false
19
19
  });
20
20
  activeBuildProcess.stdout.pipe(process.stdout);
21
21
  activeBuildProcess.stderr.pipe(process.stderr);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/vite/plugins/nx-vite-build-coordination.plugin.ts"],"sourcesContent":["import { type Plugin } from 'vite';\nimport { BatchFunctionRunner } from 'nx/src/command-line/watch/watch';\nimport { exec, type ChildProcess } from 'child_process';\nimport {\n daemonClient,\n type UnregisterCallback,\n} from 'nx/src/daemon/client/client';\nimport { output } from 'nx/src/utils/output';\n\nexport interface NxViteBuildCoordinationPluginOptions {\n buildCommand: string;\n}\nexport function nxViteBuildCoordinationPlugin(\n options: NxViteBuildCoordinationPluginOptions\n): Plugin {\n let activeBuildProcess: ChildProcess | undefined;\n let unregisterFileWatcher: UnregisterCallback | undefined;\n\n async function buildChangedProjects() {\n await new Promise<void>((res) => {\n activeBuildProcess = exec(options.buildCommand, {\n windowsHide: true,\n });\n activeBuildProcess.stdout.pipe(process.stdout);\n activeBuildProcess.stderr.pipe(process.stderr);\n activeBuildProcess.on('exit', () => {\n res();\n });\n activeBuildProcess.on('error', () => {\n res();\n });\n });\n activeBuildProcess = undefined;\n }\n\n function createFileWatcher() {\n const runner = new BatchFunctionRunner(() => buildChangedProjects());\n return daemonClient.registerFileWatcher(\n { watchProjects: 'all' },\n (err, { changedProjects, changedFiles }) => {\n if (err === 'closed') {\n output.error({\n title: 'Watch connection closed',\n bodyLines: [\n 'The daemon had closed the connection to this watch process.',\n 'Please restart your watch command.',\n ],\n });\n process.exit(1);\n }\n\n if (activeBuildProcess) {\n activeBuildProcess.kill(2);\n activeBuildProcess = undefined;\n }\n\n runner.enqueue(changedProjects, changedFiles);\n }\n );\n }\n\n let firstBuildStart = true;\n\n return {\n name: 'nx-vite-build-coordination-plugin',\n async buildStart() {\n if (firstBuildStart) {\n firstBuildStart = false;\n await buildChangedProjects();\n if (daemonClient.enabled()) {\n unregisterFileWatcher = await createFileWatcher();\n process.on('exit', () => unregisterFileWatcher());\n process.on('SIGINT', () => process.exit());\n } else {\n output.warn({\n title:\n 'Nx Daemon is not enabled. Projects will not be rebuilt when files change.',\n });\n }\n }\n },\n };\n}\n"],"names":["nxViteBuildCoordinationPlugin","options","activeBuildProcess","unregisterFileWatcher","buildChangedProjects","Promise","res","exec","buildCommand","windowsHide","stdout","pipe","process","stderr","on","undefined","createFileWatcher","runner","BatchFunctionRunner","daemonClient","registerFileWatcher","watchProjects","err","changedProjects","changedFiles","output","error","title","bodyLines","exit","kill","enqueue","firstBuildStart","name","buildStart","enabled","warn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";+BAYgBA;;;eAAAA;;;uBAXoB;+BACI;wBAIjC;wBACgB;A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
+ {"version":3,"sources":["../../../../packages/vite/plugins/nx-vite-build-coordination.plugin.ts"],"sourcesContent":["import { type Plugin } from 'vite';\nimport { BatchFunctionRunner } from 'nx/src/command-line/watch/watch';\nimport { exec, type ChildProcess } from 'child_process';\nimport {\n daemonClient,\n type UnregisterCallback,\n} from 'nx/src/daemon/client/client';\nimport { output } from 'nx/src/utils/output';\n\nexport interface NxViteBuildCoordinationPluginOptions {\n buildCommand: string;\n}\nexport function nxViteBuildCoordinationPlugin(\n options: NxViteBuildCoordinationPluginOptions\n): Plugin {\n let activeBuildProcess: ChildProcess | undefined;\n let unregisterFileWatcher: UnregisterCallback | undefined;\n\n async function buildChangedProjects() {\n await new Promise<void>((res) => {\n activeBuildProcess = exec(options.buildCommand, {\n windowsHide: false,\n });\n activeBuildProcess.stdout.pipe(process.stdout);\n activeBuildProcess.stderr.pipe(process.stderr);\n activeBuildProcess.on('exit', () => {\n res();\n });\n activeBuildProcess.on('error', () => {\n res();\n });\n });\n activeBuildProcess = undefined;\n }\n\n function createFileWatcher() {\n const runner = new BatchFunctionRunner(() => buildChangedProjects());\n return daemonClient.registerFileWatcher(\n { watchProjects: 'all' },\n (err, { changedProjects, changedFiles }) => {\n if (err === 'closed') {\n output.error({\n title: 'Watch connection closed',\n bodyLines: [\n 'The daemon had closed the connection to this watch process.',\n 'Please restart your watch command.',\n ],\n });\n process.exit(1);\n }\n\n if (activeBuildProcess) {\n activeBuildProcess.kill(2);\n activeBuildProcess = undefined;\n }\n\n runner.enqueue(changedProjects, changedFiles);\n }\n );\n }\n\n let firstBuildStart = true;\n\n return {\n name: 'nx-vite-build-coordination-plugin',\n async buildStart() {\n if (firstBuildStart) {\n firstBuildStart = false;\n await buildChangedProjects();\n if (daemonClient.enabled()) {\n unregisterFileWatcher = await createFileWatcher();\n process.on('exit', () => unregisterFileWatcher());\n process.on('SIGINT', () => process.exit());\n } else {\n output.warn({\n title:\n 'Nx Daemon is not enabled. Projects will not be rebuilt when files change.',\n });\n }\n }\n },\n };\n}\n"],"names":["nxViteBuildCoordinationPlugin","options","activeBuildProcess","unregisterFileWatcher","buildChangedProjects","Promise","res","exec","buildCommand","windowsHide","stdout","pipe","process","stderr","on","undefined","createFileWatcher","runner","BatchFunctionRunner","daemonClient","registerFileWatcher","watchProjects","err","changedProjects","changedFiles","output","error","title","bodyLines","exit","kill","enqueue","firstBuildStart","name","buildStart","enabled","warn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";+BAYgBA;;;eAAAA;;;uBAXoB;+BACI;wBAIjC;wBACgB;AAKhB,SAASA,8BACdC,OAA6C;IAE7C,IAAIC;IACJ,IAAIC;IAEJ,eAAeC;QACb,MAAM,IAAIC,QAAc,CAACC;YACvBJ,qBAAqBK,IAAAA,mBAAI,EAACN,QAAQO,YAAY,EAAE;gBAC9CC,aAAa;YACf;YACAP,mBAAmBQ,MAAM,CAACC,IAAI,CAACC,QAAQF,MAAM;YAC7CR,mBAAmBW,MAAM,CAACF,IAAI,CAACC,QAAQC,MAAM;YAC7CX,mBAAmBY,EAAE,CAAC,QAAQ;gBAC5BR;YACF;YACAJ,mBAAmBY,EAAE,CAAC,SAAS;gBAC7BR;YACF;QACF;QACAJ,qBAAqBa;IACvB;IAEA,SAASC;QACP,MAAMC,SAAS,IAAIC,0BAAmB,CAAC,IAAMd;QAC7C,OAAOe,oBAAY,CAACC,mBAAmB,CACrC;YAAEC,eAAe;QAAM,GACvB,CAACC,KAAK,EAAEC,eAAe,EAAEC,YAAY,EAAE;YACrC,IAAIF,QAAQ,UAAU;gBACpBG,cAAM,CAACC,KAAK,CAAC;oBACXC,OAAO;oBACPC,WAAW;wBACT;wBACA;qBACD;gBACH;gBACAhB,QAAQiB,IAAI,CAAC;YACf;YAEA,IAAI3B,oBAAoB;gBACtBA,mBAAmB4B,IAAI,CAAC;gBACxB5B,qBAAqBa;YACvB;YAEAE,OAAOc,OAAO,CAACR,iBAAiBC;QAClC;IAEJ;IAEA,IAAIQ,kBAAkB;IAEtB,OAAO;QACLC,MAAM;QACN,MAAMC;YACJ,IAAIF,iBAAiB;gBACnBA,kBAAkB;gBAClB,MAAM5B;gBACN,IAAIe,oBAAY,CAACgB,OAAO,IAAI;oBAC1BhC,wBAAwB,MAAMa;oBAC9BJ,QAAQE,EAAE,CAAC,QAAQ,IAAMX;oBACzBS,QAAQE,EAAE,CAAC,UAAU,IAAMF,QAAQiB,IAAI;gBACzC,OAAO;oBACLJ,cAAM,CAACW,IAAI,CAAC;wBACVT,OACE;oBACJ;gBACF;YACF;QACF;IACF;AACF"}
@@ -25,27 +25,27 @@ const _path = require("path");
25
25
  const _asynciterable = require("@nx/devkit/src/utils/async-iterable");
26
26
  const _executorutils = require("../../utils/executor-utils");
27
27
  async function* viteBuildExecutor(options, context) {
28
- var _resolved_config_build, _resolved_config;
28
+ var _resolved_build;
29
29
  process.env.VITE_CJS_IGNORE_WARNING = 'true';
30
30
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
31
- const { mergeConfig, build, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
31
+ const { mergeConfig, build, resolveConfig } = await (0, _executorutils.loadViteDynamicImport)();
32
32
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
33
33
  const tsConfigForBuild = (0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
34
34
  const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, options.configFile);
35
35
  const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
36
36
  const { buildOptions, otherOptions } = await getBuildExtraArgs(options);
37
- var _otherOptions_mode;
38
- const resolved = await loadConfigFromFile({
39
- mode: (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : 'production',
40
- command: 'build'
41
- }, viteConfigPath);
37
+ var _otherOptions_mode, _otherOptions_mode1;
38
+ const resolved = await resolveConfig({
39
+ configFile: viteConfigPath,
40
+ mode: (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : 'production'
41
+ }, 'build', (_otherOptions_mode1 = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode1 : 'production');
42
42
  var _joinPathFragments;
43
- const outDir = (_joinPathFragments = (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), options.outputPath)) != null ? _joinPathFragments : resolved == null ? void 0 : (_resolved_config = resolved.config) == null ? void 0 : (_resolved_config_build = _resolved_config.build) == null ? void 0 : _resolved_config_build.outDir;
44
- var _resolved_config_root;
43
+ const outDir = (_joinPathFragments = (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), options.outputPath)) != null ? _joinPathFragments : resolved == null ? void 0 : (_resolved_build = resolved.build) == null ? void 0 : _resolved_build.outDir;
44
+ var _resolved_root;
45
45
  const buildConfig = mergeConfig({
46
46
  // This should not be needed as it's going to be set in vite.config.ts
47
47
  // but leaving it here in case someone did not migrate correctly
48
- root: (_resolved_config_root = resolved.config.root) != null ? _resolved_config_root : root,
48
+ root: (_resolved_root = resolved.root) != null ? _resolved_root : root,
49
49
  configFile: viteConfigPath
50
50
  }, _extends._({
51
51
  build: _extends._({
@@ -53,11 +53,11 @@ async function* viteBuildExecutor(options, context) {
53
53
  }, buildOptions)
54
54
  }, otherOptions));
55
55
  if (!options.skipTypeCheck) {
56
- var _resolved_config_plugins;
56
+ var _resolved_plugins;
57
57
  await (0, _executorutils.validateTypes)({
58
58
  workspaceRoot: context.root,
59
59
  tsconfig: tsConfigForBuild,
60
- isVueProject: Boolean((_resolved_config_plugins = resolved.config.plugins) == null ? void 0 : _resolved_config_plugins.find((plugin)=>typeof plugin === 'object' && (plugin == null ? void 0 : plugin.name) === 'vite:vue'))
60
+ isVueProject: Boolean((_resolved_plugins = resolved.plugins) == null ? void 0 : _resolved_plugins.find((plugin)=>typeof plugin === 'object' && (plugin == null ? void 0 : plugin.name) === 'vite:vue'))
61
61
  });
62
62
  }
63
63
  const watcherOrOutput = await build(buildConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import {\n detectPackageManager,\n ExecutorContext,\n joinPathFragments,\n logger,\n offsetFromRoot,\n stripIndents,\n writeJsonFile,\n} from '@nx/devkit';\nimport {\n getProjectTsConfigPath,\n normalizeViteConfigFilePath,\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 { relative, resolve } from 'path';\nimport { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n validateTypes,\n} from '../../utils/executor-utils';\nimport { type Plugin } from 'vite';\n\nexport async function* viteBuildExecutor(\n options: Record<string, any> & ViteBuildExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, build, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const tsConfigForBuild = createBuildableTsConfig(\n projectRoot,\n options,\n context\n );\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n options.configFile\n );\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n const { buildOptions, otherOptions } = await getBuildExtraArgs(options);\n\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n joinPathFragments(offsetFromRoot(projectRoot), options.outputPath) ??\n resolved?.config?.build?.outDir;\n\n const buildConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n build: {\n outDir,\n ...buildOptions,\n },\n ...otherOptions,\n }\n );\n\n if (!options.skipTypeCheck) {\n await validateTypes({\n workspaceRoot: context.root,\n tsconfig: tsConfigForBuild,\n isVueProject: Boolean(\n resolved.config.plugins?.find(\n (plugin: Plugin) =>\n typeof plugin === 'object' && plugin?.name === 'vite:vue'\n )\n ),\n });\n }\n\n const watcherOrOutput = await build(buildConfig);\n\n const libraryPackageJson = resolve(projectRoot, 'package.json');\n const rootPackageJson = resolve(context.root, 'package.json');\n\n // Here, we want the outdir relative to the workspace root.\n // So, we calculate the relative path from the workspace root to the outdir.\n const outDirRelativeToWorkspaceRoot = outDir.replaceAll('../', '');\n const distPackageJson = resolve(\n outDirRelativeToWorkspaceRoot,\n 'package.json'\n );\n\n // Generate a package.json if option has been set.\n if (options.generatePackageJson) {\n if (context.projectGraph.nodes[context.projectName].type !== 'app') {\n logger.warn(\n stripIndents`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.\n For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks).`\n );\n }\n\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 skipOverrides: options.skipOverrides,\n skipPackageManager: options.skipPackageManager,\n }\n );\n\n builtPackageJson.type ??= 'module';\n\n writeJsonFile(\n `${outDirRelativeToWorkspaceRoot}/package.json`,\n builtPackageJson\n );\n const packageManager = detectPackageManager(context.root);\n\n const lockFile = createLockFile(\n builtPackageJson,\n context.projectGraph,\n packageManager\n );\n writeFileSync(\n `${outDirRelativeToWorkspaceRoot}/${getLockFileName(packageManager)}`,\n lockFile,\n {\n encoding: 'utf-8',\n }\n );\n }\n // For buildable libs, copy package.json if it exists.\n else if (\n options.generatePackageJson !== false &&\n !existsSync(distPackageJson) &&\n existsSync(libraryPackageJson) &&\n rootPackageJson !== libraryPackageJson\n ) {\n await copyAssets(\n {\n outputPath: outDirRelativeToWorkspaceRoot,\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 && event.result) {\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(outDirRelativeToWorkspaceRoot, fileName);\n yield { success: true, outfile };\n }\n}\n\nexport async function getBuildExtraArgs(\n options: ViteBuildExecutorOptions\n): Promise<{\n // vite BuildOptions\n buildOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const buildOptions = {};\n const buildSchemaKeys = [\n 'target',\n 'polyfillModulePreload',\n 'modulePreload',\n 'outDir',\n 'assetsDir',\n 'assetsInlineLimit',\n 'cssCodeSplit',\n 'cssTarget',\n 'cssMinify',\n 'sourcemap',\n 'minify',\n 'terserOptions',\n 'rollupOptions',\n 'commonjsOptions',\n 'dynamicImportVarsOptions',\n 'write',\n 'emptyOutDir',\n 'copyPublicDir',\n 'manifest',\n 'lib',\n 'ssr',\n 'ssrManifest',\n 'ssrEmitAssets',\n 'reportCompressedSize',\n 'chunkSizeWarningLimit',\n 'watch',\n ];\n const otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (buildSchemaKeys.includes(key)) {\n buildOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n buildOptions['watch'] = options.watch ?? undefined;\n\n return {\n buildOptions,\n otherOptions,\n };\n}\n\nexport default viteBuildExecutor;\n"],"names":["getBuildExtraArgs","viteBuildExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","build","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","tsConfigForBuild","createBuildableTsConfig","viteConfigPath","normalizeViteConfigFilePath","configFile","cwd","relative","joinPathFragments","buildOptions","otherOptions","mode","command","outDir","offsetFromRoot","outputPath","config","buildConfig","skipTypeCheck","validateTypes","workspaceRoot","tsconfig","isVueProject","Boolean","plugins","find","plugin","name","watcherOrOutput","libraryPackageJson","resolve","rootPackageJson","outDirRelativeToWorkspaceRoot","replaceAll","distPackageJson","generatePackageJson","builtPackageJson","projectGraph","nodes","type","logger","warn","stripIndents","createPackageJson","target","targetName","isProduction","includeDevDependenciesInPackageJson","skipOverrides","skipPackageManager","writeJsonFile","packageManager","detectPackageManager","lockFile","createLockFile","writeFileSync","getLockFileName","encoding","existsSync","copyAssets","assets","input","output","glob","iterable","createAsyncIterable","next","success","on","event","code","result","close","fileName","outfile","schema","extraArgs","key","Object","keys","properties","buildSchemaKeys","includes","watch","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAyQA,OAAiC;eAAjC;;IA9DsBA,iBAAiB;eAAjBA;;IA7KCC,iBAAiB;eAAj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BAApBA,kBAAsBkC,MAAM;QAC1E,MAAMW,WAAWX,CAAAA,2BAAAA,WAAAA,MAAQ,CAAC,EAAE,qBAAXA,SAAaW,QAAQ,KAAI;QAC1C,MAAMC,UAAU5C,IAAAA,aAAO,EAACE,+BAA+ByC;QACvD,MAAM;YAAEN,SAAS;YAAMO;QAAQ;IACjC;AACF;AAEO,eAAe1F,kBACpBE,OAAiC;IAMjC,yCAAyC;IACzC,MAAMyF,SAAS,MAAM,2BAAA,QAAO;IAC5B,MAAMC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC7F,SAAU;QACtC,IAAI,CAACyF,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAG3F,OAAO,CAAC2F,IAAI;QAC/B;IACF;IAEA,MAAMpE,eAAe,CAAC;IACtB,MAAMwE,kBAAkB;QACtB;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;IACD,MAAMvE,eAAe,CAAC;IACtB,KAAK,MAAMmE,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,gBAAgBC,QAAQ,CAACL,MAAM;YACjCpE,YAAY,CAACoE,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC,OAAO;YACLnE,YAAY,CAACmE,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;QAEwB3F;IAAxBuB,YAAY,CAAC,QAAQ,GAAGvB,CAAAA,iBAAAA,QAAQiG,KAAK,YAAbjG,iBAAiBkG;IAEzC,OAAO;QACL3E;QACAC;IACF;AACF;MAEA,WAAezB"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import {\n detectPackageManager,\n ExecutorContext,\n joinPathFragments,\n logger,\n offsetFromRoot,\n stripIndents,\n writeJsonFile,\n} from '@nx/devkit';\nimport {\n getProjectTsConfigPath,\n normalizeViteConfigFilePath,\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 { relative, resolve } from 'path';\nimport { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n validateTypes,\n} from '../../utils/executor-utils';\nimport { type Plugin } from 'vite';\n\nexport async function* viteBuildExecutor(\n options: Record<string, any> & ViteBuildExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, build, resolveConfig } = await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const tsConfigForBuild = createBuildableTsConfig(\n projectRoot,\n options,\n context\n );\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n options.configFile\n );\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n const { buildOptions, otherOptions } = await getBuildExtraArgs(options);\n\n const resolved = await resolveConfig(\n {\n configFile: viteConfigPath,\n mode: otherOptions?.mode ?? 'production',\n },\n 'build',\n otherOptions?.mode ?? 'production'\n );\n\n const outDir =\n joinPathFragments(offsetFromRoot(projectRoot), options.outputPath) ??\n resolved?.build?.outDir;\n\n const buildConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.root ?? root,\n configFile: viteConfigPath,\n },\n {\n build: {\n outDir,\n ...buildOptions,\n },\n ...otherOptions,\n }\n );\n\n if (!options.skipTypeCheck) {\n await validateTypes({\n workspaceRoot: context.root,\n tsconfig: tsConfigForBuild,\n isVueProject: Boolean(\n resolved.plugins?.find(\n (plugin: Plugin) =>\n typeof plugin === 'object' && plugin?.name === 'vite:vue'\n )\n ),\n });\n }\n\n const watcherOrOutput = await build(buildConfig);\n\n const libraryPackageJson = resolve(projectRoot, 'package.json');\n const rootPackageJson = resolve(context.root, 'package.json');\n\n // Here, we want the outdir relative to the workspace root.\n // So, we calculate the relative path from the workspace root to the outdir.\n const outDirRelativeToWorkspaceRoot = outDir.replaceAll('../', '');\n const distPackageJson = resolve(\n outDirRelativeToWorkspaceRoot,\n 'package.json'\n );\n\n // Generate a package.json if option has been set.\n if (options.generatePackageJson) {\n if (context.projectGraph.nodes[context.projectName].type !== 'app') {\n logger.warn(\n stripIndents`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.\n For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks).`\n );\n }\n\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 skipOverrides: options.skipOverrides,\n skipPackageManager: options.skipPackageManager,\n }\n );\n\n builtPackageJson.type ??= 'module';\n\n writeJsonFile(\n `${outDirRelativeToWorkspaceRoot}/package.json`,\n builtPackageJson\n );\n const packageManager = detectPackageManager(context.root);\n\n const lockFile = createLockFile(\n builtPackageJson,\n context.projectGraph,\n packageManager\n );\n writeFileSync(\n `${outDirRelativeToWorkspaceRoot}/${getLockFileName(packageManager)}`,\n lockFile,\n {\n encoding: 'utf-8',\n }\n );\n }\n // For buildable libs, copy package.json if it exists.\n else if (\n options.generatePackageJson !== false &&\n !existsSync(distPackageJson) &&\n existsSync(libraryPackageJson) &&\n rootPackageJson !== libraryPackageJson\n ) {\n await copyAssets(\n {\n outputPath: outDirRelativeToWorkspaceRoot,\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 && event.result) {\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(outDirRelativeToWorkspaceRoot, fileName);\n yield { success: true, outfile };\n }\n}\n\nexport async function getBuildExtraArgs(\n options: ViteBuildExecutorOptions\n): Promise<{\n // vite BuildOptions\n buildOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const buildOptions = {};\n const buildSchemaKeys = [\n 'target',\n 'polyfillModulePreload',\n 'modulePreload',\n 'outDir',\n 'assetsDir',\n 'assetsInlineLimit',\n 'cssCodeSplit',\n 'cssTarget',\n 'cssMinify',\n 'sourcemap',\n 'minify',\n 'terserOptions',\n 'rollupOptions',\n 'commonjsOptions',\n 'dynamicImportVarsOptions',\n 'write',\n 'emptyOutDir',\n 'copyPublicDir',\n 'manifest',\n 'lib',\n 'ssr',\n 'ssrManifest',\n 'ssrEmitAssets',\n 'reportCompressedSize',\n 'chunkSizeWarningLimit',\n 'watch',\n ];\n const otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (buildSchemaKeys.includes(key)) {\n buildOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n buildOptions['watch'] = options.watch ?? undefined;\n\n return {\n buildOptions,\n otherOptions,\n };\n}\n\nexport default viteBuildExecutor;\n"],"names":["getBuildExtraArgs","viteBuildExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","build","resolveConfig","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","tsConfigForBuild","createBuildableTsConfig","viteConfigPath","normalizeViteConfigFilePath","configFile","cwd","relative","joinPathFragments","buildOptions","otherOptions","mode","outDir","offsetFromRoot","outputPath","buildConfig","skipTypeCheck","validateTypes","workspaceRoot","tsconfig","isVueProject","Boolean","plugins","find","plugin","name","watcherOrOutput","libraryPackageJson","resolve","rootPackageJson","outDirRelativeToWorkspaceRoot","replaceAll","distPackageJson","generatePackageJson","builtPackageJson","projectGraph","nodes","type","logger","warn","stripIndents","createPackageJson","target","targetName","isProduction","includeDevDependenciesInPackageJson","skipOverrides","skipPackageManager","writeJsonFile","packageManager","detectPackageManager","lockFile","createLockFile","writeFileSync","getLockFileName","encoding","existsSync","copyAssets","assets","input","output","glob","iterable","createAsyncIterable","next","success","on","event","code","result","close","fileName","outfile","schema","extraArgs","key","Object","keys","properties","buildSchemaKeys","includes","watch","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAyQA,OAAiC;eAAjC;;IA9DsBA,iBAAiB;eAAjBA;;IA7KCC,iBAAiB;eAAjBA;;;;wBAtBhB;8BAIA;oBAOA;oBACmC;sBACR;+BACE;+BAK7B;AAGA,gBAAgBA,kBACrBC,OAAuD,EACvDC,OAAwB;QAoCtBC;IAlCFC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,aAAa,EAAE,GAAG,MAAMC,IAAAA,oCAAqB;IACzE,MAA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AS,MAAM,2BAAA,QAAO;IAC5B,MAAMC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC3F,SAAU;QACtC,IAAI,CAACuF,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAGzF,OAAO,CAACyF,IAAI;QAC/B;IACF;IAEA,MAAMlE,eAAe,CAAC;IACtB,MAAMsE,kBAAkB;QACtB;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;IACD,MAAMrE,eAAe,CAAC;IACtB,KAAK,MAAMiE,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,gBAAgBC,QAAQ,CAACL,MAAM;YACjClE,YAAY,CAACkE,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC,OAAO;YACLjE,YAAY,CAACiE,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;QAEwBzF;IAAxBuB,YAAY,CAAC,QAAQ,GAAGvB,CAAAA,iBAAAA,QAAQ+F,KAAK,YAAb/F,iBAAiBgG;IAEzC,OAAO;QACLzE;QACAC;IACF;AACF;MAEA,WAAezB"}
@@ -22,7 +22,7 @@ const _buildimpl = require("../build/build.impl");
22
22
  async function* viteDevServerExecutor(options, context) {
23
23
  process.env.VITE_CJS_IGNORE_WARNING = 'true';
24
24
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
25
- const { mergeConfig, createServer, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
25
+ const { mergeConfig, createServer, resolveConfig } = await (0, _executorutils.loadViteDynamicImport)();
26
26
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
27
27
  const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
28
28
  (0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
@@ -32,17 +32,17 @@ async function* viteDevServerExecutor(options, context) {
32
32
  const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
33
33
  const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
34
34
  const { serverOptions, otherOptions } = await getServerExtraArgs(options, configuration, buildOptions, otherOptionsFromBuild);
35
- var _otherOptions_mode, _ref;
36
- const resolved = await loadConfigFromFile({
37
- mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : buildTargetOptions == null ? void 0 : buildTargetOptions['mode']) != null ? _ref : 'development',
38
- command: 'serve'
39
- }, viteConfigPath);
40
- var _resolved_config_root;
35
+ var _otherOptions_mode, _ref, _otherOptions_mode1, _ref1;
36
+ const resolved = await resolveConfig({
37
+ configFile: viteConfigPath,
38
+ mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : buildTargetOptions == null ? void 0 : buildTargetOptions['mode']) != null ? _ref : 'development'
39
+ }, 'serve', (_ref1 = (_otherOptions_mode1 = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode1 : buildTargetOptions == null ? void 0 : buildTargetOptions['mode']) != null ? _ref1 : 'development');
40
+ var _resolved_root;
41
41
  // vite InlineConfig
42
42
  const serverConfig = mergeConfig({
43
43
  // This should not be needed as it's going to be set in vite.config.ts
44
44
  // but leaving it here in case someone did not migrate correctly
45
- root: (_resolved_config_root = resolved.config.root) != null ? _resolved_config_root : root,
45
+ root: (_resolved_root = resolved.root) != null ? _resolved_root : root,
46
46
  configFile: viteConfigPath
47
47
  }, _extends._({
48
48
  server: _extends._({}, await (0, _optionsutils.getViteServerOptions)(options, context), serverOptions)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n parseTargetString,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getViteServerOptions,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteDevServerExecutorOptions } from './schema';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n} from '../../utils/executor-utils';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\n\nexport async function* viteDevServerExecutor(\n options: ViteDevServerExecutorOptions,\n context: ExecutorContext\n): AsyncGenerator<{ success: boolean; baseUrl: string }> {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, createServer, loadConfigFromFile } =\n await loadViteDynamicImport();\n\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n createBuildableTsConfig(projectRoot, options, context);\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n const { serverOptions, otherOptions } = await getServerExtraArgs(\n options,\n configuration,\n buildOptions,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development',\n command: 'serve',\n },\n viteConfigPath\n );\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n server: {\n ...(await getViteServerOptions(options, context)),\n ...serverOptions,\n },\n ...otherOptions,\n }\n );\n\n try {\n const server = await createServer(serverConfig);\n await runViteDevServer(server);\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n// vite ViteDevServer\nasync function runViteDevServer(server: Record<string, any>): Promise<void> {\n await server.listen();\n\n server.printUrls();\n\n const processOnExit = async () => {\n await server.close();\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n}\n\nexport default viteDevServerExecutor;\n\nasync function getServerExtraArgs(\n options: ViteDevServerExecutorOptions,\n configuration: string | undefined,\n buildOptionsFromBuildTarget: Record<string, unknown> | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite ServerOptions\n serverOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n let serverOptions: Record<string, unknown> = {};\n const serverSchemaKeys = [\n 'hmr',\n 'warmup',\n 'watch',\n 'middlewareMode',\n 'fs',\n 'origin',\n 'preTransformRequests',\n 'sourcemapIgnoreList',\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (serverSchemaKeys.includes(key)) {\n serverOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n serverOptions = {\n ...serverOptions,\n watch: buildOptionsFromBuildTarget?.watch ?? serverOptions?.watch,\n };\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n serverOptions,\n otherOptions,\n };\n}\n"],"names":["viteDevServerExecutor","options","context","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","createServer","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","cwd","relative","joinPathFragments","createBuildableTsConfig","buildTargetOptions","getNxTargetOptions","buildTarget","configuration","parseTargetString","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","viteConfigPath","normalizeViteConfigFilePath","configFile","serverOptions","getServerExtraArgs","resolved","mode","command","serverConfig","config","server","getViteServerOptions","runViteDevServer","resolvedUrls","local","network","success","baseUrl","e","console","error","Promise","resolve","once","listen","printUrls","processOnExit","close","buildOptionsFromBuildTarget","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","serverSchemaKeys","includes","watch"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IA4HA,OAAqC;eAArC;;IAzGuBA,qBAAqB;eAArBA;;;;wBAfhB;8BAKA;+BAMA;sBACkB;2BACS;AAE3B,gBAAgBA,sBACrBC,OAAqC,EACrCC,OAAwB;IAExBC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,YAAY,EAAEC,kBAAkB,EAAE,GACrD,MAAMC,IAAAA,oCAAqB;IAE7B,MAAMC,cACJR,QAAQS,sBAAsB,CAACC,QAAQ,CAACV,QAAQW,WAAW,CAAC,CAACC,IAAI;IACnE,MAAMA,OACJJ,gBAAgB,MACZP,QAAQY,GAAG,KACXC,IAAAA,cAAQ,EAACd,QAAQa,GAAG,EAA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C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAItC,eAAe;YAGRkC;QAFTzB,gBAAgB,eACXA;YACHmC,OAAOV,CAAAA,qCAAAA,+CAAAA,4BAA6BU,KAAK,YAAlCV,qCAAsCzB,iCAAAA,cAAemC,KAAK;;QAEnEzC,eAAe,eACVA,cACCgC,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACL1B;QACAN;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n parseTargetString,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getViteServerOptions,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteDevServerExecutorOptions } from './schema';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n} from '../../utils/executor-utils';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\n\nexport async function* viteDevServerExecutor(\n options: ViteDevServerExecutorOptions,\n context: ExecutorContext\n): AsyncGenerator<{ success: boolean; baseUrl: string }> {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, createServer, resolveConfig } =\n await loadViteDynamicImport();\n\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n createBuildableTsConfig(projectRoot, options, context);\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n const { serverOptions, otherOptions } = await getServerExtraArgs(\n options,\n configuration,\n buildOptions,\n otherOptionsFromBuild\n );\n const resolved = await resolveConfig(\n {\n configFile: viteConfigPath,\n mode: otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development',\n },\n 'serve',\n otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development'\n );\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.root ?? root,\n configFile: viteConfigPath,\n },\n {\n server: {\n ...(await getViteServerOptions(options, context)),\n ...serverOptions,\n },\n ...otherOptions,\n }\n );\n\n try {\n const server = await createServer(serverConfig);\n await runViteDevServer(server);\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\n// vite ViteDevServer\nasync function runViteDevServer(server: Record<string, any>): Promise<void> {\n await server.listen();\n\n server.printUrls();\n\n const processOnExit = async () => {\n await server.close();\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n}\n\nexport default viteDevServerExecutor;\n\nasync function getServerExtraArgs(\n options: ViteDevServerExecutorOptions,\n configuration: string | undefined,\n buildOptionsFromBuildTarget: Record<string, unknown> | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite ServerOptions\n serverOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n let serverOptions: Record<string, unknown> = {};\n const serverSchemaKeys = [\n 'hmr',\n 'warmup',\n 'watch',\n 'middlewareMode',\n 'fs',\n 'origin',\n 'preTransformRequests',\n 'sourcemapIgnoreList',\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (serverSchemaKeys.includes(key)) {\n serverOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n serverOptions = {\n ...serverOptions,\n watch: buildOptionsFromBuildTarget?.watch ?? serverOptions?.watch,\n };\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n serverOptions,\n otherOptions,\n };\n}\n"],"names":["viteDevServerExecutor","options","context","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","createServer","resolveConfig","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","cwd","relative","joinPathFragments","createBuildableTsConfig","buildTargetOptions","getNxTargetOptions","buildTarget","configuration","parseTargetString","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","viteConfigPath","normalizeViteConfigFilePath","configFile","serverOptions","getServerExtraArgs","resolved","mode","serverConfig","server","getViteServerOptions","runViteDevServer","resolvedUrls","local","network","success","baseUrl","e","console","error","Promise","resolve","once","listen","printUrls","processOnExit","close","buildOptionsFromBuildTarget","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","serverSchemaKeys","includes","watch"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IA8HA,OAAqC;eAArC;;IA3GuBA,qBAAqB;eAArBA;;;;wBAfhB;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MC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC3D,SAAU;QACtC,IAAI,CAACuD,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAGzD,OAAO,CAACyD,IAAI;QAC/B;IACF;IAEA,IAAI3B,gBAAyC,CAAC;IAC9C,MAAM+B,mBAAmB;QACvB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,IAAIrC,eAAe,CAAC;IACpB,KAAK,MAAMiC,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,iBAAiBC,QAAQ,CAACL,MAAM;YAClC3B,aAAa,CAAC2B,IAAI,GAAGD,SAAS,CAACC,IAAI;QACrC,OAAO;YACLjC,YAAY,CAACiC,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAIpC,eAAe;YAGRgC;QAFTvB,gBAAgB,eACXA;YACHiC,OAAOV,CAAAA,qCAAAA,+CAAAA,4BAA6BU,KAAK,YAAlCV,qCAAsCvB,iCAAAA,cAAeiC,KAAK;;QAEnEvC,eAAe,eACVA,cACC8B,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACLxB;QACAN;IACF;AACF"}
@@ -20,10 +20,10 @@ const _path = require("path");
20
20
  const _buildimpl = require("../build/build.impl");
21
21
  const _executorutils = require("../../utils/executor-utils");
22
22
  async function* vitePreviewServerExecutor(options, context) {
23
- var _context_projectsConfigurations_projects_target_project, _resolved_config_build, _resolved_config;
23
+ var _context_projectsConfigurations_projects_target_project, _resolved_build;
24
24
  process.env.VITE_CJS_IGNORE_WARNING = 'true';
25
25
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
26
- const { mergeConfig, preview, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
26
+ const { mergeConfig, preview, resolveConfig } = await (0, _executorutils.loadViteDynamicImport)();
27
27
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
28
28
  const target = (0, _devkit.parseTargetString)(options.buildTarget, context);
29
29
  const targetConfiguration = (_context_projectsConfigurations_projects_target_project = context.projectsConfigurations.projects[target.project]) == null ? void 0 : _context_projectsConfigurations_projects_target_project.targets[target.target];
@@ -37,13 +37,13 @@ async function* vitePreviewServerExecutor(options, context) {
37
37
  const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
38
38
  const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
39
39
  const { previewOptions, otherOptions } = await getExtraArgs(options, configuration, otherOptionsFromBuild);
40
- var _otherOptions_mode, _ref;
41
- const resolved = await loadConfigFromFile({
42
- mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : otherOptionsFromBuild == null ? void 0 : otherOptionsFromBuild.mode) != null ? _ref : 'production',
43
- command: 'build'
44
- }, viteConfigPath);
45
- var _options_staticFilePath, _ref1;
46
- const outDir = (_ref1 = (_options_staticFilePath = options.staticFilePath) != null ? _options_staticFilePath : (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath)) != null ? _ref1 : resolved == null ? void 0 : (_resolved_config = resolved.config) == null ? void 0 : (_resolved_config_build = _resolved_config.build) == null ? void 0 : _resolved_config_build.outDir;
40
+ var _otherOptions_mode, _ref, _otherOptions_mode1, _ref1;
41
+ const resolved = await resolveConfig({
42
+ configFile: viteConfigPath,
43
+ mode: (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : otherOptionsFromBuild == null ? void 0 : otherOptionsFromBuild.mode) != null ? _ref : 'production'
44
+ }, 'build', (_ref1 = (_otherOptions_mode1 = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode1 : otherOptionsFromBuild == null ? void 0 : otherOptionsFromBuild.mode) != null ? _ref1 : 'production');
45
+ var _options_staticFilePath, _ref2;
46
+ const outDir = (_ref2 = (_options_staticFilePath = options.staticFilePath) != null ? _options_staticFilePath : (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath)) != null ? _ref2 : resolved == null ? void 0 : (_resolved_build = resolved.build) == null ? void 0 : _resolved_build.outDir;
47
47
  if (!outDir) {
48
48
  throw new Error(`Could not infer the "outputPath" or "outDir". It should be set in your vite.config.ts, or as a property of the "${options.buildTarget}" buildTarget or provided explicitly as a "staticFilePath" option.`);
49
49
  }
@@ -59,12 +59,12 @@ async function* vitePreviewServerExecutor(options, context) {
59
59
  }, isCustomBuildTarget ? {} : otherOptionsFromBuild, otherOptions, {
60
60
  preview: _extends._({}, (0, _optionsutils.getProxyConfig)(context, otherOptions.proxyConfig), previewOptions)
61
61
  });
62
- var _resolved_config_root;
62
+ var _resolved_root;
63
63
  // vite InlineConfig
64
64
  const serverConfig = mergeConfig({
65
65
  // This should not be needed as it's going to be set in vite.config.ts
66
66
  // but leaving it here in case someone did not migrate correctly
67
- root: (_resolved_config_root = resolved.config.root) != null ? _resolved_config_root : root,
67
+ root: (_resolved_root = resolved.root) != null ? _resolved_root : root,
68
68
  configFile: viteConfigPath
69
69
  }, _extends._({}, mergedOptions));
70
70
  if (serverConfig.mode === 'production') {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n offsetFromRoot,\n parseTargetString,\n runExecutor,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getProxyConfig,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\nimport { loadViteDynamicImport } from '../../utils/executor-utils';\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const { previewOptions, otherOptions } = await getExtraArgs(\n options,\n configuration,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n options.staticFilePath ??\n joinPathFragments(\n offsetFromRoot(projectRoot),\n buildTargetOptions.outputPath\n ) ??\n resolved?.config?.build?.outDir;\n\n if (!outDir) {\n throw new Error(\n `Could not infer the \"outputPath\" or \"outDir\". It should be set in your vite.config.ts, or as a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n build: {\n outDir,\n ...(isCustomBuildTarget ? {} : buildOptions),\n },\n ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),\n ...otherOptions,\n preview: {\n ...getProxyConfig(context, otherOptions.proxyConfig),\n ...previewOptions,\n },\n };\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n ...mergedOptions,\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n // vite PreviewServer\n let server: Record<string, any> | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: Record<string, any>): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n if (httpServer['closeAllConnections']) {\n // https://github.com/vitejs/vite/pull/14834\n // closeAllConnections was added in Node v18.2.0\n // typically is \"as http.Server\" but no reason\n // to import http just for this\n (httpServer as any).closeAllConnections();\n }\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n\nasync function getExtraArgs(\n options: VitePreviewServerExecutorOptions,\n configuration: string | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite PreviewOptions\n previewOptions: Record<string, any>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const previewOptions = {};\n const previewSchemaKeys = [\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (previewSchemaKeys.includes(key)) {\n previewOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n previewOptions,\n otherOptions,\n };\n}\n"],"names":["vitePreviewServerExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","preview","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","target","parseTargetString","buildTarget","targetConfiguration","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","configuration","viteConfigPath","normalizeViteConfigFilePath","configFile","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","previewOptions","getExtraArgs","mode","command","outDir","staticFilePath","joinPathFragments","offsetFromRoot","outputPath","config","build","cwd","relative","mergedOptions","watch","getProxyConfig","proxyConfig","serverConfig","console","warn","server","processOnExit","closeServer","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","previewSchemaKeys","includes"],"rangeMappings":";;;;;;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Q,IAAMa;IAC7B;AACF;AAEA,SAASd,YAAYF,MAA4B;IAC/C,OAAO,IAAIe,QAAQ,CAACC;QAClB,IAAI,CAAChB,QAAQ;YACXgB;QACF,OAAO;YACL,MAAM,EAAEC,UAAU,EAAE,GAAGjB;YACvB,IAAIiB,UAAU,CAAC,sBAAsB,EAAE;gBACrC,4CAA4C;gBAC5C,gDAAgD;gBAChD,8CAA8C;gBAC9C,+BAA+B;gBAC9BA,WAAmBC,mBAAmB;YACzC;YACAD,WAAWE,KAAK,CAAC,IAAMH;QACzB;IACF;AACF;MAEA,WAAevE;AAEf,eAAeoC,aACbnC,OAAyC,EACzC0B,aAAiC,EACjCgD,2BAAgE;IAMhE,yCAAyC;IACzC,MAAMC,SAAS,MAAM,2BAAA,QAAO;IAC5B,MAAMC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAAC/E,SAAU;QACtC,IAAI,CAAC2E,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAG7E,OAAO,CAAC6E,IAAI;QAC/B;IACF;IAEA,MAAM3C,iBAAiB,CAAC;IACxB,MAAM+C,oBAAoB;QACxB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,IAAIlD,eAAe,CAAC;IACpB,KAAK,MAAM8C,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,kBAAkBC,QAAQ,CAACL,MAAM;YACnC3C,cAAc,CAAC2C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACtC,OAAO;YACL9C,YAAY,CAAC8C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAInD,eAAe;QACjBK,eAAe,eACVA,cACC2C,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACLxC;QACAH;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n offsetFromRoot,\n parseTargetString,\n runExecutor,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getProxyConfig,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\nimport { loadViteDynamicImport } from '../../utils/executor-utils';\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview, resolveConfig } = await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const { previewOptions, otherOptions } = await getExtraArgs(\n options,\n configuration,\n otherOptionsFromBuild\n );\n const resolved = await resolveConfig(\n {\n configFile: viteConfigPath,\n mode: otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production',\n },\n 'build',\n otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production'\n );\n\n const outDir =\n options.staticFilePath ??\n joinPathFragments(\n offsetFromRoot(projectRoot),\n buildTargetOptions.outputPath\n ) ??\n resolved?.build?.outDir;\n\n if (!outDir) {\n throw new Error(\n `Could not infer the \"outputPath\" or \"outDir\". It should be set in your vite.config.ts, or as a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n build: {\n outDir,\n ...(isCustomBuildTarget ? {} : buildOptions),\n },\n ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),\n ...otherOptions,\n preview: {\n ...getProxyConfig(context, otherOptions.proxyConfig),\n ...previewOptions,\n },\n };\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.root ?? root,\n configFile: viteConfigPath,\n },\n {\n ...mergedOptions,\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n // vite PreviewServer\n let server: Record<string, any> | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: Record<string, any>): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n if (httpServer['closeAllConnections']) {\n // https://github.com/vitejs/vite/pull/14834\n // closeAllConnections was added in Node v18.2.0\n // typically is \"as http.Server\" but no reason\n // to import http just for this\n (httpServer as any).closeAllConnections();\n }\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n\nasync function getExtraArgs(\n options: VitePreviewServerExecutorOptions,\n configuration: string | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite PreviewOptions\n previewOptions: Record<string, any>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const previewOptions = {};\n const previewSchemaKeys = [\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (previewSchemaKeys.includes(key)) {\n previewOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n previewOptions,\n otherOptions,\n };\n}\n"],"names":["vitePreviewServerExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","preview","resolveConfig","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","target","parseTargetString","buildTarget","targetConfiguration","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","configuration","viteConfigPath","normalizeViteConfigFilePath","configFile","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","previewOptions","getExtraArgs","mode","outDir","staticFilePath","joinPathFragments","offsetFromRoot","outputPath","build","cwd","relative","mergedOptions","watch","getProxyConfig","proxyConfig","serverConfig","console","warn","server","processOnExit","closeServer","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","previewSchemaKeys","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAmMA,OAAyC;eAAzC;;IAjLuBA,yBAAyB;eAAzBA;;;;wBAZhB;8BAKA;sBAGkB;2BACS;+BACI;AAE/B,gBAAgBA,0BACrBC,OAAyC,EACzCC,OAAwB;QAStBA,yDAgDAC;IAvDFC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,aAAa,EAAE,GAAG,MAAMC,IAAAA,oCAAqB;IAC3E,MAAMC,cACJT,QAAQU,sBAAsB,CAACC,QAAQ,CAACX,QAAQY,WAAW,CAAC,CAACC,IAAI;IACnE,MAAMC,SAASC,IAAAA,yBAAiB,EAAChB,QAAQiB,WAAW,EAAEhB;IACtD,MAAMiB,uBACJjB,0DAAAA,QAAQU,sBAAsB,CAACC,QAAQ,CAACG,OAAOI,OAAO,CAAC,qBAAvDlB,wDAAyDmB,OAAO,CAC9DL,OAAOA,MAAM,CACd;IACH,IAAI,CAACG,qBAAqB;QACxB,MAAM,IAAIG,MAAM,CAAC,qBAAqB,EAAErB,QAAQiB,WAAW,CAAC,CAAC;IAC/D;IAEA,MAAMK,sBACJJ,o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BC,QAAQ,CAACL,MAAM;YACnCzC,cAAc,CAACyC,IAAI,GAAGD,SAAS,CAACC,IAAI;QACtC,OAAO;YACL5C,YAAY,CAAC4C,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;IAEA,IAAIjD,eAAe;QACjBK,eAAe,eACVA,cACCyC,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACLtC;QACAH;IACF;AACF"}
@@ -25,6 +25,7 @@ const _addplugin = require("@nx/devkit/src/utils/add-plugin");
25
25
  const _setuppathsplugin = require("../setup-paths-plugin/setup-paths-plugin");
26
26
  const _plugin = require("../../plugins/plugin");
27
27
  const _utils = require("./lib/utils");
28
+ const _addvitetempfilestogitignore = require("../../utils/add-vite-temp-files-to-gitignore");
28
29
  function updateNxJsonSettings(tree) {
29
30
  var _nxJson_namedInputs, _nxJson_plugins;
30
31
  const nxJson = (0, _devkit.readNxJson)(tree);
@@ -96,6 +97,7 @@ async function initGeneratorInternal(tree, schema) {
96
97
  }, schema.updatePackageScripts);
97
98
  }
98
99
  updateNxJsonSettings(tree);
100
+ (0, _addvitetempfilestogitignore.addViteTempFilesToGitIgnore)(tree);
99
101
  if (schema.setupPathsPlugin) {
100
102
  await (0, _setuppathsplugin.setupPathsPlugin)(tree, {
101
103
  skipFormat: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n createProjectGraphAsync,\n formatFiles,\n GeneratorCallback,\n readNxJson,\n runTasksInSerial,\n Tree,\n updateNxJson,\n} from '@nx/devkit';\nimport { addPlugin } from '@nx/devkit/src/utils/add-plugin';\n\nimport { setupPathsPlugin } from '../setup-paths-plugin/setup-paths-plugin';\nimport { createNodesV2 } from '../../plugins/plugin';\nimport { InitGeneratorSchema } from './schema';\nimport { checkDependenciesInstalled, moveToDevDependencies } from './lib/utils';\n\nexport function updateNxJsonSettings(tree: Tree) {\n const nxJson = readNxJson(tree);\n\n const productionFileSet = nxJson.namedInputs?.production;\n if (productionFileSet) {\n productionFileSet.push(\n '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',\n '!{projectRoot}/tsconfig.spec.json'\n );\n\n nxJson.namedInputs.production = Array.from(new Set(productionFileSet));\n }\n\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n nxJson.targetDefaults ??= {};\n nxJson.targetDefaults['@nx/vite:test'] ??= {};\n nxJson.targetDefaults['@nx/vite:test'].cache ??= true;\n nxJson.targetDefaults['@nx/vite:test'].inputs ??= [\n 'default',\n productionFileSet ? '^production' : '^default',\n ];\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n return initGeneratorInternal(tree, { addPlugin: false, ...schema });\n}\n\nexport async function initGeneratorInternal(\n tree: Tree,\n schema: InitGeneratorSchema\n) {\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n\n if (schema.addPlugin) {\n await addPlugin(\n tree,\n await createProjectGraphAsync(),\n '@nx/vite/plugin',\n createNodesV2,\n {\n buildTargetName: ['build', 'vite:build', 'vite-build'],\n testTargetName: ['test', 'vite:test', 'vite-test'],\n serveTargetName: ['serve', 'vite:serve', 'vite-serve'],\n previewTargetName: ['preview', 'vite:preview', 'vite-preview'],\n serveStaticTargetName: [\n 'serve-static',\n 'vite:serve-static',\n 'vite-serve-static',\n ],\n typecheckTargetName: ['typecheck', 'vite:typecheck', 'vite-typecheck'],\n },\n schema.updatePackageScripts\n );\n }\n\n updateNxJsonSettings(tree);\n\n if (schema.setupPathsPlugin) {\n await setupPathsPlugin(tree, { skipFormat: true });\n }\n\n const tasks: GeneratorCallback[] = [];\n if (!schema.skipPackageJson) {\n tasks.push(moveToDevDependencies(tree));\n tasks.push(checkDependenciesInstalled(tree, schema));\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default initGenerator;\n"],"names":["initGenerator","initGeneratorInternal","updateNxJsonSettings","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","addPlugin","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","createProjectGraphAsync","createNodesV2","buildTargetName","testTargetName","serveTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","updatePackageScripts","setupPathsPlugin","skipFormat","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","formatFiles","runTasksInSerial"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAuGA,OAA6B;eAA7B;;IAvDgBA,aAAa;eAAbA;;IAIMC,qBAAqB;eAArBA;;IApCNC,oBAAoB;eAApBA;;;;wBART;2BACmB;kCAEO;wBACH;uBAEoC;AAE3D,SAASA,qBAAqBC,IAAU;QAGnBC,qBAURA;IAZlB,MAAMA,SAASC,IAAAA,kBAAU,EAACF;IAE1B,MAAMG,qBAAoBF,sBAAAA,OAAOG,WAAW,qBAAlBH,oBAAoBI,UAAU;IACxD,IAAIF,mBAAmB;QACrBA,kBAAkBG,IAAI,CACpB,yDACA;QAGFL,OAAOG,WAAW,CAACC,UAAU,GAAGE,MAAMC,IAAI,CAAC,IAAIC,IAAIN;IACrD;IAEA,MAAMO,aAAYT,kBAAAA,OAAOU,OAAO,qBAAdV,gBAAgBW,IAAI,CAAC,CAACC,IACtC,OAAOA,MAAM,WACTA,MAAM,oBACNA,EAAEC,MAAM,KAAK;IAGnB,IAAI,CAACJ,WAAW;YACdT,S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AOgB,gBAAgB,EAAE;QAC3B,MAAMA,IAAAA,kCAAgB,EAACnC,MAAM;YAAEoC,YAAY;QAAK;IAClD;IAEA,MAAMC,QAA6B,EAAE;IACrC,IAAI,CAAClB,OAAOmB,eAAe,EAAE;QAC3BD,MAAM/B,IAAI,CAACiC,IAAAA,4BAAqB,EAACvC;QACjCqC,MAAM/B,IAAI,CAACkC,IAAAA,iCAA0B,EAACxC,MAAMmB;IAC9C;IAEA,IAAI,CAACA,OAAOiB,UAAU,EAAE;QACtB,MAAMK,IAAAA,mBAAW,EAACzC;IACpB;IAEA,OAAO0C,IAAAA,wBAAgB,KAAIL;AAC7B;MAEA,WAAexC"}
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n createProjectGraphAsync,\n formatFiles,\n GeneratorCallback,\n readNxJson,\n runTasksInSerial,\n Tree,\n updateNxJson,\n} from '@nx/devkit';\nimport { addPlugin } from '@nx/devkit/src/utils/add-plugin';\n\nimport { setupPathsPlugin } from '../setup-paths-plugin/setup-paths-plugin';\nimport { createNodesV2 } from '../../plugins/plugin';\nimport { InitGeneratorSchema } from './schema';\nimport { checkDependenciesInstalled, moveToDevDependencies } from './lib/utils';\nimport { addViteTempFilesToGitIgnore } from '../../utils/add-vite-temp-files-to-gitignore';\n\nexport function updateNxJsonSettings(tree: Tree) {\n const nxJson = readNxJson(tree);\n\n const productionFileSet = nxJson.namedInputs?.production;\n if (productionFileSet) {\n productionFileSet.push(\n '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',\n '!{projectRoot}/tsconfig.spec.json'\n );\n\n nxJson.namedInputs.production = Array.from(new Set(productionFileSet));\n }\n\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n nxJson.targetDefaults ??= {};\n nxJson.targetDefaults['@nx/vite:test'] ??= {};\n nxJson.targetDefaults['@nx/vite:test'].cache ??= true;\n nxJson.targetDefaults['@nx/vite:test'].inputs ??= [\n 'default',\n productionFileSet ? '^production' : '^default',\n ];\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n return initGeneratorInternal(tree, { addPlugin: false, ...schema });\n}\n\nexport async function initGeneratorInternal(\n tree: Tree,\n schema: InitGeneratorSchema\n) {\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n\n if (schema.addPlugin) {\n await addPlugin(\n tree,\n await createProjectGraphAsync(),\n '@nx/vite/plugin',\n createNodesV2,\n {\n buildTargetName: ['build', 'vite:build', 'vite-build'],\n testTargetName: ['test', 'vite:test', 'vite-test'],\n serveTargetName: ['serve', 'vite:serve', 'vite-serve'],\n previewTargetName: ['preview', 'vite:preview', 'vite-preview'],\n serveStaticTargetName: [\n 'serve-static',\n 'vite:serve-static',\n 'vite-serve-static',\n ],\n typecheckTargetName: ['typecheck', 'vite:typecheck', 'vite-typecheck'],\n },\n schema.updatePackageScripts\n );\n }\n\n updateNxJsonSettings(tree);\n addViteTempFilesToGitIgnore(tree);\n\n if (schema.setupPathsPlugin) {\n await setupPathsPlugin(tree, { skipFormat: true });\n }\n\n const tasks: GeneratorCallback[] = [];\n if (!schema.skipPackageJson) {\n tasks.push(moveToDevDependencies(tree));\n tasks.push(checkDependenciesInstalled(tree, schema));\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default initGenerator;\n"],"names":["initGenerator","initGeneratorInternal","updateNxJsonSettings","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","addPlugin","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","createProjectGraphAsync","createNodesV2","buildTargetName","testTargetName","serveTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","updatePackageScripts","addViteTempFilesToGitIgnore","setupPathsPlugin","skipFormat","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","formatFiles","runTasksInSerial"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAyGA,OAA6B;eAA7B;;IAxDgBA,aAAa;eAAbA;;IAIMC,qBAAqB;eAArBA;;IApCNC,oBAAoB;eAApBA;;;;wBATT;2BACmB;kCAEO;wBACH;uBAEoC;6CACtB;AAErC,SAASA,qBAAqBC,IAAU;QAGnBC,qBAURA;IAZlB,MAAMA,SAASC,IAAAA,kBAAU,EAACF;IAE1B,MAAMG,qBAAoBF,sBAAAA,OAAOG,WAAW,qBAAlBH,oBAAoBI,UAAU;IACxD,IAAIF,mBAAmB;QACrBA,kBAAkBG,IAAI,CACpB,yDACA;QAGFL,OAAOG,WAAW,CAACC,UAAU,GAAGE,MAAMC,IAAI,CAAC,IAAIC,IAAIN;IACrD;IAEA,MAAMO,aAAYT,kBAAAA,OAAOU,OAAO,qBAAdV,gBAAgBW,IAAI,CAAC,CAACC,IACtC,OAAOA,MAAM,WACTA,MAAM,oBACNA,EAAEC,MAAM,KAAK;IAGnB,IAAI,CAACJ,WAAW;YACdT,SACAA,wBAAsB,aACtBA,mCACAA;;QAHAA,oBAAAA,UAAAA,QAAOc,4CAAPd,QAAOc,iBAAmB,CAAC;;QAC3Bd,MAAAA,yBAAAA,OAAOc,cAAc,CAAA,CAAC,cAAA,gBAAgB,gBAAtCd,sBAAqB,CAAC,YAAgB,GAAK,CAAC;;QAC5CA,WAAAA,oCAAAA,OAAOc,cAAc,CAAC,gBAAgB,EAACC,0BAAvCf,kCAAuCe,QAAU;;QACjDf,Y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C,MAAMmB;IAC9C;IAEA,IAAI,CAACA,OAAOkB,UAAU,EAAE;QACtB,MAAMK,IAAAA,mBAAW,EAAC1C;IACpB;IAEA,OAAO2C,IAAAA,wBAAgB,KAAIL;AAC7B;MAEA,WAAezC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function addViteTempFilesToGitIgnore(tree: Tree): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "default", {
3
+ enumerable: true,
4
+ get: function() {
5
+ return addViteTempFilesToGitIgnore;
6
+ }
7
+ });
8
+ const _addvitetempfilestogitignore = require("../../utils/add-vite-temp-files-to-gitignore");
9
+ function addViteTempFilesToGitIgnore(tree) {
10
+ (0, _addvitetempfilestogitignore.addViteTempFilesToGitIgnore)(tree);
11
+ }
12
+
13
+ //# sourceMappingURL=add-vite-temp-files-to-git-ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../packages/vite/src/migrations/update-20-0-2/add-vite-temp-files-to-git-ignore.ts"],"sourcesContent":["import { Tree } from '@nx/devkit';\nimport { addViteTempFilesToGitIgnore as _addViteTempFilesToGitIgnore } from '../../utils/add-vite-temp-files-to-gitignore';\n\nexport default function addViteTempFilesToGitIgnore(tree: Tree) {\n _addViteTempFilesToGitIgnore(tree);\n}\n"],"names":["addViteTempFilesToGitIgnore","tree","_addViteTempFilesToGitIgnore"],"rangeMappings":";;;;;;;;;;","mappings":";+BAGA;;;eAAwBA;;;6CAFoD;AAE7D,SAASA,4BAA4BC,IAAU;IAC5DC,IAAAA,wDAA4B,EAACD;AAC/B"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function addViteTempFilesToGitIgnore(tree: Tree): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "addViteTempFilesToGitIgnore", {
3
+ enumerable: true,
4
+ get: function() {
5
+ return addViteTempFilesToGitIgnore;
6
+ }
7
+ });
8
+ const _devkit = require("@nx/devkit");
9
+ function addViteTempFilesToGitIgnore(tree) {
10
+ let newGitIgnoreContents = `**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*`;
11
+ if (tree.exists('.gitignore')) {
12
+ const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
13
+ if (!gitIgnoreContents.includes(newGitIgnoreContents)) {
14
+ newGitIgnoreContents = (0, _devkit.stripIndents)`${gitIgnoreContents}
15
+ ${newGitIgnoreContents}`;
16
+ tree.write('.gitignore', newGitIgnoreContents);
17
+ }
18
+ } else {
19
+ tree.write('.gitignore', newGitIgnoreContents);
20
+ }
21
+ }
22
+
23
+ //# sourceMappingURL=add-vite-temp-files-to-gitignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/vite/src/utils/add-vite-temp-files-to-gitignore.ts"],"sourcesContent":["import { stripIndents, Tree } from '@nx/devkit';\n\nexport function addViteTempFilesToGitIgnore(tree: Tree) {\n let newGitIgnoreContents = `**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*`;\n if (tree.exists('.gitignore')) {\n const gitIgnoreContents = tree.read('.gitignore', 'utf-8');\n if (!gitIgnoreContents.includes(newGitIgnoreContents)) {\n newGitIgnoreContents = stripIndents`${gitIgnoreContents}\n ${newGitIgnoreContents}`;\n\n tree.write('.gitignore', newGitIgnoreContents);\n }\n } else {\n tree.write('.gitignore', newGitIgnoreContents);\n }\n}\n"],"names":["addViteTempFilesToGitIgnore","tree","newGitIgnoreContents","exists","gitIgnoreContents","read","includes","stripIndents","write"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";+BAEgBA;;;eAAAA;;;wBAFmB;AAE5B,SAASA,4BAA4BC,IAAU;IACpD,IAAIC,uBAAuB,CAAC,iDAAiD,CAAC;IAC9E,IAAID,KAAKE,MAAM,CAAC,eAAe;QAC7B,MAAMC,oBAAoBH,KAAKI,IAAI,CAAC,cAAc;QAClD,IAAI,CAACD,kBAAkBE,QAAQ,CAACJ,uBAAuB;YACrDA,uBAAuBK,IAAAA,oBAAY,CAAA,CAAC,EAAEH,kBAAkB;QACtD,EAAEF,qBAAqB,CAAC;YAE1BD,KAAKO,KAAK,CAAC,cAAcN;QAC3B;IACF,OAAO;QACLD,KAAKO,KAAK,CAAC,cAAcN;IAC3B;AACF"}
@@ -41,7 +41,7 @@ async function validateTypes(opts) {
41
41
  const cp = (0, _nodechild_process.execSync)(`${pm.exec} vue-tsc --noEmit -p ${opts.tsconfig} --composite false`, {
42
42
  cwd: opts.workspaceRoot,
43
43
  stdio: 'inherit',
44
- windowsHide: true
44
+ windowsHide: false
45
45
  });
46
46
  }
47
47
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"sourcesContent":["import { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ExecutorContext, getPackageManagerCommand } from '@nx/devkit';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport {\n calculateProjectBuildableDependencies,\n createTmpTsConfig,\n} from '@nx/js/src/utils/buildable-libs-utils';\nimport { getProjectTsConfigPath } from './options-utils';\nimport { execSync } from 'node:child_process';\nimport { printDiagnostics, runTypeCheck } from '@nx/js';\nimport { join } from 'path';\n\nexport async function validateTypes(opts: {\n workspaceRoot: string;\n tsconfig: string;\n isVueProject?: boolean;\n}): Promise<void> {\n if (!opts.isVueProject) {\n const result = await runTypeCheck({\n workspaceRoot: opts.workspaceRoot,\n tsConfigPath: opts.tsconfig.startsWith(opts.workspaceRoot)\n ? opts.tsconfig\n : join(opts.workspaceRoot, opts.tsconfig),\n mode: 'noEmit',\n });\n\n await printDiagnostics(result.errors, result.warnings);\n\n if (result.errors.length > 0) {\n throw new Error('Found type errors. See above.');\n }\n } else {\n const pm = getPackageManagerCommand();\n const cp = execSync(\n `${pm.exec} vue-tsc --noEmit -p ${opts.tsconfig} --composite false`,\n {\n cwd: opts.workspaceRoot,\n stdio: 'inherit',\n windowsHide: true,\n }\n );\n }\n}\n\nexport function createBuildableTsConfig(\n projectRoot: string,\n options: { tsConfig?: string; buildLibsFromSource?: boolean },\n context: ExecutorContext\n) {\n const tsConfig = options.tsConfig ?? getProjectTsConfigPath(projectRoot);\n options['buildLibsFromSource'] ??= true;\n\n if (!options['buildLibsFromSource']) {\n const { dependencies } = calculateProjectBuildableDependencies(\n context.taskGraph,\n context.projectGraph,\n context.root,\n context.projectName,\n // When using incremental building and the serve target is called\n // we need to get the deps for the 'build' target instead.\n context.targetName === 'serve' ? 'build' : context.targetName,\n context.configurationName\n );\n // This tsconfig is used via the Vite ts paths plugin.\n // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).\n const tmpTsConfigPath = createTmpTsConfig(\n tsConfig,\n context.root,\n projectRoot,\n dependencies\n );\n process.env.NX_TSCONFIG_PATH = tmpTsConfigPath;\n return tmpTsConfigPath;\n }\n return tsConfig;\n}\n\nexport function loadViteDynamicImport() {\n return Function('return import(\"vite\")')() as Promise<typeof import('vite')>;\n}\n\nexport function loadVitestDynamicImport() {\n return Function('return import(\"vitest/node\")')() as Promise<\n typeof import('vitest/node')\n >;\n}\n"],"names":["createBuildableTsConfig","loadViteDynamicImport","loadVitestDynamicImport","validateTypes","opts","isVueProject","result","runTypeCheck","workspaceRoot","tsConfigPath","tsconfig","startsWith","join","mode","printDiagnostics","errors","warnings","length","Error","pm","getPackageManagerCommand","cp","execSync","exec","cwd","stdio","windowsHide","projectRoot","options","context","tsConfig","getProjectTsConfigPath","dependencies","calculateProjectBuildableDependencies","taskGraph","projectGraph","root","projectName","targetName","configurationName","tmpTsConfigPath","createTmpTsConfig","process","env","NX_TSCONFIG_PATH","Function"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IA4CgBA,uBAAuB;eAAvBA;;IAiCAC,qBAAqB;eAArBA;;IAIAC,uBAAuB;eAAvBA;;IArEMC,aAAa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;QAC1DR,QAAQS,UAAU,KAAK,UAAU,UAAUT,QAAQS,UAAU,EAC7DT,QAAQU,iBAAiB;QAE3B,sDAAsD;QACtD,qGAAqG;QACrG,MAAMC,kBAAkBC,IAAAA,qCAAiB,EACvCX,UACAD,QAAQO,IAAI,EACZT,aACAK;QAEFU,QAAQC,GAAG,CAACC,gBAAgB,GAAGJ;QAC/B,OAAOA;IACT;IACA,OAAOV;AACT;AAEO,SAAS7B;IACd,OAAO4C,SAAS;AAClB;AAEO,SAAS3C;IACd,OAAO2C,SAAS;AAGlB"}
1
+ {"version":3,"sources":["../../../../../packages/vite/src/utils/executor-utils.ts"],"sourcesContent":["import { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ExecutorContext, getPackageManagerCommand } from '@nx/devkit';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport {\n calculateProjectBuildableDependencies,\n createTmpTsConfig,\n} from '@nx/js/src/utils/buildable-libs-utils';\nimport { getProjectTsConfigPath } from './options-utils';\nimport { execSync } from 'node:child_process';\nimport { printDiagnostics, runTypeCheck } from '@nx/js';\nimport { join } from 'path';\n\nexport async function validateTypes(opts: {\n workspaceRoot: string;\n tsconfig: string;\n isVueProject?: boolean;\n}): Promise<void> {\n if (!opts.isVueProject) {\n const result = await runTypeCheck({\n workspaceRoot: opts.workspaceRoot,\n tsConfigPath: opts.tsconfig.startsWith(opts.workspaceRoot)\n ? opts.tsconfig\n : join(opts.workspaceRoot, opts.tsconfig),\n mode: 'noEmit',\n });\n\n await printDiagnostics(result.errors, result.warnings);\n\n if (result.errors.length > 0) {\n throw new Error('Found type errors. See above.');\n }\n } else {\n const pm = getPackageManagerCommand();\n const cp = execSync(\n `${pm.exec} vue-tsc --noEmit -p ${opts.tsconfig} --composite false`,\n {\n cwd: opts.workspaceRoot,\n stdio: 'inherit',\n windowsHide: false,\n }\n );\n }\n}\n\nexport function createBuildableTsConfig(\n projectRoot: string,\n options: { tsConfig?: string; buildLibsFromSource?: boolean },\n context: ExecutorContext\n) {\n const tsConfig = options.tsConfig ?? getProjectTsConfigPath(projectRoot);\n options['buildLibsFromSource'] ??= true;\n\n if (!options['buildLibsFromSource']) {\n const { dependencies } = calculateProjectBuildableDependencies(\n context.taskGraph,\n context.projectGraph,\n context.root,\n context.projectName,\n // When using incremental building and the serve target is called\n // we need to get the deps for the 'build' target instead.\n context.targetName === 'serve' ? 'build' : context.targetName,\n context.configurationName\n );\n // This tsconfig is used via the Vite ts paths plugin.\n // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).\n const tmpTsConfigPath = createTmpTsConfig(\n tsConfig,\n context.root,\n projectRoot,\n dependencies\n );\n process.env.NX_TSCONFIG_PATH = tmpTsConfigPath;\n return tmpTsConfigPath;\n }\n return tsConfig;\n}\n\nexport function loadViteDynamicImport() {\n return Function('return import(\"vite\")')() as Promise<typeof import('vite')>;\n}\n\nexport function loadVitestDynamicImport() {\n return Function('return import(\"vitest/node\")')() as Promise<\n typeof import('vitest/node')\n >;\n}\n"],"names":["createBuildableTsConfig","loadViteDynamicImport","loadVitestDynamicImport","validateTypes","opts","isVueProject","result","runTypeCheck","workspaceRoot","tsConfigPath","tsconfig","startsWith","join","mode","printDiagnostics","errors","warnings","length","Error","pm","getPackageManagerCommand","cp","execSync","exec","cwd","stdio","windowsHide","projectRoot","options","context","tsConfig","getProjectTsConfigPath","dependencies","calculateProjectBuildableDependencies","taskGraph","projectGraph","root","projectName","targetName","configurationName","tmpTsConfigPath","createTmpTsConfig","process","env","NX_TSCONFIG_PATH","Function"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IA4CgBA,uBAAuB;eAAvBA;;IAiCAC,qBAAqB;eAArBA;;IAIAC,uBAAuB;eAAvBA;;IArEMC,aAAa;eAAbA;;;wBAXoC;oCAKnD;8BACgC;mCACd;oBACsB;sBAC1B;AAEd,eAAeA,cAAcC,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