@nx/vite 16.0.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 (116) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/executors.d.ts +8 -0
  5. package/executors.js +19 -0
  6. package/executors.js.map +1 -0
  7. package/executors.json +46 -0
  8. package/generators.json +46 -0
  9. package/index.d.ts +8 -0
  10. package/index.js +20 -0
  11. package/index.js.map +1 -0
  12. package/migrations.json +80 -0
  13. package/package.json +60 -0
  14. package/plugins/rollup-replace-files.plugin.d.ts +16 -0
  15. package/plugins/rollup-replace-files.plugin.js +49 -0
  16. package/plugins/rollup-replace-files.plugin.js.map +1 -0
  17. package/src/executors/build/build.impl.d.ts +10 -0
  18. package/src/executors/build/build.impl.js +91 -0
  19. package/src/executors/build/build.impl.js.map +1 -0
  20. package/src/executors/build/compat.d.ts +2 -0
  21. package/src/executors/build/compat.js +10 -0
  22. package/src/executors/build/compat.js.map +1 -0
  23. package/src/executors/build/schema.d.js +3 -0
  24. package/src/executors/build/schema.d.js.map +1 -0
  25. package/src/executors/build/schema.d.ts +17 -0
  26. package/src/executors/build/schema.json +143 -0
  27. package/src/executors/dev-server/compat.d.ts +2 -0
  28. package/src/executors/dev-server/compat.js +10 -0
  29. package/src/executors/dev-server/compat.js.map +1 -0
  30. package/src/executors/dev-server/dev-server.impl.d.ts +8 -0
  31. package/src/executors/dev-server/dev-server.impl.js +68 -0
  32. package/src/executors/dev-server/dev-server.impl.js.map +1 -0
  33. package/src/executors/dev-server/schema.d.js +3 -0
  34. package/src/executors/dev-server/schema.d.js.map +1 -0
  35. package/src/executors/dev-server/schema.d.ts +14 -0
  36. package/src/executors/dev-server/schema.json +89 -0
  37. package/src/executors/preview-server/compat.d.ts +2 -0
  38. package/src/executors/preview-server/compat.js +10 -0
  39. package/src/executors/preview-server/compat.js.map +1 -0
  40. package/src/executors/preview-server/preview-server.impl.d.ts +7 -0
  41. package/src/executors/preview-server/preview-server.impl.js +107 -0
  42. package/src/executors/preview-server/preview-server.impl.js.map +1 -0
  43. package/src/executors/preview-server/schema.d.js +3 -0
  44. package/src/executors/preview-server/schema.d.js.map +1 -0
  45. package/src/executors/preview-server/schema.d.ts +12 -0
  46. package/src/executors/preview-server/schema.json +80 -0
  47. package/src/executors/test/compat.d.ts +2 -0
  48. package/src/executors/test/compat.js +10 -0
  49. package/src/executors/test/compat.js.map +1 -0
  50. package/src/executors/test/schema.d.js +3 -0
  51. package/src/executors/test/schema.d.js.map +1 -0
  52. package/src/executors/test/schema.d.ts +11 -0
  53. package/src/executors/test/schema.json +63 -0
  54. package/src/executors/test/vitest.impl.d.ts +6 -0
  55. package/src/executors/test/vitest.impl.js +130 -0
  56. package/src/executors/test/vitest.impl.js.map +1 -0
  57. package/src/generators/configuration/configuration.d.ts +5 -0
  58. package/src/generators/configuration/configuration.js +130 -0
  59. package/src/generators/configuration/configuration.js.map +1 -0
  60. package/src/generators/configuration/schema.d.js +3 -0
  61. package/src/generators/configuration/schema.d.js.map +1 -0
  62. package/src/generators/configuration/schema.d.ts +12 -0
  63. package/src/generators/configuration/schema.json +61 -0
  64. package/src/generators/init/init.d.ts +6 -0
  65. package/src/generators/init/init.js +84 -0
  66. package/src/generators/init/init.js.map +1 -0
  67. package/src/generators/init/schema.d.js +3 -0
  68. package/src/generators/init/schema.d.js.map +1 -0
  69. package/src/generators/init/schema.d.ts +4 -0
  70. package/src/generators/init/schema.json +22 -0
  71. package/src/generators/vitest/files/tsconfig.spec.json__tmpl__ +19 -0
  72. package/src/generators/vitest/schema.d.js +3 -0
  73. package/src/generators/vitest/schema.d.js.map +1 -0
  74. package/src/generators/vitest/schema.d.ts +9 -0
  75. package/src/generators/vitest/schema.json +49 -0
  76. package/src/generators/vitest/vitest-generator.d.ts +5 -0
  77. package/src/generators/vitest/vitest-generator.js +99 -0
  78. package/src/generators/vitest/vitest-generator.js.map +1 -0
  79. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.d.ts +3 -0
  80. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js +63 -0
  81. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js.map +1 -0
  82. package/src/migrations/update-15-3-4/set-mode-in-configuration.d.ts +3 -0
  83. package/src/migrations/update-15-3-4/set-mode-in-configuration.js +33 -0
  84. package/src/migrations/update-15-3-4/set-mode-in-configuration.js.map +1 -0
  85. package/src/migrations/update-15-4-3/update-report-directory.d.ts +3 -0
  86. package/src/migrations/update-15-4-3/update-report-directory.js +35 -0
  87. package/src/migrations/update-15-4-3/update-report-directory.js.map +1 -0
  88. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  89. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  90. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  91. package/src/utils/generator-utils.d.ts +34 -0
  92. package/src/utils/generator-utils.js +567 -0
  93. package/src/utils/generator-utils.js.map +1 -0
  94. package/src/utils/options-utils.d.ts +32 -0
  95. package/src/utils/options-utils.js +113 -0
  96. package/src/utils/options-utils.js.map +1 -0
  97. package/src/utils/test-files/angular-project.config.json +89 -0
  98. package/src/utils/test-files/react-lib-non-buildable-jest.json +25 -0
  99. package/src/utils/test-files/react-lib-non-buildable-vitest.json +25 -0
  100. package/src/utils/test-files/react-mixed-project.config.json +52 -0
  101. package/src/utils/test-files/react-project.config.json +85 -0
  102. package/src/utils/test-files/react-vite-project.config.json +57 -0
  103. package/src/utils/test-files/test-vite-configs.d.ts +32 -0
  104. package/src/utils/test-files/test-vite-configs.js +285 -0
  105. package/src/utils/test-files/test-vite-configs.js.map +1 -0
  106. package/src/utils/test-files/unknown-project.config.json +72 -0
  107. package/src/utils/test-files/web-project.config.json +72 -0
  108. package/src/utils/test-utils.d.ts +9 -0
  109. package/src/utils/test-utils.js +516 -0
  110. package/src/utils/test-utils.js.map +1 -0
  111. package/src/utils/versions.d.ts +13 -0
  112. package/src/utils/versions.js +37 -0
  113. package/src/utils/versions.js.map +1 -0
  114. package/src/utils/vite-config-edit-utils.d.ts +3 -0
  115. package/src/utils/vite-config-edit-utils.js +286 -0
  116. package/src/utils/vite-config-edit-utils.js.map +1 -0
