@nx/vite 21.3.7 → 21.4.0-beta.1

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.
Files changed (222) hide show
  1. package/executors.d.ts +1 -0
  2. package/executors.d.ts.map +1 -0
  3. package/executors.js +10 -26
  4. package/index.d.ts +1 -0
  5. package/index.d.ts.map +1 -0
  6. package/index.js +12 -26
  7. package/package.json +7 -4
  8. package/plugin.d.ts +1 -0
  9. package/plugin.d.ts.map +1 -0
  10. package/plugin.js +6 -23
  11. package/plugins/nx-copy-assets.plugin.d.ts +1 -0
  12. package/plugins/nx-copy-assets.plugin.d.ts.map +1 -0
  13. package/plugins/nx-copy-assets.plugin.js +28 -30
  14. package/plugins/nx-tsconfig-paths.plugin.d.ts +1 -0
  15. package/plugins/nx-tsconfig-paths.plugin.d.ts.map +1 -0
  16. package/plugins/nx-tsconfig-paths.plugin.js +86 -88
  17. package/plugins/nx-vite-build-coordination.plugin.d.ts +1 -0
  18. package/plugins/nx-vite-build-coordination.plugin.d.ts.map +1 -0
  19. package/plugins/nx-vite-build-coordination.plugin.js +25 -32
  20. package/plugins/rollup-replace-files.plugin.d.ts +1 -0
  21. package/plugins/rollup-replace-files.plugin.d.ts.map +1 -0
  22. package/plugins/rollup-replace-files.plugin.js +20 -26
  23. package/project.json +52 -0
  24. package/src/executors/build/build.impl.d.ts +1 -0
  25. package/src/executors/build/build.impl.d.ts.map +1 -0
  26. package/src/executors/build/build.impl.js +98 -112
  27. package/src/executors/build/compat.d.ts +1 -0
  28. package/src/executors/build/compat.d.ts.map +1 -0
  29. package/src/executors/build/compat.js +4 -11
  30. package/src/executors/dev-server/compat.d.ts +1 -0
  31. package/src/executors/dev-server/compat.d.ts.map +1 -0
  32. package/src/executors/dev-server/compat.js +4 -11
  33. package/src/executors/dev-server/dev-server.impl.d.ts +1 -0
  34. package/src/executors/dev-server/dev-server.impl.d.ts.map +1 -0
  35. package/src/executors/dev-server/dev-server.impl.js +54 -62
  36. package/src/executors/preview-server/compat.d.ts +1 -0
  37. package/src/executors/preview-server/compat.d.ts.map +1 -0
  38. package/src/executors/preview-server/compat.js +4 -11
  39. package/src/executors/preview-server/preview-server.impl.d.ts +1 -0
  40. package/src/executors/preview-server/preview-server.impl.d.ts.map +1 -0
  41. package/src/executors/preview-server/preview-server.impl.js +74 -77
  42. package/src/executors/test/compat.d.ts +1 -0
  43. package/src/executors/test/compat.d.ts.map +1 -0
  44. package/src/executors/test/compat.js +4 -11
  45. package/src/executors/test/lib/nx-reporter.d.ts +1 -0
  46. package/src/executors/test/lib/nx-reporter.d.ts.map +1 -0
  47. package/src/executors/test/lib/nx-reporter.js +17 -25
  48. package/src/executors/test/lib/utils.d.ts +1 -0
  49. package/src/executors/test/lib/utils.d.ts.map +1 -0
  50. package/src/executors/test/lib/utils.js +36 -59
  51. package/src/executors/test/vitest.impl.d.ts +1 -0
  52. package/src/executors/test/vitest.impl.d.ts.map +1 -0
  53. package/src/executors/test/vitest.impl.js +29 -43
  54. package/src/generators/configuration/configuration.d.ts +1 -0
  55. package/src/generators/configuration/configuration.d.ts.map +1 -0
  56. package/src/generators/configuration/configuration.js +82 -102
  57. package/src/generators/configuration/lib/convert-non-vite.d.ts +1 -0
  58. package/src/generators/configuration/lib/convert-non-vite.d.ts.map +1 -0
  59. package/src/generators/configuration/lib/convert-non-vite.js +33 -32
  60. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +1 -0
  61. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -0
  62. package/src/generators/convert-to-inferred/convert-to-inferred.js +31 -61
  63. package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts +1 -0
  64. package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts.map +1 -0
  65. package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js +46 -58
  66. package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts +1 -0
  67. package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts.map +1 -0
  68. package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.js +9 -14
  69. package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts +1 -0
  70. package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts.map +1 -0
  71. package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.js +10 -15
  72. package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts +1 -0
  73. package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts.map +1 -0
  74. package/src/generators/convert-to-inferred/lib/test-post-target-transformer.js +16 -23
  75. package/src/generators/convert-to-inferred/lib/utils.d.ts +1 -0
  76. package/src/generators/convert-to-inferred/lib/utils.d.ts.map +1 -0
  77. package/src/generators/convert-to-inferred/lib/utils.js +18 -33
  78. package/src/generators/init/init.d.ts +1 -0
  79. package/src/generators/init/init.d.ts.map +1 -0
  80. package/src/generators/init/init.js +44 -96
  81. package/src/generators/init/lib/utils.d.ts +1 -0
  82. package/src/generators/init/lib/utils.d.ts.map +1 -0
  83. package/src/generators/init/lib/utils.js +20 -35
  84. package/src/generators/setup-paths-plugin/lib/utils.d.ts +1 -0
  85. package/src/generators/setup-paths-plugin/lib/utils.d.ts.map +1 -0
  86. package/src/generators/setup-paths-plugin/lib/utils.js +0 -3
  87. package/src/generators/setup-paths-plugin/setup-paths-plugin.d.ts +1 -0
  88. package/src/generators/setup-paths-plugin/setup-paths-plugin.d.ts.map +1 -0
  89. package/src/generators/setup-paths-plugin/setup-paths-plugin.js +45 -54
  90. package/src/generators/vitest/vitest-generator.d.ts +1 -0
  91. package/src/generators/vitest/vitest-generator.d.ts.map +1 -0
  92. package/src/generators/vitest/vitest-generator.js +134 -174
  93. package/src/migrations/update-19-6-0/add-depends-on-for-preview.d.ts +1 -0
  94. package/src/migrations/update-19-6-0/add-depends-on-for-preview.d.ts.map +1 -0
  95. package/src/migrations/update-19-6-0/add-depends-on-for-preview.js +10 -18
  96. package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.d.ts +1 -0
  97. package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.d.ts.map +1 -0
  98. package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.js +4 -10
  99. package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.d.ts +1 -0
  100. package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.d.ts.map +1 -0
  101. package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.js +4 -10
  102. package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.d.ts +1 -0
  103. package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.d.ts.map +1 -0
  104. package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.js +20 -24
  105. package/src/migrations/update-20-5-0/install-jiti.d.ts +1 -0
  106. package/src/migrations/update-20-5-0/install-jiti.d.ts.map +1 -0
  107. package/src/migrations/update-20-5-0/install-jiti.js +6 -12
  108. package/src/migrations/update-20-5-0/update-resolve-conditions.d.ts +1 -0
  109. package/src/migrations/update-20-5-0/update-resolve-conditions.d.ts.map +1 -0
  110. package/src/migrations/update-20-5-0/update-resolve-conditions.js +26 -28
  111. package/src/plugins/plugin.d.ts +1 -0
  112. package/src/plugins/plugin.d.ts.map +1 -0
  113. package/src/plugins/plugin.js +189 -267
  114. package/src/utils/detect-ui-framework.d.ts +1 -0
  115. package/src/utils/detect-ui-framework.d.ts.map +1 -0
  116. package/src/utils/detect-ui-framework.js +9 -20
  117. package/src/utils/e2e-web-server-info-utils.d.ts +1 -0
  118. package/src/utils/e2e-web-server-info-utils.d.ts.map +1 -0
  119. package/src/utils/e2e-web-server-info-utils.js +23 -35
  120. package/src/utils/ensure-dependencies.d.ts +1 -0
  121. package/src/utils/ensure-dependencies.d.ts.map +1 -0
  122. package/src/utils/ensure-dependencies.js +24 -26
  123. package/src/utils/executor-utils.d.ts +1 -0
  124. package/src/utils/executor-utils.d.ts.map +1 -0
  125. package/src/utils/executor-utils.js +27 -43
  126. package/src/utils/find-vite-config.d.ts +1 -0
  127. package/src/utils/find-vite-config.d.ts.map +1 -0
  128. package/src/utils/find-vite-config.js +12 -37
  129. package/src/utils/generator-utils.d.ts +1 -0
  130. package/src/utils/generator-utils.d.ts.map +1 -0
  131. package/src/utils/generator-utils.js +204 -216
  132. package/src/utils/ignore-vite-temp-files.d.ts +1 -0
  133. package/src/utils/ignore-vite-temp-files.d.ts.map +1 -0
  134. package/src/utils/ignore-vite-temp-files.js +22 -32
  135. package/src/utils/nx-tsconfig-paths-find-file.d.ts +1 -0
  136. package/src/utils/nx-tsconfig-paths-find-file.d.ts.map +1 -0
  137. package/src/utils/nx-tsconfig-paths-find-file.js +10 -16
  138. package/src/utils/options-utils.d.ts +1 -0
  139. package/src/utils/options-utils.d.ts.map +1 -0
  140. package/src/utils/options-utils.js +48 -58
  141. package/src/utils/test-files/test-vite-configs.d.ts +1 -0
  142. package/src/utils/test-files/test-vite-configs.d.ts.map +1 -0
  143. package/src/utils/test-files/test-vite-configs.js +21 -82
  144. package/src/utils/test-utils.d.ts +1 -0
  145. package/src/utils/test-utils.d.ts.map +1 -0
  146. package/src/utils/test-utils.js +103 -130
  147. package/src/utils/version-utils.d.ts +1 -0
  148. package/src/utils/version-utils.d.ts.map +1 -0
  149. package/src/utils/version-utils.js +26 -44
  150. package/src/utils/versions.d.ts +1 -0
  151. package/src/utils/versions.d.ts.map +1 -0
  152. package/src/utils/versions.js +22 -82
  153. package/src/utils/vite-config-edit-utils.d.ts +1 -0
  154. package/src/utils/vite-config-edit-utils.d.ts.map +1 -0
  155. package/src/utils/vite-config-edit-utils.js +145 -125
  156. package/executors.js.map +0 -1
  157. package/index.js.map +0 -1
  158. package/plugin.js.map +0 -1
  159. package/plugins/nx-copy-assets.plugin.js.map +0 -1
  160. package/plugins/nx-tsconfig-paths.plugin.js.map +0 -1
  161. package/plugins/nx-vite-build-coordination.plugin.js.map +0 -1
  162. package/plugins/rollup-replace-files.plugin.js.map +0 -1
  163. package/src/executors/build/build.impl.js.map +0 -1
  164. package/src/executors/build/compat.js.map +0 -1
  165. package/src/executors/build/schema.d.js +0 -3
  166. package/src/executors/build/schema.d.js.map +0 -1
  167. package/src/executors/dev-server/compat.js.map +0 -1
  168. package/src/executors/dev-server/dev-server.impl.js.map +0 -1
  169. package/src/executors/dev-server/schema.d.js +0 -3
  170. package/src/executors/dev-server/schema.d.js.map +0 -1
  171. package/src/executors/preview-server/compat.js.map +0 -1
  172. package/src/executors/preview-server/preview-server.impl.js.map +0 -1
  173. package/src/executors/preview-server/schema.d.js +0 -3
  174. package/src/executors/preview-server/schema.d.js.map +0 -1
  175. package/src/executors/test/compat.js.map +0 -1
  176. package/src/executors/test/lib/nx-reporter.js.map +0 -1
  177. package/src/executors/test/lib/utils.js.map +0 -1
  178. package/src/executors/test/schema.d.js +0 -3
  179. package/src/executors/test/schema.d.js.map +0 -1
  180. package/src/executors/test/vitest.impl.js.map +0 -1
  181. package/src/generators/configuration/configuration.js.map +0 -1
  182. package/src/generators/configuration/lib/convert-non-vite.js.map +0 -1
  183. package/src/generators/configuration/schema.d.js +0 -3
  184. package/src/generators/configuration/schema.d.js.map +0 -1
  185. package/src/generators/convert-to-inferred/convert-to-inferred.js.map +0 -1
  186. package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js.map +0 -1
  187. package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.js.map +0 -1
  188. package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.js.map +0 -1
  189. package/src/generators/convert-to-inferred/lib/test-post-target-transformer.js.map +0 -1
  190. package/src/generators/convert-to-inferred/lib/utils.js.map +0 -1
  191. package/src/generators/init/init.js.map +0 -1
  192. package/src/generators/init/lib/utils.js.map +0 -1
  193. package/src/generators/init/schema.d.js +0 -3
  194. package/src/generators/init/schema.d.js.map +0 -1
  195. package/src/generators/setup-paths-plugin/lib/utils.js.map +0 -1
  196. package/src/generators/setup-paths-plugin/schema.d.js +0 -3
  197. package/src/generators/setup-paths-plugin/schema.d.js.map +0 -1
  198. package/src/generators/setup-paths-plugin/setup-paths-plugin.js.map +0 -1
  199. package/src/generators/vitest/schema.d.js +0 -3
  200. package/src/generators/vitest/schema.d.js.map +0 -1
  201. package/src/generators/vitest/vitest-generator.js.map +0 -1
  202. package/src/migrations/update-19-6-0/add-depends-on-for-preview.js.map +0 -1
  203. package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.js.map +0 -1
  204. package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.js.map +0 -1
  205. package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.js.map +0 -1
  206. package/src/migrations/update-20-5-0/install-jiti.js.map +0 -1
  207. package/src/migrations/update-20-5-0/update-resolve-conditions.js.map +0 -1
  208. package/src/plugins/plugin.js.map +0 -1
  209. package/src/utils/detect-ui-framework.js.map +0 -1
  210. package/src/utils/e2e-web-server-info-utils.js.map +0 -1
  211. package/src/utils/ensure-dependencies.js.map +0 -1
  212. package/src/utils/executor-utils.js.map +0 -1
  213. package/src/utils/find-vite-config.js.map +0 -1
  214. package/src/utils/generator-utils.js.map +0 -1
  215. package/src/utils/ignore-vite-temp-files.js.map +0 -1
  216. package/src/utils/nx-tsconfig-paths-find-file.js.map +0 -1
  217. package/src/utils/options-utils.js.map +0 -1
  218. package/src/utils/test-files/test-vite-configs.js.map +0 -1
  219. package/src/utils/test-utils.js.map +0 -1
  220. package/src/utils/version-utils.js.map +0 -1
  221. package/src/utils/versions.js.map +0 -1
  222. package/src/utils/vite-config-edit-utils.js.map +0 -1