@@ -0,0 +1,567 @@
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
+ findExistingTargetsInProject: ()=>findExistingTargetsInProject,
10
+ addOrChangeTestTarget: ()=>addOrChangeTestTarget,
11
+ addOrChangeBuildTarget: ()=>addOrChangeBuildTarget,
12
+ addOrChangeServeTarget: ()=>addOrChangeServeTarget,
13
+ addPreviewTarget: ()=>addPreviewTarget,
14
+ editTsConfig: ()=>editTsConfig,
15
+ deleteWebpackConfig: ()=>deleteWebpackConfig,
16
+ moveAndEditIndexHtml: ()=>moveAndEditIndexHtml,
17
+ createOrEditViteConfig: ()=>createOrEditViteConfig,
18
+ normalizeViteConfigFilePathWithTree: ()=>normalizeViteConfigFilePathWithTree,
19
+ getViteConfigPathForProject: ()=>getViteConfigPathForProject,
20
+ handleUnsupportedUserProvidedTargets: ()=>handleUnsupportedUserProvidedTargets,
21
+ handleUnknownExecutors: ()=>handleUnknownExecutors
22
+ });
23
+ const _extends = require("@swc/helpers/lib/_extends.js").default;
24
+ const _devkit = require("@nx/devkit");
25
+ const _viteConfigEditUtils = require("./vite-config-edit-utils");
26
+ var _hasViteTargets, _hasViteTargets1, _hasViteTargets2, _hasViteTargets3, _output, _project, _project1, _project2, _project3;
27
+ function findExistingTargetsInProject(targets, userProvidedTargets) {
28
+ const output = {
29
+ validFoundTargetName: {},
30
+ projectContainsUnsupportedExecutor: false,
31
+ userProvidedTargetIsUnsupported: {},
32
+ alreadyHasNxViteTargets: {}
33
+ };
34
+ const supportedExecutors = {
35
+ build: [
36
+ '@nxext/vite:build',
37
+ '@nrwl/js:babel',
38
+ '@nrwl/js:swc',
39
+ '@nrwl/webpack:webpack',
40
+ '@nrwl/rollup:rollup',
41
+ '@nrwl/web:rollup'
42
+ ],
43
+ serve: [
44
+ '@nxext/vite:dev',
45
+ '@nrwl/webpack:dev-server'
46
+ ],
47
+ test: [
48
+ '@nrwl/jest:jest',
49
+ '@nxext/vitest:vitest'
50
+ ]
51
+ };
52
+ const unsupportedExecutors = [
53
+ '@nrwl/angular:ng-packagr-lite',
54
+ '@nrwl/angular:package',
55
+ '@nrwl/angular:webpack-browser',
56
+ '@angular-devkit/build-angular:browser',
57
+ '@angular-devkit/build-angular:dev-server',
58
+ '@nrwl/esbuild:esbuild',
59
+ '@nrwl/react-native:run-ios',
60
+ '@nrwl/react-native:start',
61
+ '@nrwl/react-native:run-android',
62
+ '@nrwl/react-native:bundle',
63
+ '@nrwl/react-native:build-android',
64
+ '@nrwl/react-native:bundle',
65
+ '@nrwl/next:build',
66
+ '@nrwl/next:server',
67
+ '@nrwl/js:tsc'
68
+ ];
69
+ // First, we check if the user has provided a target
70
+ // If they have, we check if the executor the target is using is supported
71
+ // If it's not supported, then we set the unsupported flag to true for that target
72
+ function checkUserProvidedTarget(target) {
73
+ if (userProvidedTargets == null ? void 0 : userProvidedTargets[target]) {
74
+ var ref;
75
+ if (supportedExecutors[target].includes((ref = targets[userProvidedTargets[target]]) == null ? void 0 : ref.executor)) {
76
+ output.validFoundTargetName[target] = userProvidedTargets[target];
77
+ } else {
78
+ output.userProvidedTargetIsUnsupported[target] = true;
79
+ }
80
+ }
81
+ }
82
+ checkUserProvidedTarget('build');
83
+ checkUserProvidedTarget('serve');
84
+ checkUserProvidedTarget('test');
85
+ // Returns early when we have a build, serve, and test targets.
86
+ if (output.validFoundTargetName.build && output.validFoundTargetName.serve && output.validFoundTargetName.test) {
87
+ return output;
88
+ }
89
+ // We try to find the targets that are using the supported executors
90
+ // for build, serve and test, since these are the ones we will be converting
91
+ for(const target in targets){
92
+ const executorName = targets[target].executor;
93
+ const hasViteTargets = output.alreadyHasNxViteTargets;
94
+ (_hasViteTargets = hasViteTargets).build || (_hasViteTargets.build = executorName === '@nrwl/vite:build');
95
+ (_hasViteTargets1 = hasViteTargets).serve || (_hasViteTargets1.serve = executorName === '@nrwl/vite:dev-server');
96
+ (_hasViteTargets2 = hasViteTargets).test || (_hasViteTargets2.test = executorName === '@nrwl/vite:test');
97
+ (_hasViteTargets3 = hasViteTargets).preview || (_hasViteTargets3.preview = executorName === '@nrwl/vite:preview-server');
98
+ const foundTargets = output.validFoundTargetName;
99
+ if (!foundTargets.build && supportedExecutors.build.includes(executorName)) {
100
+ foundTargets.build = target;
101
+ }
102
+ if (!foundTargets.serve && supportedExecutors.serve.includes(executorName)) {
103
+ foundTargets.serve = target;
104
+ }
105
+ if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {
106
+ foundTargets.test = target;
107
+ }
108
+ (_output = output).projectContainsUnsupportedExecutor || (_output.projectContainsUnsupportedExecutor = unsupportedExecutors.includes(executorName));
109
+ }
110
+ return output;
111
+ }
112
+ function addOrChangeTestTarget(tree, options, target) {
113
+ const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
114
+ const coveragePath = (0, _devkit.joinPathFragments)('coverage', project.root === '.' ? options.project : project.root);
115
+ const testOptions = {
116
+ passWithNoTests: true,
117
+ // vitest runs in the project root so we have to offset to the workspaceRoot
118
+ reportsDirectory: (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(project.root), coveragePath)
119
+ };
120
+ var _targets;
121
+ (_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
122
+ if (project.targets[target]) {
123
+ var ref;
124
+ project.targets[target].executor = '@nrwl/vite:test';
125
+ (ref = project.targets[target].options) == null ? void 0 : delete ref.jestConfig;
126
+ } else {
127
+ project.targets[target] = {
128
+ executor: '@nrwl/vite:test',
129
+ outputs: [
130
+ coveragePath
131
+ ],
132
+ options: testOptions
133
+ };
134
+ }
135
+ (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
136
+ }
137
+ function addOrChangeBuildTarget(tree, options, target) {
138
+ const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
139
+ const buildOptions = {
140
+ outputPath: (0, _devkit.joinPathFragments)('dist', project.root != '.' ? project.root : options.project)
141
+ };
142
+ var _targets;
143
+ (_targets = (_project1 = project).targets) != null ? _targets : _project1.targets = {};
144
+ if (project.targets[target]) {
145
+ var ref;
146
+ buildOptions.fileReplacements = (ref = project.targets[target].options) == null ? void 0 : ref.fileReplacements;
147
+ if (project.targets[target].executor === '@nxext/vite:build') {
148
+ var ref1, ref2;
149
+ buildOptions.base = (ref1 = project.targets[target].options) == null ? void 0 : ref1.baseHref;
150
+ buildOptions.sourcemap = (ref2 = project.targets[target].options) == null ? void 0 : ref2.sourcemaps;
151
+ }
152
+ project.targets[target].options = _extends({}, buildOptions);
153
+ project.targets[target].executor = '@nrwl/vite:build';
154
+ } else {
155
+ project.targets[target] = {
156
+ executor: '@nrwl/vite:build',
157
+ outputs: [
158
+ '{options.outputPath}'
159
+ ],
160
+ defaultConfiguration: 'production',
161
+ options: buildOptions,
162
+ configurations: {
163
+ development: {
164
+ mode: 'development'
165
+ },
166
+ production: {
167
+ mode: 'production'
168
+ }
169
+ }
170
+ };
171
+ }
172
+ (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
173
+ }
174
+ function addOrChangeServeTarget(tree, options, target) {
175
+ const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
176
+ var _targets;
177
+ (_targets = (_project2 = project).targets) != null ? _targets : _project2.targets = {};
178
+ if (project.targets[target]) {
179
+ var ref, ref1, ref2;
180
+ const serveTarget = project.targets[target];
181
+ const serveOptions = {
182
+ buildTarget: `${options.project}:build`,
183
+ https: (ref = project.targets[target].options) == null ? void 0 : ref.https,
184
+ hmr: (ref1 = project.targets[target].options) == null ? void 0 : ref1.hmr,
185
+ open: (ref2 = project.targets[target].options) == null ? void 0 : ref2.open
186
+ };
187
+ if (serveTarget.executor === '@nxext/vite:dev') {
188
+ serveOptions.proxyConfig = project.targets[target].options.proxyConfig;
189
+ }
190
+ serveTarget.executor = '@nrwl/vite:dev-server';
191
+ serveTarget.options = serveOptions;
192
+ } else {
193
+ project.targets[target] = {
194
+ executor: '@nrwl/vite:dev-server',
195
+ defaultConfiguration: 'development',
196
+ options: {
197
+ buildTarget: `${options.project}:build`
198
+ },
199
+ configurations: {
200
+ development: {
201
+ buildTarget: `${options.project}:build:development`,
202
+ hmr: true
203
+ },
204
+ production: {
205
+ buildTarget: `${options.project}:build:production`,
206
+ hmr: false
207
+ }
208
+ }
209
+ };
210
+ }
211
+ (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
212
+ }
213
+ function addPreviewTarget(tree, options, serveTarget) {
214
+ const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
215
+ const previewOptions = {
216
+ buildTarget: `${options.project}:build`
217
+ };
218
+ var _targets;
219
+ (_targets = (_project3 = project).targets) != null ? _targets : _project3.targets = {};
220
+ // Update the options from the passed serve target.
221
+ if (project.targets[serveTarget]) {
222
+ var ref, ref1;
223
+ const target = project.targets[serveTarget];
224
+ if (target.executor === '@nxext/vite:dev') {
225
+ previewOptions.proxyConfig = target.options.proxyConfig;
226
+ }
227
+ previewOptions.https = (ref = target.options) == null ? void 0 : ref.https;
228
+ previewOptions.open = (ref1 = target.options) == null ? void 0 : ref1.open;
229
+ }
230
+ // Adds a preview target.
231
+ project.targets.preview = {
232
+ executor: '@nrwl/vite:preview-server',
233
+ defaultConfiguration: 'development',
234
+ options: previewOptions,
235
+ configurations: {
236
+ development: {
237
+ buildTarget: `${options.project}:build:development`
238
+ },
239
+ production: {
240
+ buildTarget: `${options.project}:build:production`
241
+ }
242
+ }
243
+ };
244
+ (0, _devkit.updateProjectConfiguration)(tree, options.project, project);
245
+ }
246
+ function editTsConfig(tree, options) {
247
+ const projectConfig = (0, _devkit.readProjectConfiguration)(tree, options.project);
248
+ const config = (0, _devkit.readJson)(tree, `${projectConfig.root}/tsconfig.json`);
249
+ const commonCompilerOptions = {
250
+ target: 'ESNext',
251
+ useDefineForClassFields: true,
252
+ module: 'ESNext',
253
+ strict: true,
254
+ moduleResolution: 'Node',
255
+ resolveJsonModule: true,
256
+ isolatedModules: true,
257
+ types: [
258
+ 'vite/client'
259
+ ],
260
+ noEmit: true
261
+ };
262
+ switch(options.uiFramework){
263
+ case 'react':
264
+ config.compilerOptions = _extends({}, commonCompilerOptions, {
265
+ lib: [
266
+ 'DOM',
267
+ 'DOM.Iterable',
268
+ 'ESNext'
269
+ ],
270
+ allowJs: false,
271
+ esModuleInterop: false,
272
+ skipLibCheck: true,
273
+ allowSyntheticDefaultImports: true,
274
+ forceConsistentCasingInFileNames: true,
275
+ jsx: 'react-jsx'
276
+ });
277
+ config.include = [
278
+ ...config.include,
279
+ 'src'
280
+ ];
281
+ break;
282
+ case 'none':
283
+ config.compilerOptions = _extends({}, commonCompilerOptions, {
284
+ lib: [
285
+ 'ESNext',
286
+ 'DOM'
287
+ ],
288
+ skipLibCheck: true,
289
+ esModuleInterop: true,
290
+ strict: true,
291
+ noUnusedLocals: true,
292
+ noUnusedParameters: true,
293
+ noImplicitReturns: true
294
+ });
295
+ config.include = [
296
+ ...config.include,
297
+ 'src'
298
+ ];
299
+ break;
300
+ default:
301
+ break;
302
+ }
303
+ (0, _devkit.writeJson)(tree, `${projectConfig.root}/tsconfig.json`, config);
304
+ }
305
+ function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
306
+ 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;
307
+ if (webpackConfigPath) {
308
+ tree.delete(webpackConfigPath);
309
+ }
310
+ }
311
+ function moveAndEditIndexHtml(tree, options, buildTarget) {
312
+ var ref, ref1, ref2, ref3, ref4, ref5;
313
+ const projectConfig = (0, _devkit.readProjectConfiguration)(tree, options.project);
314
+ var ref6;
315
+ let indexHtmlPath = (ref6 = (ref = projectConfig.targets) == null ? void 0 : (ref1 = ref[buildTarget]) == null ? void 0 : (ref2 = ref1.options) == null ? void 0 : ref2.index) != null ? ref6 : `${projectConfig.root}/src/index.html`;
316
+ var ref7;
317
+ let mainPath = (ref7 = (ref3 = projectConfig.targets) == null ? void 0 : (ref4 = ref3[buildTarget]) == null ? void 0 : (ref5 = ref4.options) == null ? void 0 : ref5.main) != null ? ref7 : `${projectConfig.root}/src/main.ts${options.uiFramework === 'react' ? 'x' : ''}`;
318
+ if (projectConfig.root !== '.') {
319
+ mainPath = mainPath.replace(projectConfig.root, '');
320
+ }
321
+ if (!tree.exists(indexHtmlPath) && tree.exists(`${projectConfig.root}/index.html`)) {
322
+ indexHtmlPath = `${projectConfig.root}/index.html`;
323
+ }
324
+ if (tree.exists(indexHtmlPath)) {
325
+ const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');
326
+ if (!indexHtmlContent.includes(`<script type="module" src="${mainPath}"></script>`)) {
327
+ tree.write(`${projectConfig.root}/index.html`, indexHtmlContent.replace('</body>', `<script type="module" src="${mainPath}"></script>
328
+ </body>`));
329
+ if (tree.exists(`${projectConfig.root}/src/index.html`)) {
330
+ tree.delete(`${projectConfig.root}/src/index.html`);
331
+ }
332
+ }
333
+ } else {
334
+ tree.write(`${projectConfig.root}/index.html`, `<!DOCTYPE html>
335
+ <html lang="en">
336
+ <head>
337
+ <meta charset="UTF-8" />
338
+ <link rel="icon" href="/favicon.ico" />
339
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
340
+ <title>Vite</title>
341
+ </head>
342
+ <body>
343
+ <div id="root"></div>
344
+ <script type="module" src="${mainPath}"></script>
345
+ </body>
346
+ </html>`);
347
+ }
348
+ }
349
+ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasViteTargets) {
350
+ const projectConfig = (0, _devkit.readProjectConfiguration)(tree, options.project);
351
+ const viteConfigPath = `${projectConfig.root}/vite.config.ts`;
352
+ const buildOption = onlyVitest ? '' : options.includeLib ? `
353
+ // Configuration for building your library.
354
+ // See: https://vitejs.dev/guide/build.html#library-mode
355
+ build: {
356
+ lib: {
357
+ // Could also be a dictionary or array of multiple entry points.
358
+ entry: 'src/index.ts',
359
+ name: '${options.project}',
360
+ fileName: 'index',
361
+ // Change this to the formats you want to support.
362
+ // Don't forgot to update your package.json as well.
363
+ formats: ['es', 'cjs']
364
+ },
365
+ rollupOptions: {
366
+ // External packages that should not be bundled into your library.
367
+ external: [${options.uiFramework === 'react' ? "'react', 'react-dom', 'react/jsx-runtime'" : ''}]
368
+ }
369
+ },` : ``;
370
+ const dtsPlugin = onlyVitest ? '' : options.includeLib ? `dts({
371
+ entryRoot: 'src',
372
+ tsConfigFilePath: join(__dirname, 'tsconfig.lib.json'),
373
+ skipDiagnostics: true,
374
+ }),` : '';
375
+ const dtsImportLine = onlyVitest ? '' : options.includeLib ? `import dts from 'vite-plugin-dts';\nimport { join } from 'path';` : '';
376
+ let viteConfigContent = '';
377
+ const testOption = options.includeVitest ? `test: {
378
+ globals: true,
379
+ cache: {
380
+ dir: '${(0, _devkit.offsetFromRoot)(projectConfig.root)}node_modules/.vitest'
381
+ },
382
+ environment: 'jsdom',
383
+ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
384
+ ${options.inSourceTests ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']` : ''}
385
+ },` : '';
386
+ const defineOption = options.inSourceTests ? `define: {
387
+ 'import.meta.vitest': undefined
388
+ },` : '';
389
+ const reactPluginImportLine = options.uiFramework === 'react' ? `import react from '@vitejs/plugin-react';` : '';
390
+ const reactPlugin = options.uiFramework === 'react' ? `react(),` : '';
391
+ const devServerOption = onlyVitest ? '' : options.includeLib ? '' : `
392
+ server:{
393
+ port: 4200,
394
+ host: 'localhost',
395
+ },`;
396
+ const previewServerOption = onlyVitest ? '' : options.includeLib ? '' : `
397
+ preview:{
398
+ port: 4300,
399
+ host: 'localhost',
400
+ },`;
401
+ const pluginOption = `
402
+ plugins: [
403
+ ${dtsPlugin}
404
+ ${reactPlugin}
405
+ viteTsConfigPaths({
406
+ root: '${(0, _devkit.offsetFromRoot)(projectConfig.root)}',
407
+ }),
408
+ ],
409
+ `;
410
+ const workerOption = `
411
+ // Uncomment this if you are using workers.
412
+ // worker: {
413
+ // plugins: [
414
+ // viteTsConfigPaths({
415
+ // root: '${(0, _devkit.offsetFromRoot)(projectConfig.root)}',
416
+ // }),
417
+ // ],
418
+ // },`;
419
+ const cacheDir = `cacheDir: '${(0, _devkit.offsetFromRoot)(projectConfig.root)}node_modules/.vite/${options.project}',`;
420
+ if (tree.exists(viteConfigPath)) {
421
+ handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, dtsPlugin, dtsImportLine, pluginOption, testOption, cacheDir, (0, _devkit.offsetFromRoot)(projectConfig.root), projectAlreadyHasViteTargets);
422
+ return;
423
+ }
424
+ viteConfigContent = `
425
+ /// <reference types="vitest" />
426
+ import { defineConfig } from 'vite';
427
+ ${reactPluginImportLine}
428
+ import viteTsConfigPaths from 'vite-tsconfig-paths';
429
+ ${dtsImportLine}
430
+
431
+ export default defineConfig({
432
+ ${cacheDir}
433
+ ${devServerOption}
434
+ ${previewServerOption}
435
+ ${pluginOption}
436
+ ${workerOption}
437
+ ${buildOption}
438
+ ${defineOption}
439
+ ${testOption}
440
+ });`;
441
+ tree.write(viteConfigPath, viteConfigContent);
442
+ }
443
+ function normalizeViteConfigFilePathWithTree(tree, projectRoot, configFile) {
444
+ 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;
445
+ }
446
+ function getViteConfigPathForProject(tree, projectName, target) {
447
+ let viteConfigPath;
448
+ const { targets , root } = (0, _devkit.readProjectConfiguration)(tree, projectName);
449
+ if (target) {
450
+ var ref, ref1;
451
+ viteConfigPath = targets == null ? void 0 : (ref = targets[target]) == null ? void 0 : (ref1 = ref.options) == null ? void 0 : ref1.configFile;
452
+ } else {
453
+ var ref2;
454
+ const config = Object.values(targets).find((config)=>config.executor === '@nrwl/vite:build');
455
+ viteConfigPath = config == null ? void 0 : (ref2 = config.options) == null ? void 0 : ref2.configFile;
456
+ }
457
+ return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);
458
+ }
459
+ async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName) {
460
+ if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
461
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build', 'build');
462
+ }
463
+ if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {
464
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve', 'dev-server');
465
+ }
466
+ if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {
467
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.test, validFoundTargetName.test, 'test', 'test');
468
+ }
469
+ }
470
+ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
471
+ _devkit.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nrwl/vite:${executor} executor.
472
+ However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
473
+
474
+ Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
475
+ your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
476
+ `);
477
+ const { Confirm } = require('enquirer');
478
+ const prompt = new Confirm({
479
+ name: 'question',
480
+ message: `Should we convert the ${validFoundTargetName} target to use the @nrwl/vite:${executor} executor?`,
481
+ initial: true
482
+ });
483
+ const shouldConvert = await prompt.run();
484
+ if (!shouldConvert) {
485
+ throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nrwl/vite:${executor} executor.
486
+ Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
487
+ convert the first one it finds, most probably this one: ${validFoundTargetName})
488
+
489
+ Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
490
+ your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
491
+ `);
492
+ }
493
+ }
494
+ async function handleUnknownExecutors(projectName) {
495
+ _devkit.logger.warn(`
496
+ We could not find any targets in project ${projectName} that use executors which
497
+ can be converted to the @nrwl/vite executors.
498
+
499
+ This either means that your project may not have a target
500
+ for building, serving, or testing at all, or that your targets are
501
+ using executors that are not known to Nx.
502
+
503
+ If you still want to convert your project to use the @nrwl/vite executors,
504
+ please make sure to commit your changes before running this generator.
505
+ `);
506
+ const { Confirm } = require('enquirer');
507
+ const prompt = new Confirm({
508
+ name: 'question',
509
+ message: `Should Nx convert your project to use the @nrwl/vite executors?`,
510
+ initial: true
511
+ });
512
+ const shouldConvert = await prompt.run();
513
+ if (!shouldConvert) {
514
+ throw new Error(`
515
+ Nx could not verify that the executors you are using can be converted to the @nrwl/vite executors.
516
+ Please try again with a different project.
517
+ `);
518
+ }
519
+ }
520
+ function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, dtsPlugin, dtsImportLine, pluginOption, testOption, cacheDir, offsetFromRoot, projectAlreadyHasViteTargets) {
521
+ if (projectAlreadyHasViteTargets.build && projectAlreadyHasViteTargets.test) {
522
+ return;
523
+ }
524
+ _devkit.logger.info(`vite.config.ts already exists for project ${options.project}.`);
525
+ const buildOptionObject = {
526
+ lib: {
527
+ entry: 'src/index.ts',
528
+ name: options.project,
529
+ fileName: 'index',
530
+ formats: [
531
+ 'es',
532
+ 'cjs'
533
+ ]
534
+ },
535
+ rollupOptions: {
536
+ external: options.uiFramework === 'react' ? [
537
+ 'react',
538
+ 'react-dom',
539
+ 'react/jsx-runtime'
540
+ ] : []
541
+ }
542
+ };
543
+ const testOptionObject = {
544
+ globals: true,
545
+ cache: {
546
+ dir: `${offsetFromRoot}node_modules/.vitest`
547
+ },
548
+ environment: 'jsdom',
549
+ include: [
550
+ 'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
551
+ ]
552
+ };
553
+ const changed = (0, _viteConfigEditUtils.ensureViteConfigIsCorrect)(tree, viteConfigPath, buildOption, buildOptionObject, dtsPlugin, dtsImportLine, pluginOption, testOption, testOptionObject, cacheDir, projectAlreadyHasViteTargets);
554
+ if (!changed) {
555
+ _devkit.logger.warn(`Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):
556
+
557
+ ${buildOption}
558
+
559
+ `);
560
+ } else {
561
+ _devkit.logger.info(`
562
+ Vite configuration file (${viteConfigPath}) has been updated with the required settings for the new target(s).
563
+ `);
564
+ }
565
+ }
566
+
567
+ //# sourceMappingURL=generator-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/vite/src/utils/generator-utils.ts"],"sourcesContent":["import {\n joinPathFragments,\n logger,\n offsetFromRoot,\n readJson,\n readProjectConfiguration,\n TargetConfiguration,\n Tree,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { ViteBuildExecutorOptions } from '../executors/build/schema';\nimport { ViteDevServerExecutorOptions } from '../executors/dev-server/schema';\nimport { VitePreviewServerExecutorOptions } from '../executors/preview-server/schema';\nimport { VitestExecutorOptions } from '../executors/test/schema';\nimport { ViteConfigurationGeneratorSchema } from '../generators/configuration/schema';\nimport { ensureViteConfigIsCorrect } from './vite-config-edit-utils';\n\nexport type Target = 'build' | 'serve' | 'test' | 'preview';\nexport type TargetFlags = Partial<Record<Target, boolean>>;\nexport type UserProvidedTargetName = Partial<Record<Target, string>>;\nexport type ValidFoundTargetName = Partial<Record<Target, string>>;\n\nexport function findExistingTargetsInProject(\n targets: {\n [targetName: string]: TargetConfiguration;\n },\n userProvidedTargets?: UserProvidedTargetName\n): {\n validFoundTargetName: ValidFoundTargetName;\n projectContainsUnsupportedExecutor: boolean;\n userProvidedTargetIsUnsupported: TargetFlags;\n alreadyHasNxViteTargets: TargetFlags;\n} {\n const output: ReturnType<typeof findExistingTargetsInProject> = {\n validFoundTargetName: {},\n projectContainsUnsupportedExecutor: false,\n userProvidedTargetIsUnsupported: {},\n alreadyHasNxViteTargets: {},\n };\n\n const supportedExecutors = {\n build: [\n '@nxext/vite:build',\n '@nrwl/js:babel',\n '@nrwl/js:swc',\n '@nrwl/webpack:webpack',\n '@nrwl/rollup:rollup',\n '@nrwl/web:rollup',\n ],\n serve: ['@nxext/vite:dev', '@nrwl/webpack:dev-server'],\n test: ['@nrwl/jest:jest', '@nxext/vitest:vitest'],\n };\n\n const unsupportedExecutors = [\n '@nrwl/angular:ng-packagr-lite',\n '@nrwl/angular:package',\n '@nrwl/angular:webpack-browser',\n '@angular-devkit/build-angular:browser',\n '@angular-devkit/build-angular:dev-server',\n '@nrwl/esbuild:esbuild',\n '@nrwl/react-native:run-ios',\n '@nrwl/react-native:start',\n '@nrwl/react-native:run-android',\n '@nrwl/react-native:bundle',\n '@nrwl/react-native:build-android',\n '@nrwl/react-native:bundle',\n '@nrwl/next:build',\n '@nrwl/next:server',\n '@nrwl/js:tsc',\n ];\n\n // First, we check if the user has provided a target\n // If they have, we check if the executor the target is using is supported\n // If it's not supported, then we set the unsupported flag to true for that target\n\n function checkUserProvidedTarget(target: Target) {\n if (userProvidedTargets?.[target]) {\n if (\n supportedExecutors[target].includes(\n targets[userProvidedTargets[target]]?.executor\n )\n ) {\n output.validFoundTargetName[target] = userProvidedTargets[target];\n } else {\n output.userProvidedTargetIsUnsupported[target] = true;\n }\n }\n }\n\n checkUserProvidedTarget('build');\n checkUserProvidedTarget('serve');\n checkUserProvidedTarget('test');\n\n // Returns early when we have a build, serve, and test targets.\n if (\n output.validFoundTargetName.build &&\n output.validFoundTargetName.serve &&\n output.validFoundTargetName.test\n ) {\n return output;\n }\n\n // We try to find the targets that are using the supported executors\n // for build, serve and test, since these are the ones we will be converting\n for (const target in targets) {\n const executorName = targets[target].executor;\n\n const hasViteTargets = output.alreadyHasNxViteTargets;\n hasViteTargets.build ||= executorName === '@nrwl/vite:build';\n hasViteTargets.serve ||= executorName === '@nrwl/vite:dev-server';\n hasViteTargets.test ||= executorName === '@nrwl/vite:test';\n hasViteTargets.preview ||= executorName === '@nrwl/vite:preview-server';\n\n const foundTargets = output.validFoundTargetName;\n if (\n !foundTargets.build &&\n supportedExecutors.build.includes(executorName)\n ) {\n foundTargets.build = target;\n }\n if (\n !foundTargets.serve &&\n supportedExecutors.serve.includes(executorName)\n ) {\n foundTargets.serve = target;\n }\n if (!foundTargets.test && supportedExecutors.test.includes(executorName)) {\n foundTargets.test = target;\n }\n\n output.projectContainsUnsupportedExecutor ||=\n unsupportedExecutors.includes(executorName);\n }\n\n return output;\n}\n\nexport function addOrChangeTestTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const coveragePath = joinPathFragments(\n 'coverage',\n project.root === '.' ? options.project : project.root\n );\n const testOptions: VitestExecutorOptions = {\n passWithNoTests: true,\n // vitest runs in the project root so we have to offset to the workspaceRoot\n reportsDirectory: joinPathFragments(\n offsetFromRoot(project.root),\n coveragePath\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n project.targets[target].executor = '@nrwl/vite:test';\n delete project.targets[target].options?.jestConfig;\n } else {\n project.targets[target] = {\n executor: '@nrwl/vite:test',\n outputs: [coveragePath],\n options: testOptions,\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeBuildTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n const buildOptions: ViteBuildExecutorOptions = {\n outputPath: joinPathFragments(\n 'dist',\n project.root != '.' ? project.root : options.project\n ),\n };\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n buildOptions.fileReplacements =\n project.targets[target].options?.fileReplacements;\n\n if (project.targets[target].executor === '@nxext/vite:build') {\n buildOptions.base = project.targets[target].options?.baseHref;\n buildOptions.sourcemap = project.targets[target].options?.sourcemaps;\n }\n project.targets[target].options = { ...buildOptions };\n project.targets[target].executor = '@nrwl/vite:build';\n } else {\n project.targets[target] = {\n executor: '@nrwl/vite:build',\n outputs: ['{options.outputPath}'],\n defaultConfiguration: 'production',\n options: buildOptions,\n configurations: {\n development: {\n mode: 'development',\n },\n production: {\n mode: 'production',\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function addOrChangeServeTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n target: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n project.targets ??= {};\n\n if (project.targets[target]) {\n const serveTarget = project.targets[target];\n const serveOptions: ViteDevServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n https: project.targets[target].options?.https,\n hmr: project.targets[target].options?.hmr,\n open: project.targets[target].options?.open,\n };\n if (serveTarget.executor === '@nxext/vite:dev') {\n serveOptions.proxyConfig = project.targets[target].options.proxyConfig;\n }\n serveTarget.executor = '@nrwl/vite:dev-server';\n serveTarget.options = serveOptions;\n } else {\n project.targets[target] = {\n executor: '@nrwl/vite:dev-server',\n defaultConfiguration: 'development',\n options: {\n buildTarget: `${options.project}:build`,\n },\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n hmr: true,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n hmr: false,\n },\n },\n };\n }\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\n/**\n * Adds a target for the preview server.\n *\n * @param tree\n * @param options\n * @param serveTarget An existing serve target.\n * @param previewTarget The preview target to create.\n */\nexport function addPreviewTarget(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n serveTarget: string\n) {\n const project = readProjectConfiguration(tree, options.project);\n\n const previewOptions: VitePreviewServerExecutorOptions = {\n buildTarget: `${options.project}:build`,\n };\n\n project.targets ??= {};\n\n // Update the options from the passed serve target.\n if (project.targets[serveTarget]) {\n const target = project.targets[serveTarget];\n if (target.executor === '@nxext/vite:dev') {\n previewOptions.proxyConfig = target.options.proxyConfig;\n }\n previewOptions.https = target.options?.https;\n previewOptions.open = target.options?.open;\n }\n\n // Adds a preview target.\n project.targets.preview = {\n executor: '@nrwl/vite:preview-server',\n defaultConfiguration: 'development',\n options: previewOptions,\n configurations: {\n development: {\n buildTarget: `${options.project}:build:development`,\n },\n production: {\n buildTarget: `${options.project}:build:production`,\n },\n },\n };\n\n updateProjectConfiguration(tree, options.project, project);\n}\n\nexport function editTsConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const config = readJson(tree, `${projectConfig.root}/tsconfig.json`);\n\n const commonCompilerOptions = {\n target: 'ESNext',\n useDefineForClassFields: true,\n module: 'ESNext',\n strict: true,\n moduleResolution: 'Node',\n resolveJsonModule: true,\n isolatedModules: true,\n types: ['vite/client'],\n noEmit: true,\n };\n\n switch (options.uiFramework) {\n case 'react':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['DOM', 'DOM.Iterable', 'ESNext'],\n allowJs: false,\n esModuleInterop: false,\n skipLibCheck: true,\n allowSyntheticDefaultImports: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n };\n config.include = [...config.include, 'src'];\n break;\n case 'none':\n config.compilerOptions = {\n ...commonCompilerOptions,\n lib: ['ESNext', 'DOM'],\n skipLibCheck: true,\n esModuleInterop: true,\n strict: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n noImplicitReturns: true,\n };\n config.include = [...config.include, 'src'];\n break;\n default:\n break;\n }\n\n writeJson(tree, `${projectConfig.root}/tsconfig.json`, config);\n}\n\nexport function deleteWebpackConfig(\n tree: Tree,\n projectRoot: string,\n webpackConfigFilePath?: string\n) {\n const webpackConfigPath =\n webpackConfigFilePath && tree.exists(webpackConfigFilePath)\n ? webpackConfigFilePath\n : tree.exists(`${projectRoot}/webpack.config.js`)\n ? `${projectRoot}/webpack.config.js`\n : tree.exists(`${projectRoot}/webpack.config.ts`)\n ? `${projectRoot}/webpack.config.ts`\n : null;\n if (webpackConfigPath) {\n tree.delete(webpackConfigPath);\n }\n}\n\nexport function moveAndEditIndexHtml(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n buildTarget: string\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n let indexHtmlPath =\n projectConfig.targets?.[buildTarget]?.options?.index ??\n `${projectConfig.root}/src/index.html`;\n let mainPath =\n projectConfig.targets?.[buildTarget]?.options?.main ??\n `${projectConfig.root}/src/main.ts${\n options.uiFramework === 'react' ? 'x' : ''\n }`;\n\n if (projectConfig.root !== '.') {\n mainPath = mainPath.replace(projectConfig.root, '');\n }\n\n if (\n !tree.exists(indexHtmlPath) &&\n tree.exists(`${projectConfig.root}/index.html`)\n ) {\n indexHtmlPath = `${projectConfig.root}/index.html`;\n }\n\n if (tree.exists(indexHtmlPath)) {\n const indexHtmlContent = tree.read(indexHtmlPath, 'utf8');\n if (\n !indexHtmlContent.includes(\n `<script type=\"module\" src=\"${mainPath}\"></script>`\n )\n ) {\n tree.write(\n `${projectConfig.root}/index.html`,\n indexHtmlContent.replace(\n '</body>',\n `<script type=\"module\" src=\"${mainPath}\"></script>\n </body>`\n )\n );\n\n if (tree.exists(`${projectConfig.root}/src/index.html`)) {\n tree.delete(`${projectConfig.root}/src/index.html`);\n }\n }\n } else {\n tree.write(\n `${projectConfig.root}/index.html`,\n `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" href=\"/favicon.ico\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Vite</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"${mainPath}\"></script>\n </body>\n </html>`\n );\n }\n}\n\nexport function createOrEditViteConfig(\n tree: Tree,\n options: ViteConfigurationGeneratorSchema,\n onlyVitest: boolean,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n const projectConfig = readProjectConfiguration(tree, options.project);\n\n const viteConfigPath = `${projectConfig.root}/vite.config.ts`;\n\n const buildOption = onlyVitest\n ? ''\n : options.includeLib\n ? `\n // Configuration for building your library.\n // See: https://vitejs.dev/guide/build.html#library-mode\n build: {\n lib: {\n // Could also be a dictionary or array of multiple entry points.\n entry: 'src/index.ts',\n name: '${options.project}',\n fileName: 'index',\n // Change this to the formats you want to support.\n // Don't forgot to update your package.json as well.\n formats: ['es', 'cjs']\n },\n rollupOptions: {\n // External packages that should not be bundled into your library.\n external: [${\n options.uiFramework === 'react'\n ? \"'react', 'react-dom', 'react/jsx-runtime'\"\n : ''\n }]\n }\n },`\n : ``;\n\n const dtsPlugin = onlyVitest\n ? ''\n : options.includeLib\n ? `dts({\n entryRoot: 'src',\n tsConfigFilePath: join(__dirname, 'tsconfig.lib.json'),\n skipDiagnostics: true,\n }),`\n : '';\n\n const dtsImportLine = onlyVitest\n ? ''\n : options.includeLib\n ? `import dts from 'vite-plugin-dts';\\nimport { join } from 'path';`\n : '';\n\n let viteConfigContent = '';\n\n const testOption = options.includeVitest\n ? `test: {\n globals: true,\n cache: {\n dir: '${offsetFromRoot(projectConfig.root)}node_modules/.vitest'\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n ${\n options.inSourceTests\n ? `includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']`\n : ''\n }\n },`\n : '';\n\n const defineOption = options.inSourceTests\n ? `define: {\n 'import.meta.vitest': undefined\n },`\n : '';\n\n const reactPluginImportLine =\n options.uiFramework === 'react'\n ? `import react from '@vitejs/plugin-react';`\n : '';\n\n const reactPlugin = options.uiFramework === 'react' ? `react(),` : '';\n\n const devServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n server:{\n port: 4200,\n host: 'localhost',\n },`;\n\n const previewServerOption = onlyVitest\n ? ''\n : options.includeLib\n ? ''\n : `\n preview:{\n port: 4300,\n host: 'localhost',\n },`;\n\n const pluginOption = `\n plugins: [\n ${dtsPlugin}\n ${reactPlugin}\n viteTsConfigPaths({\n root: '${offsetFromRoot(projectConfig.root)}',\n }),\n ],\n `;\n\n const workerOption = `\n // Uncomment this if you are using workers. \n // worker: {\n // plugins: [\n // viteTsConfigPaths({\n // root: '${offsetFromRoot(projectConfig.root)}',\n // }),\n // ],\n // },`;\n\n const cacheDir = `cacheDir: '${offsetFromRoot(\n projectConfig.root\n )}node_modules/.vite/${options.project}',`;\n\n if (tree.exists(viteConfigPath)) {\n handleViteConfigFileExists(\n tree,\n viteConfigPath,\n options,\n buildOption,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\n testOption,\n cacheDir,\n offsetFromRoot(projectConfig.root),\n projectAlreadyHasViteTargets\n );\n return;\n }\n\n viteConfigContent = `\n /// <reference types=\"vitest\" />\n import { defineConfig } from 'vite';\n ${reactPluginImportLine}\n import viteTsConfigPaths from 'vite-tsconfig-paths';\n ${dtsImportLine}\n \n export default defineConfig({\n ${cacheDir}\n ${devServerOption}\n ${previewServerOption}\n ${pluginOption}\n ${workerOption}\n ${buildOption}\n ${defineOption}\n ${testOption}\n });`;\n\n tree.write(viteConfigPath, viteConfigContent);\n}\n\nexport function normalizeViteConfigFilePathWithTree(\n tree: Tree,\n projectRoot: string,\n configFile?: string\n): string {\n return configFile && tree.exists(configFile)\n ? configFile\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.ts`))\n ? joinPathFragments(`${projectRoot}/vite.config.ts`)\n : tree.exists(joinPathFragments(`${projectRoot}/vite.config.js`))\n ? joinPathFragments(`${projectRoot}/vite.config.js`)\n : undefined;\n}\n\nexport function getViteConfigPathForProject(\n tree: Tree,\n projectName: string,\n target?: string\n) {\n let viteConfigPath: string | undefined;\n const { targets, root } = readProjectConfiguration(tree, projectName);\n if (target) {\n viteConfigPath = targets?.[target]?.options?.configFile;\n } else {\n const config = Object.values(targets).find(\n (config) => config.executor === '@nrwl/vite:build'\n );\n viteConfigPath = config?.options?.configFile;\n }\n\n return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);\n}\n\nexport async function handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported: TargetFlags,\n userProvidedTargetName: UserProvidedTargetName,\n validFoundTargetName: ValidFoundTargetName\n) {\n if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.build,\n validFoundTargetName.build,\n 'build',\n 'build'\n );\n }\n\n if (userProvidedTargetIsUnsupported.serve && validFoundTargetName.serve) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.serve,\n validFoundTargetName.serve,\n 'serve',\n 'dev-server'\n );\n }\n\n if (userProvidedTargetIsUnsupported.test && validFoundTargetName.test) {\n await handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName.test,\n validFoundTargetName.test,\n 'test',\n 'test'\n );\n }\n}\n\nasync function handleUnsupportedUserProvidedTargetsErrors(\n userProvidedTargetName: string,\n validFoundTargetName: string,\n target: Target,\n executor: 'build' | 'dev-server' | 'test'\n) {\n logger.warn(\n `The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nrwl/vite:${executor} executor.\n However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should we convert the ${validFoundTargetName} target to use the @nrwl/vite:${executor} executor?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(\n `The ${target} target ${userProvidedTargetName} cannot be converted to use the @nrwl/vite:${executor} executor.\n Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will\n convert the first one it finds, most probably this one: ${validFoundTargetName})\n\n Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit\n your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.\n `\n );\n }\n}\n\nexport async function handleUnknownExecutors(projectName: string) {\n logger.warn(\n `\n We could not find any targets in project ${projectName} that use executors which \n can be converted to the @nrwl/vite executors.\n\n This either means that your project may not have a target \n for building, serving, or testing at all, or that your targets are \n using executors that are not known to Nx.\n \n If you still want to convert your project to use the @nrwl/vite executors,\n please make sure to commit your changes before running this generator.\n `\n );\n\n const { Confirm } = require('enquirer');\n const prompt = new Confirm({\n name: 'question',\n message: `Should Nx convert your project to use the @nrwl/vite executors?`,\n initial: true,\n });\n const shouldConvert = await prompt.run();\n if (!shouldConvert) {\n throw new Error(`\n Nx could not verify that the executors you are using can be converted to the @nrwl/vite executors.\n Please try again with a different project.\n `);\n }\n}\n\nfunction handleViteConfigFileExists(\n tree: Tree,\n viteConfigPath: string,\n options: ViteConfigurationGeneratorSchema,\n buildOption: string,\n dtsPlugin: string,\n dtsImportLine: string,\n pluginOption: string,\n testOption: string,\n cacheDir: string,\n offsetFromRoot: string,\n projectAlreadyHasViteTargets?: TargetFlags\n) {\n if (projectAlreadyHasViteTargets.build && projectAlreadyHasViteTargets.test) {\n return;\n }\n\n logger.info(`vite.config.ts already exists for project ${options.project}.`);\n const buildOptionObject = {\n lib: {\n entry: 'src/index.ts',\n name: options.project,\n fileName: 'index',\n formats: ['es', 'cjs'],\n },\n rollupOptions: {\n external:\n options.uiFramework === 'react'\n ? ['react', 'react-dom', 'react/jsx-runtime']\n : [],\n },\n };\n\n const testOptionObject = {\n globals: true,\n cache: {\n dir: `${offsetFromRoot}node_modules/.vitest`,\n },\n environment: 'jsdom',\n include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n };\n\n const changed = ensureViteConfigIsCorrect(\n tree,\n viteConfigPath,\n buildOption,\n buildOptionObject,\n dtsPlugin,\n dtsImportLine,\n pluginOption,\n testOption,\n testOptionObject,\n cacheDir,\n projectAlreadyHasViteTargets\n );\n\n if (!changed) {\n logger.warn(\n `Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):\n \n ${buildOption}\n \n `\n );\n } else {\n logger.info(`\n Vite configuration file (${viteConfigPath}) has been updated with the required settings for the new target(s).\n `);\n }\n}\n"],"names":["findExistingTargetsInProject","addOrChangeTestTarget","addOrChangeBuildTarget","addOrChangeServeTarget","addPreviewTarget","editTsConfig","deleteWebpackConfig","moveAndEditIndexHtml","createOrEditViteConfig","normalizeViteConfigFilePathWithTree","getViteConfigPathForProject","handleUnsupportedUserProvidedTargets","handleUnknownExecutors","hasViteTargets","output","project","targets","userProvidedTargets","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","supportedExecutors","build","serve","test","unsupportedExecutors","checkUserProvidedTarget","target","includes","executor","executorName","preview","foundTargets","tree","options","readProjectConfiguration","coveragePath","joinPathFragments","root","testOptions","passWithNoTests","reportsDirectory","offsetFromRoot","jestConfig","outputs","updateProjectConfiguration","buildOptions","outputPath","fileReplacements","base","baseHref","sourcemap","sourcemaps","defaultConfiguration","configurations","development","mode","production","serveTarget","serveOptions","buildTarget","https","hmr","open","proxyConfig","previewOptions","projectConfig","config","readJson","commonCompilerOptions","useDefineForClassFields","module","strict","moduleResolution","resolveJsonModule","isolatedModules","types","noEmit","uiFramework","compilerOptions","lib","allowJs","esModuleInterop","skipLibCheck","allowSyntheticDefaultImports","forceConsistentCasingInFileNames","jsx","include","noUnusedLocals","noUnusedParameters","noImplicitReturns","writeJson","projectRoot","webpackConfigFilePath","webpackConfigPath","exists","delete","indexHtmlPath","index","mainPath","main","replace","indexHtmlContent","read","write","onlyVitest","projectAlreadyHasViteTargets","viteConfigPath","buildOption","includeLib","dtsPlugin","dtsImportLine","viteConfigContent","testOption","includeVitest","inSourceTests","defineOption","reactPluginImportLine","reactPlugin","devServerOption","previewServerOption","pluginOption","workerOption","cacheDir","handleViteConfigFileExists","configFile","undefined","projectName","Object","values","find","userProvidedTargetName","handleUnsupportedUserProvidedTargetsErrors","logger","warn","Confirm","require","prompt","name","message","initial","shouldConvert","run","Error","info","buildOptionObject","entry","fileName","formats","rollupOptions","external","testOptionObject","globals","cache","dir","environment","changed","ensureViteConfigIsCorrect"],"mappings":"AAAA;;;;;;;;IAuBgBA,4BAA4B,MAA5BA;IAmHAC,qBAAqB,MAArBA;IAoCAC,sBAAsB,MAAtBA;IA6CAC,sBAAsB,MAAtBA;IAqDAC,gBAAgB,MAAhBA;IAyCAC,YAAY,MAAZA;IAsDAC,mBAAmB,MAAnBA;IAkBAC,oBAAoB,MAApBA;IAmEAC,sBAAsB,MAAtBA;IAsKAC,mCAAmC,MAAnCA;IAcAC,2BAA2B,MAA3BA;IAmBMC,oCAAoC,MAApCA;IAmEAC,sBAAsB,MAAtBA;;;wBApsBf;qCAMmC;IA6FtCC,iBACAA,kBACAA,kBACAA,kBAmBAC,SA2BFC,UA6BAA,WAuCAA,WAyDAA;AApQK,SAASf,6BACdgB,OAEC,EACDC,mBAA4C,EAM5C;IACA,MAAMH,SAA0D;QAC9DI,sBAAsB,CAAC;QACvBC,oCAAoC,KAAK;QACzCC,iCAAiC,CAAC;QAClCC,yBAAyB,CAAC;IAC5B;IAEA,MAAMC,qBAAqB;QACzBC,OAAO;YACL;YACA;YACA;YACA;YACA;YACA;SACD;QACDC,OAAO;YAAC;YAAmB;SAA2B;QACtDC,MAAM;YAAC;YAAmB;SAAuB;IACnD;IAEA,MAAMC,uBAAuB;QAC3B;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,oDAAo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