@@ -1,63 +1,26 @@
1
1
  "use strict";
2
- function _export(target, all) {
3
- for(var name in all)Object.defineProperty(target, name, {
4
- enumerable: true,
5
- get: all[name]
6
- });
7
- }
8
- _export(exports, {
9
- addBuildTarget: function() {
10
- return addBuildTarget;
11
- },
12
- addOrChangeTestTarget: function() {
13
- return addOrChangeTestTarget;
14
- },
15
- addPreviewTarget: function() {
16
- return addPreviewTarget;
17
- },
18
- addServeTarget: function() {
19
- return addServeTarget;
20
- },
21
- createOrEditViteConfig: function() {
22
- return createOrEditViteConfig;
23
- },
24
- deleteWebpackConfig: function() {
25
- return deleteWebpackConfig;
26
- },
27
- editTsConfig: function() {
28
- return editTsConfig;
29
- },
30
- findExistingJsBuildTargetInProject: function() {
31
- return findExistingJsBuildTargetInProject;
32
- },
33
- getViteConfigPathForProject: function() {
34
- return getViteConfigPathForProject;
35
- },
36
- handleUnknownConfiguration: function() {
37
- return handleUnknownConfiguration;
38
- },
39
- handleUnsupportedUserProvidedTargets: function() {
40
- return handleUnsupportedUserProvidedTargets;
41
- },
42
- moveAndEditIndexHtml: function() {
43
- return moveAndEditIndexHtml;
44
- },
45
- normalizeViteConfigFilePathWithTree: function() {
46
- return normalizeViteConfigFilePathWithTree;
47
- }
48
- });
49
- const _devkit = require("@nx/devkit");
50
- const _targetdefaultsutils = require("@nx/devkit/src/generators/target-defaults-utils");
51
- const _tssolutionsetup = require("@nx/js/src/utils/typescript/ts-solution-setup");
52
- const _viteconfigeditutils = require("./vite-config-edit-utils");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findExistingJsBuildTargetInProject = findExistingJsBuildTargetInProject;
4
+ exports.addOrChangeTestTarget = addOrChangeTestTarget;
5
+ exports.addBuildTarget = addBuildTarget;
6
+ exports.addServeTarget = addServeTarget;
7
+ exports.addPreviewTarget = addPreviewTarget;
8
+ exports.editTsConfig = editTsConfig;
9
+ exports.deleteWebpackConfig = deleteWebpackConfig;
10
+ exports.moveAndEditIndexHtml = moveAndEditIndexHtml;
11
+ exports.createOrEditViteConfig = createOrEditViteConfig;
12
+ exports.normalizeViteConfigFilePathWithTree = normalizeViteConfigFilePathWithTree;
13
+ exports.getViteConfigPathForProject = getViteConfigPathForProject;
14
+ exports.handleUnsupportedUserProvidedTargets = handleUnsupportedUserProvidedTargets;
15
+ exports.handleUnknownConfiguration = handleUnknownConfiguration;
16
+ const devkit_1 = require("@nx/devkit");
17
+ const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
18
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
19
+ const vite_config_edit_utils_1 = require("./vite-config-edit-utils");
53
20
  function findExistingJsBuildTargetInProject(targets) {
54
21
  const output = {};
55
22
  const supportedExecutors = {
56
- build: [
57
- '@nx/js:babel',
58
- '@nx/js:swc',
59
- '@nx/rollup:rollup'
60
- ]
23
+ build: ['@nx/js:babel', '@nx/js:swc', '@nx/rollup:rollup'],
61
24
  };
62
25
  const unsupportedExecutors = [
63
26
  '@nx/angular:ng-packagr-lite',
@@ -86,158 +49,154 @@ function findExistingJsBuildTargetInProject(targets) {
86
49
  '@nrwl/js:tsc',
87
50
  '@angular-devkit/build-angular:browser',
88
51
  '@angular-devkit/build-angular:browser-esbuild',
89
- '@angular-devkit/build-angular:application'
52
+ '@angular-devkit/build-angular:application',
90
53
  ];
91
54
  // We try to find the target that is using the supported executors
92
55
  // for build since this is the one we will be converting
93
- for(const target in targets){
56
+ for (const target in targets) {
94
57
  const executorName = targets[target].executor;
95
58
  if (supportedExecutors.build.includes(executorName)) {
96
59
  output.supported = target;
97
- } else if (unsupportedExecutors.includes(executorName)) {
60
+ }
61
+ else if (unsupportedExecutors.includes(executorName)) {
98
62
  output.unsupported = target;
99
63
  }
100
64
  }
101
65
  return output;
102
66
  }
103
67
  function addOrChangeTestTarget(tree, options, hasPlugin) {
104
- var _nxJson_plugins;
105
- var _project;
106
- const nxJson = (0, _devkit.readNxJson)(tree);
107
- hasPlugin = (_nxJson_plugins = nxJson.plugins) == null ? void 0 : _nxJson_plugins.some((p)=>typeof p === 'string' ? p === '@nx/vite/plugin' : p.plugin === '@nx/vite/plugin' || hasPlugin);
68
+ const nxJson = (0, devkit_1.readNxJson)(tree);
69
+ hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
70
+ ? p === '@nx/vite/plugin'
71
+ : p.plugin === '@nx/vite/plugin' || hasPlugin);
108
72
  if (hasPlugin) {
109
73
  return;
110
74
  }
111
- const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
112
- var _options_testTarget;
113
- const target = (_options_testTarget = options.testTarget) != null ? _options_testTarget : 'test';
114
- const reportsDirectory = (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(project.root), 'coverage', project.root === '.' ? options.project : project.root);
75
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
76
+ const target = options.testTarget ?? 'test';
77
+ const reportsDirectory = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(project.root), 'coverage', project.root === '.' ? options.project : project.root);
115
78
  const testOptions = {
116
- reportsDirectory
79
+ reportsDirectory,
117
80
  };
118
- var _targets;
119
- (_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
81
+ project.targets ??= {};
120
82
  if (project.targets[target]) {
121
83
  throw new Error(`Target "${target}" already exists in the project.`);
122
- } else {
84
+ }
85
+ else {
123
86
  project.targets[target] = {
124
87
  executor: '@nx/vite:test',
125
- outputs: [
126
- '{options.reportsDirectory}'
127
- ],
128
- options: testOptions
88
+ outputs: ['{options.reportsDirectory}'],
89
+ options: testOptions,
129
90
  };
130
91
  }
131
- (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
92
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
132
93
  }
133
94
  function addBuildTarget(tree, options, target) {
134
- var _project;
135
- (0, _targetdefaultsutils.addBuildTargetDefaults)(tree, '@nx/vite:build');
136
- const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
137
- const isTsSolutionSetup = (0, _tssolutionsetup.isUsingTsSolutionSetup)(tree);
95
+ (0, target_defaults_utils_1.addBuildTargetDefaults)(tree, '@nx/vite:build');
96
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
97
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
138
98
  const buildOptions = {
139
- outputPath: isTsSolutionSetup ? (0, _devkit.joinPathFragments)(project.root, 'dist') : (0, _devkit.joinPathFragments)('dist', project.root != '.' ? project.root : options.project)
99
+ outputPath: isTsSolutionSetup
100
+ ? (0, devkit_1.joinPathFragments)(project.root, 'dist')
101
+ : (0, devkit_1.joinPathFragments)('dist', project.root != '.' ? project.root : options.project),
140
102
  };
141
- var _targets;
142
- (_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
103
+ project.targets ??= {};
143
104
  project.targets[target] = {
144
105
  executor: '@nx/vite:build',
145
- outputs: [
146
- '{options.outputPath}'
147
- ],
106
+ outputs: ['{options.outputPath}'],
148
107
  defaultConfiguration: 'production',
149
108
  options: buildOptions,
150
109
  configurations: {
151
110
  development: {
152
- mode: 'development'
111
+ mode: 'development',
153
112
  },
154
113
  production: {
155
- mode: 'production'
156
- }
157
- }
114
+ mode: 'production',
115
+ },
116
+ },
158
117
  };
159
- (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
118
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
160
119
  }
161
120
  function addServeTarget(tree, options, target) {
162
- var _project;
163
- const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
164
- var _targets;
165
- (_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
121
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
122
+ project.targets ??= {};
166
123
  project.targets[target] = {
167
124
  executor: '@nx/vite:dev-server',
168
125
  defaultConfiguration: 'development',
169
126
  options: {
170
- buildTarget: `${options.project}:build`
127
+ buildTarget: `${options.project}:build`,
171
128
  },
172
129
  configurations: {
173
130
  development: {
174
131
  buildTarget: `${options.project}:build:development`,
175
- hmr: true
132
+ hmr: true,
176
133
  },
177
134
  production: {
178
135
  buildTarget: `${options.project}:build:production`,
179
- hmr: false
180
- }
181
- }
136
+ hmr: false,
137
+ },
138
+ },
182
139
  };
183
- (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
140
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
184
141
  }
142
+ /**
143
+ * Adds a target for the preview server.
144
+ *
145
+ * @param tree
146
+ * @param options
147
+ * @param serveTarget An existing serve target.
148
+ */
185
149
  function addPreviewTarget(tree, options, serveTarget) {
186
- var _project;
187
- const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
150
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
188
151
  const previewOptions = {
189
- buildTarget: `${options.project}:build`
152
+ buildTarget: `${options.project}:build`,
190
153
  };
191
- var _targets;
192
- (_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
154
+ project.targets ??= {};
193
155
  // Update the options from the passed serve target.
194
156
  if (project.targets[serveTarget]) {
195
- var _target_options, _target_options1;
196
157
  const target = project.targets[serveTarget];
197
158
  if (target.executor === '@nxext/vite:dev') {
198
159
  previewOptions.proxyConfig = target.options.proxyConfig;
199
160
  }
200
- previewOptions['https'] = (_target_options = target.options) == null ? void 0 : _target_options.https;
201
- previewOptions['open'] = (_target_options1 = target.options) == null ? void 0 : _target_options1.open;
161
+ previewOptions['https'] = target.options?.https;
162
+ previewOptions['open'] = target.options?.open;
202
163
  }
203
164
  // Adds a preview target.
204
165
  project.targets.preview = {
205
- dependsOn: [
206
- 'build'
207
- ],
166
+ dependsOn: ['build'],
208
167
  executor: '@nx/vite:preview-server',
209
168
  defaultConfiguration: 'development',
210
169
  options: previewOptions,
211
170
  configurations: {
212
171
  development: {
213
- buildTarget: `${options.project}:build:development`
172
+ buildTarget: `${options.project}:build:development`,
214
173
  },
215
174
  production: {
216
- buildTarget: `${options.project}:build:production`
217
- }
218
- }
175
+ buildTarget: `${options.project}:build:production`,
176
+ },
177
+ },
219
178
  };
220
- (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
179
+ (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
221
180
  }
222
181
  function editTsConfig(tree, options) {
223
- const projectConfig = (0, _devkit.readProjectConfiguration)(tree, options.project);
224
- let tsconfigPath = (0, _devkit.joinPathFragments)(projectConfig.root, 'tsconfig.json');
225
- const isTsSolutionSetup = (0, _tssolutionsetup.isUsingTsSolutionSetup)(tree);
182
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
183
+ let tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
184
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
226
185
  if (isTsSolutionSetup) {
227
186
  tsconfigPath = [
228
- (0, _devkit.joinPathFragments)(projectConfig.root, 'tsconfig.app.json'),
229
- (0, _devkit.joinPathFragments)(projectConfig.root, 'tsconfig.lib.json')
230
- ].find((p)=>tree.exists(p));
187
+ (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.app.json'),
188
+ (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.lib.json'),
189
+ ].find((p) => tree.exists(p));
231
190
  }
232
- const config = (0, _devkit.readJson)(tree, tsconfigPath);
233
- switch(options.uiFramework){
191
+ const config = (0, devkit_1.readJson)(tree, tsconfigPath);
192
+ switch (options.uiFramework) {
234
193
  case 'react':
235
194
  config.compilerOptions = {
236
195
  jsx: 'react-jsx',
237
196
  allowJs: false,
238
197
  esModuleInterop: false,
239
198
  allowSyntheticDefaultImports: true,
240
- strict: true
199
+ strict: true,
241
200
  };
242
201
  break;
243
202
  case 'none':
@@ -249,29 +208,36 @@ function editTsConfig(tree, options) {
249
208
  noImplicitOverride: true,
250
209
  noPropertyAccessFromIndexSignature: true,
251
210
  noImplicitReturns: true,
252
- noFallthroughCasesInSwitch: true
211
+ noFallthroughCasesInSwitch: true,
253
212
  };
254
213
  }
255
214
  break;
256
215
  default:
257
216
  break;
258
217
  }
259
- (0, _devkit.writeJson)(tree, tsconfigPath, config);
218
+ (0, devkit_1.writeJson)(tree, tsconfigPath, config);
260
219
  }
261
220
  function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
262
- const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath) ? webpackConfigFilePath : tree.exists(`${projectRoot}/webpack.config.js`) ? `${projectRoot}/webpack.config.js` : tree.exists(`${projectRoot}/webpack.config.ts`) ? `${projectRoot}/webpack.config.ts` : null;
221
+ const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
222
+ ? webpackConfigFilePath
223
+ : tree.exists(`${projectRoot}/webpack.config.js`)
224
+ ? `${projectRoot}/webpack.config.js`
225
+ : tree.exists(`${projectRoot}/webpack.config.ts`)
226
+ ? `${projectRoot}/webpack.config.ts`
227
+ : null;
263
228
  if (webpackConfigPath) {
264
229
  tree.delete(webpackConfigPath);
265
230
  }
266
231
  }
267
232
  function moveAndEditIndexHtml(tree, options) {
268
- const projectConfig = (0, _devkit.readProjectConfiguration)(tree, options.project);
233
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
269
234
  let indexHtmlPath = `${projectConfig.root}/src/index.html`;
270
235
  let mainPath = `${projectConfig.root}/src/main.ts${options.uiFramework === 'react' ? 'x' : ''}`;
271
236
  if (projectConfig.root !== '.') {
272
237
  mainPath = mainPath.replace(projectConfig.root, '');
273
238
  }
274
- if (!tree.exists(indexHtmlPath) && tree.exists(`${projectConfig.root}/index.html`)) {
239
+ if (!tree.exists(indexHtmlPath) &&
240
+ tree.exists(`${projectConfig.root}/index.html`)) {
275
241
  indexHtmlPath = `${projectConfig.root}/index.html`;
276
242
  }
277
243
  if (tree.exists(indexHtmlPath)) {
@@ -283,7 +249,8 @@ function moveAndEditIndexHtml(tree, options) {
283
249
  tree.delete(`${projectConfig.root}/src/index.html`);
284
250
  }
285
251
  }
286
- } else {
252
+ }
253
+ else {
287
254
  tree.write(`${projectConfig.root}/index.html`, `<!DOCTYPE html>
288
255
  <html lang='en'>
289
256
  <head>
@@ -300,13 +267,21 @@ function moveAndEditIndexHtml(tree, options) {
300
267
  }
301
268
  }
302
269
  function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasViteTargets, vitestFileName) {
303
- const { root: projectRoot } = (0, _devkit.readProjectConfiguration)(tree, options.project);
270
+ const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
304
271
  const extension = options.useEsmExtension ? 'mts' : 'ts';
305
- const viteConfigPath = vitestFileName ? `${projectRoot}/vitest.config.${extension}` : `${projectRoot}/vite.config.${extension}`;
306
- const isTsSolutionSetup = (0, _tssolutionsetup.isUsingTsSolutionSetup)(tree);
307
- const buildOutDir = isTsSolutionSetup ? './dist' : projectRoot === '.' ? `./dist/${options.project}` : `${(0, _devkit.offsetFromRoot)(projectRoot)}dist/${projectRoot}`;
308
- var _options_rollupOptionsExternal;
309
- const buildOption = onlyVitest ? '' : options.includeLib ? ` // Configuration for building your library.
272
+ const viteConfigPath = vitestFileName
273
+ ? `${projectRoot}/vitest.config.${extension}`
274
+ : `${projectRoot}/vite.config.${extension}`;
275
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
276
+ const buildOutDir = isTsSolutionSetup
277
+ ? './dist'
278
+ : projectRoot === '.'
279
+ ? `./dist/${options.project}`
280
+ : `${(0, devkit_1.offsetFromRoot)(projectRoot)}dist/${projectRoot}`;
281
+ const buildOption = onlyVitest
282
+ ? ''
283
+ : options.includeLib
284
+ ? ` // Configuration for building your library.
310
285
  // See: https://vitejs.dev/guide/build.html#library-mode
311
286
  build: {
312
287
  outDir: '${buildOutDir}',
@@ -326,9 +301,10 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
326
301
  },
327
302
  rollupOptions: {
328
303
  // External packages that should not be bundled into your library.
329
- external: [${(_options_rollupOptionsExternal = options.rollupOptionsExternal) != null ? _options_rollupOptionsExternal : ''}]
304
+ external: [${options.rollupOptionsExternal ?? ''}]
330
305
  },
331
- },` : ` build: {
306
+ },`
307
+ : ` build: {
332
308
  outDir: '${buildOutDir}',
333
309
  emptyOutDir: true,
334
310
  reportCompressedSize: true,
@@ -336,12 +312,8 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
336
312
  transformMixedEsModules: true,
337
313
  },
338
314
  },`;
339
- const imports = options.imports ? [
340
- ...options.imports
341
- ] : [];
342
- const plugins = options.plugins ? [
343
- ...options.plugins
344
- ] : [];
315
+ const imports = options.imports ? [...options.imports] : [];
316
+ const plugins = options.plugins ? [...options.plugins] : [];
345
317
  if (!onlyVitest && options.includeLib) {
346
318
  imports.push(`import dts from 'vite-plugin-dts'`, `import * as path from 'path'`);
347
319
  }
@@ -352,41 +324,58 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
352
324
  if (!onlyVitest && options.includeLib) {
353
325
  plugins.push(`dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json')${!isTsSolutionSetup ? ', pathsToAliases: false' : ''} })`);
354
326
  }
355
- const reportsDirectory = isTsSolutionSetup ? './test-output/vitest/coverage' : projectRoot === '.' ? `./coverage/${options.project}` : `${(0, _devkit.offsetFromRoot)(projectRoot)}coverage/${projectRoot}`;
356
- var _options_testEnvironment;
357
- const testOption = options.includeVitest ? ` test: {
327
+ const reportsDirectory = isTsSolutionSetup
328
+ ? './test-output/vitest/coverage'
329
+ : projectRoot === '.'
330
+ ? `./coverage/${options.project}`
331
+ : `${(0, devkit_1.offsetFromRoot)(projectRoot)}coverage/${projectRoot}`;
332
+ const testOption = options.includeVitest
333
+ ? ` test: {
358
334
  watch: false,
359
335
  globals: true,
360
- environment: '${(_options_testEnvironment = options.testEnvironment) != null ? _options_testEnvironment : 'jsdom'}',
336
+ environment: '${options.testEnvironment ?? 'jsdom'}',
361
337
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
362
338
  ${options.setupFile ? ` setupFiles: ['${options.setupFile}'],\n` : ''}\
363
- ${options.inSourceTests ? ` includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n` : ''}\
339
+ ${options.inSourceTests
340
+ ? ` includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n`
341
+ : ''}\
364
342
  reporters: ['default'],
365
343
  coverage: {
366
344
  reportsDirectory: '${reportsDirectory}',
367
- provider: ${options.coverageProvider ? `'${options.coverageProvider}' as const` : `'v8' as const`},
345
+ provider: ${options.coverageProvider
346
+ ? `'${options.coverageProvider}' as const`
347
+ : `'v8' as const`},
368
348
  }
369
- },` : '';
370
- const defineOption = options.inSourceTests ? ` define: {
349
+ },`
350
+ : '';
351
+ const defineOption = options.inSourceTests
352
+ ? ` define: {
371
353
  'import.meta.vitest': undefined
372
- },` : '';
373
- var _options_port;
374
- const devServerOption = onlyVitest ? '' : options.includeLib ? '' : ` server:{
375
- port: ${(_options_port = options.port) != null ? _options_port : 4200},
354
+ },`
355
+ : '';
356
+ const devServerOption = onlyVitest
357
+ ? ''
358
+ : options.includeLib
359
+ ? ''
360
+ : ` server:{
361
+ port: ${options.port ?? 4200},
376
362
  host: 'localhost',
377
363
  },`;
378
- var _options_previewPort;
379
- const previewServerOption = onlyVitest ? '' : options.includeLib ? '' : ` preview:{
380
- port: ${(_options_previewPort = options.previewPort) != null ? _options_previewPort : 4300},
364
+ const previewServerOption = onlyVitest
365
+ ? ''
366
+ : options.includeLib
367
+ ? ''
368
+ : ` preview:{
369
+ port: ${options.previewPort ?? 4300},
381
370
  host: 'localhost',
382
371
  },`;
383
372
  const workerOption = ` // Uncomment this if you are using workers.
384
373
  // worker: {
385
374
  // plugins: [ nxViteTsPaths() ],
386
375
  // },`;
387
- const cacheDir = `cacheDir: '${normalizedJoinPaths((0, _devkit.offsetFromRoot)(projectRoot), 'node_modules', '.vite', projectRoot === '.' ? options.project : projectRoot)}',`;
376
+ const cacheDir = `cacheDir: '${normalizedJoinPaths((0, devkit_1.offsetFromRoot)(projectRoot), 'node_modules', '.vite', projectRoot === '.' ? options.project : projectRoot)}',`;
388
377
  if (tree.exists(viteConfigPath)) {
389
- handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, (0, _devkit.offsetFromRoot)(projectRoot), projectAlreadyHasViteTargets);
378
+ handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, (0, devkit_1.offsetFromRoot)(projectRoot), projectAlreadyHasViteTargets);
390
379
  return;
391
380
  }
392
381
  const viteConfigContent = `/// <reference types='vitest' />
@@ -404,18 +393,24 @@ function printOptions(...options) {
404
393
  return options.filter(Boolean).join('\n');
405
394
  }
406
395
  function normalizeViteConfigFilePathWithTree(tree, projectRoot, configFile) {
407
- return configFile && tree.exists(configFile) ? configFile : tree.exists((0, _devkit.joinPathFragments)(`${projectRoot}/vite.config.ts`)) ? (0, _devkit.joinPathFragments)(`${projectRoot}/vite.config.ts`) : tree.exists((0, _devkit.joinPathFragments)(`${projectRoot}/vite.config.js`)) ? (0, _devkit.joinPathFragments)(`${projectRoot}/vite.config.js`) : undefined;
396
+ return configFile && tree.exists(configFile)
397
+ ? configFile
398
+ : tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`))
399
+ ? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`)
400
+ : tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`))
401
+ ? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`)
402
+ : undefined;
408
403
  }
409
404
  function getViteConfigPathForProject(tree, projectName, target) {
410
405
  let viteConfigPath;
411
- const { targets, root } = (0, _devkit.readProjectConfiguration)(tree, projectName);
406
+ const { targets, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
412
407
  if (target) {
413
- var _targets_target_options, _targets_target;
414
- viteConfigPath = targets == null ? void 0 : (_targets_target = targets[target]) == null ? void 0 : (_targets_target_options = _targets_target.options) == null ? void 0 : _targets_target_options.configFile;
415
- } else {
416
- var _config_options;
417
- const config = Object.values(targets).find((config)=>config.executor === '@nrwl/nx:build' || config.executor === '@nrwl/vite:build');
418
- viteConfigPath = config == null ? void 0 : (_config_options = config.options) == null ? void 0 : _config_options.configFile;
408
+ viteConfigPath = targets?.[target]?.options?.configFile;
409
+ }
410
+ else {
411
+ const config = Object.values(targets).find((config) => config.executor === '@nrwl/nx:build' ||
412
+ config.executor === '@nrwl/vite:build');
413
+ viteConfigPath = config?.options?.configFile;
419
414
  }
420
415
  return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);
421
416
  }
@@ -431,7 +426,7 @@ async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsuppor
431
426
  }
432
427
  }
433
428
  async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
434
- _devkit.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.
429
+ devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.
435
430
  However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
436
431
 
437
432
  Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
@@ -441,7 +436,7 @@ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName
441
436
  const prompt = new Confirm({
442
437
  name: 'question',
443
438
  message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,
444
- initial: true
439
+ initial: true,
445
440
  });
446
441
  const shouldConvert = await prompt.run();
447
442
  if (!shouldConvert) {
@@ -458,7 +453,7 @@ async function handleUnknownConfiguration(projectName) {
458
453
  if (process.env.NX_INTERACTIVE === 'false') {
459
454
  return;
460
455
  }
461
- _devkit.logger.warn(`
456
+ devkit_1.logger.warn(`
462
457
  We could not find any configuration in project ${projectName} that
463
458
  indicates whether we can definitely convert to Vite.
464
459
 
@@ -469,7 +464,7 @@ async function handleUnknownConfiguration(projectName) {
469
464
  const prompt = new Confirm({
470
465
  name: 'question',
471
466
  message: `Should Nx convert your project to use Vite?`,
472
- initial: true
467
+ initial: true,
473
468
  });
474
469
  const shouldConvert = await prompt.run();
475
470
  if (!shouldConvert) {
@@ -480,55 +475,50 @@ async function handleUnknownConfiguration(projectName) {
480
475
  }
481
476
  }
482
477
  function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, offsetFromRoot, projectAlreadyHasViteTargets) {
483
- if ((projectAlreadyHasViteTargets == null ? void 0 : projectAlreadyHasViteTargets.build) && (projectAlreadyHasViteTargets == null ? void 0 : projectAlreadyHasViteTargets.test)) {
478
+ if (projectAlreadyHasViteTargets?.build &&
479
+ projectAlreadyHasViteTargets?.test) {
484
480
  return;
485
481
  }
486
482
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
487
- _devkit.logger.info(`vite.config.ts already exists for project ${options.project}.`);
483
+ devkit_1.logger.info(`vite.config.ts already exists for project ${options.project}.`);
488
484
  }
489
- var _options_rollupOptionsExternal;
490
- const buildOptionObject = options.includeLib ? {
491
- lib: {
492
- entry: 'src/index.ts',
493
- name: options.project,
494
- fileName: 'index',
495
- formats: [
496
- 'es'
497
- ]
498
- },
499
- rollupOptions: {
500
- external: (_options_rollupOptionsExternal = options.rollupOptionsExternal) != null ? _options_rollupOptionsExternal : []
501
- },
502
- outDir: buildOutDir,
503
- reportCompressedSize: true,
504
- commonjsOptions: {
505
- transformMixedEsModules: true
506
- }
507
- } : {
508
- outDir: buildOutDir,
509
- reportCompressedSize: true,
510
- commonjsOptions: {
511
- transformMixedEsModules: true
485
+ const buildOptionObject = options.includeLib
486
+ ? {
487
+ lib: {
488
+ entry: 'src/index.ts',
489
+ name: options.project,
490
+ fileName: 'index',
491
+ formats: ['es'],
492
+ },
493
+ rollupOptions: {
494
+ external: options.rollupOptionsExternal ?? [],
495
+ },
496
+ outDir: buildOutDir,
497
+ reportCompressedSize: true,
498
+ commonjsOptions: {
499
+ transformMixedEsModules: true,
500
+ },
512
501
  }
513
- };
514
- var _options_testEnvironment, _options_coverageProvider;
502
+ : {
503
+ outDir: buildOutDir,
504
+ reportCompressedSize: true,
505
+ commonjsOptions: {
506
+ transformMixedEsModules: true,
507
+ },
508
+ };
515
509
  const testOptionObject = {
516
510
  globals: true,
517
- environment: (_options_testEnvironment = options.testEnvironment) != null ? _options_testEnvironment : 'jsdom',
518
- include: [
519
- 'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
520
- ],
521
- reporters: [
522
- 'default'
523
- ],
511
+ environment: options.testEnvironment ?? 'jsdom',
512
+ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
513
+ reporters: ['default'],
524
514
  coverage: {
525
515
  reportsDirectory: reportsDirectory,
526
- provider: `'${(_options_coverageProvider = options.coverageProvider) != null ? _options_coverageProvider : 'v8'}'`
527
- }
516
+ provider: `'${options.coverageProvider ?? 'v8'}'`,
517
+ },
528
518
  };
529
- const changed = (0, _viteconfigeditutils.ensureViteConfigIsCorrect)(tree, viteConfigPath, buildOption, buildOptionObject, imports, plugins, testOption, testOptionObject, cacheDir, projectAlreadyHasViteTargets != null ? projectAlreadyHasViteTargets : {});
519
+ const changed = (0, vite_config_edit_utils_1.ensureViteConfigIsCorrect)(tree, viteConfigPath, buildOption, buildOptionObject, imports, plugins, testOption, testOptionObject, cacheDir, projectAlreadyHasViteTargets ?? {});
530
520
  if (!changed) {
531
- _devkit.logger.warn(`Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):
521
+ devkit_1.logger.warn(`Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):
532
522
 
533
523
  ${buildOption}
534
524
 
@@ -536,8 +526,6 @@ function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption,
536
526
  }
537
527
  }
538
528
  function normalizedJoinPaths(...paths) {
539
- const path = (0, _devkit.joinPathFragments)(...paths);
529
+ const path = (0, devkit_1.joinPathFragments)(...paths);
540
530
  return path.startsWith('.') ? path : `./${path}`;
541
531
  }
542
-
543
- //# sourceMappingURL=generator-utils.js.map