@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,96 +1,86 @@
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
- default: function() {
10
- return _default;
11
- },
12
- viteDevServerExecutor: function() {
13
- return viteDevServerExecutor;
14
- }
15
- });
16
- const _extends = require("@swc/helpers/_/_extends");
17
- const _devkit = require("@nx/devkit");
18
- const _optionsutils = require("../../utils/options-utils");
19
- const _executorutils = require("../../utils/executor-utils");
20
- const _path = require("path");
21
- const _buildimpl = require("../build/build.impl");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.viteDevServerExecutor = viteDevServerExecutor;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const options_utils_1 = require("../../utils/options-utils");
6
+ const executor_utils_1 = require("../../utils/executor-utils");
7
+ const path_1 = require("path");
8
+ const build_impl_1 = require("../build/build.impl");
22
9
  async function* viteDevServerExecutor(options, context) {
23
10
  process.env.VITE_CJS_IGNORE_WARNING = 'true';
24
11
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
25
- const { mergeConfig, createServer, resolveConfig } = await (0, _executorutils.loadViteDynamicImport)();
12
+ const { mergeConfig, createServer, resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
26
13
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
27
- const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
28
- (0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
14
+ const root = projectRoot === '.'
15
+ ? process.cwd()
16
+ : (0, path_1.relative)(context.cwd, (0, devkit_1.joinPathFragments)(context.root, projectRoot));
17
+ (0, executor_utils_1.createBuildableTsConfig)(projectRoot, options, context);
29
18
  // Retrieve the option for the configured buildTarget.
30
- const buildTargetOptions = (0, _optionsutils.getNxTargetOptions)(options.buildTarget, context);
31
- const { configuration } = (0, _devkit.parseTargetString)(options.buildTarget, context);
32
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
33
- const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
19
+ const buildTargetOptions = (0, options_utils_1.getNxTargetOptions)(options.buildTarget, context);
20
+ const { configuration } = (0, devkit_1.parseTargetString)(options.buildTarget, context);
21
+ const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, build_impl_1.getBuildExtraArgs)(buildTargetOptions);
22
+ const viteConfigPath = (0, options_utils_1.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
34
23
  const { serverOptions, otherOptions } = await getServerExtraArgs(options, configuration, buildOptions, otherOptionsFromBuild);
35
- var _otherOptions_mode, _ref;
36
- const defaultMode = (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : buildTargetOptions == null ? void 0 : buildTargetOptions['mode']) != null ? _ref : 'development';
37
- var _process_env_NODE_ENV;
24
+ const defaultMode = otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development';
38
25
  const resolved = await resolveConfig({
39
26
  configFile: viteConfigPath,
40
- mode: defaultMode
41
- }, 'serve', defaultMode, (_process_env_NODE_ENV = process.env.NODE_ENV) != null ? _process_env_NODE_ENV : defaultMode);
42
- var _resolved_root;
27
+ mode: defaultMode,
28
+ }, 'serve', defaultMode, process.env.NODE_ENV ?? defaultMode);
43
29
  // vite InlineConfig
44
30
  const serverConfig = mergeConfig({
45
31
  // This should not be needed as it's going to be set in vite.config.ts
46
32
  // but leaving it here in case someone did not migrate correctly
47
- root: (_resolved_root = resolved.root) != null ? _resolved_root : root,
48
- configFile: viteConfigPath
49
- }, _extends._({
50
- server: _extends._({}, await (0, _optionsutils.getViteServerOptions)(options, context), serverOptions)
51
- }, otherOptions));
33
+ root: resolved.root ?? root,
34
+ configFile: viteConfigPath,
35
+ }, {
36
+ server: {
37
+ ...(await (0, options_utils_1.getViteServerOptions)(options, context)),
38
+ ...serverOptions,
39
+ },
40
+ ...otherOptions,
41
+ });
52
42
  try {
53
43
  const server = await createServer(serverConfig);
54
44
  await runViteDevServer(server);
55
45
  const resolvedUrls = [
56
46
  ...server.resolvedUrls.local,
57
- ...server.resolvedUrls.network
47
+ ...server.resolvedUrls.network,
58
48
  ];
59
- var _resolvedUrls_;
60
49
  yield {
61
50
  success: true,
62
- baseUrl: (_resolvedUrls_ = resolvedUrls[0]) != null ? _resolvedUrls_ : ''
51
+ baseUrl: resolvedUrls[0] ?? '',
63
52
  };
64
- } catch (e) {
53
+ }
54
+ catch (e) {
65
55
  console.error(e);
66
56
  yield {
67
57
  success: false,
68
- baseUrl: ''
58
+ baseUrl: '',
69
59
  };
70
60
  }
71
- await new Promise((resolve)=>{
72
- process.once('SIGINT', ()=>resolve());
73
- process.once('SIGTERM', ()=>resolve());
74
- process.once('exit', ()=>resolve());
61
+ await new Promise((resolve) => {
62
+ process.once('SIGINT', () => resolve());
63
+ process.once('SIGTERM', () => resolve());
64
+ process.once('exit', () => resolve());
75
65
  });
76
66
  }
77
67
  // vite ViteDevServer
78
68
  async function runViteDevServer(server) {
79
69
  await server.listen();
80
70
  server.printUrls();
81
- const processOnExit = async ()=>{
71
+ const processOnExit = async () => {
82
72
  await server.close();
83
73
  };
84
74
  process.once('SIGINT', processOnExit);
85
75
  process.once('SIGTERM', processOnExit);
86
76
  process.once('exit', processOnExit);
87
77
  }
88
- const _default = viteDevServerExecutor;
78
+ exports.default = viteDevServerExecutor;
89
79
  async function getServerExtraArgs(options, configuration, buildOptionsFromBuildTarget, otherOptionsFromBuildTarget) {
90
80
  // support passing extra args to vite cli
91
- const schema = await Promise.resolve().then(()=>require("./schema.json"));
81
+ const schema = await Promise.resolve().then(() => require('./schema.json'));
92
82
  const extraArgs = {};
93
- for (const key of Object.keys(options)){
83
+ for (const key of Object.keys(options)) {
94
84
  if (!schema.properties[key]) {
95
85
  extraArgs[key] = options[key];
96
86
  }
@@ -112,27 +102,29 @@ async function getServerExtraArgs(options, configuration, buildOptionsFromBuildT
112
102
  'open',
113
103
  'proxy',
114
104
  'cors',
115
- 'headers'
105
+ 'headers',
116
106
  ];
117
107
  let otherOptions = {};
118
- for (const key of Object.keys(extraArgs)){
108
+ for (const key of Object.keys(extraArgs)) {
119
109
  if (serverSchemaKeys.includes(key)) {
120
110
  serverOptions[key] = extraArgs[key];
121
- } else {
111
+ }
112
+ else {
122
113
  otherOptions[key] = extraArgs[key];
123
114
  }
124
115
  }
125
116
  if (configuration) {
126
- var _buildOptionsFromBuildTarget_watch;
127
- serverOptions = _extends._({}, serverOptions, {
128
- watch: (_buildOptionsFromBuildTarget_watch = buildOptionsFromBuildTarget == null ? void 0 : buildOptionsFromBuildTarget.watch) != null ? _buildOptionsFromBuildTarget_watch : serverOptions == null ? void 0 : serverOptions.watch
129
- });
130
- otherOptions = _extends._({}, otherOptions, otherOptionsFromBuildTarget != null ? otherOptionsFromBuildTarget : {});
117
+ serverOptions = {
118
+ ...serverOptions,
119
+ watch: buildOptionsFromBuildTarget?.watch ?? serverOptions?.watch,
120
+ };
121
+ otherOptions = {
122
+ ...otherOptions,
123
+ ...(otherOptionsFromBuildTarget ?? {}),
124
+ };
131
125
  }
132
126
  return {
133
127
  serverOptions,
134
- otherOptions
128
+ otherOptions,
135
129
  };
136
130
  }
137
-
138
- //# sourceMappingURL=dev-server.impl.js.map
@@ -1,2 +1,3 @@
1
1
  declare const _default: any;
2
2
  export default _default;
3
+ //# sourceMappingURL=compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/executors/preview-server/compat.ts"],"names":[],"mappings":";AAGA,wBAA4D"}
@@ -1,12 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "default", {
3
- enumerable: true,
4
- get: function() {
5
- return _default;
6
- }
7
- });
8
- const _devkit = require("@nx/devkit");
9
- const _previewserverimpl = require("./preview-server.impl");
10
- const _default = (0, _devkit.convertNxExecutor)(_previewserverimpl.default);
11
-
12
- //# sourceMappingURL=compat.js.map
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const preview_server_impl_1 = require("./preview-server.impl");
5
+ exports.default = (0, devkit_1.convertNxExecutor)(preview_server_impl_1.default);
@@ -5,3 +5,4 @@ export declare function vitePreviewServerExecutor(options: VitePreviewServerExec
5
5
  baseUrl: any;
6
6
  }, void, unknown>;
7
7
  export default vitePreviewServerExecutor;
8
+ //# sourceMappingURL=preview-server.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-server.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAK5D,wBAAuB,yBAAyB,CAC9C,OAAO,EAAE,gCAAgC,EACzC,OAAO,EAAE,eAAe;;;kBA+JzB;AAoBD,eAAe,yBAAyB,CAAC"}
@@ -1,80 +1,73 @@
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
- default: function() {
10
- return _default;
11
- },
12
- vitePreviewServerExecutor: function() {
13
- return vitePreviewServerExecutor;
14
- }
15
- });
16
- const _extends = require("@swc/helpers/_/_extends");
17
- const _devkit = require("@nx/devkit");
18
- const _optionsutils = require("../../utils/options-utils");
19
- const _path = require("path");
20
- const _buildimpl = require("../build/build.impl");
21
- const _executorutils = require("../../utils/executor-utils");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vitePreviewServerExecutor = vitePreviewServerExecutor;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const options_utils_1 = require("../../utils/options-utils");
6
+ const path_1 = require("path");
7
+ const build_impl_1 = require("../build/build.impl");
8
+ const executor_utils_1 = require("../../utils/executor-utils");
22
9
  async function* vitePreviewServerExecutor(options, context) {
23
- var _context_projectsConfigurations_projects_target_project, _resolved_build;
24
10
  process.env.VITE_CJS_IGNORE_WARNING = 'true';
25
11
  // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
26
- const { mergeConfig, preview, resolveConfig } = await (0, _executorutils.loadViteDynamicImport)();
12
+ const { mergeConfig, preview, resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
27
13
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
28
- const target = (0, _devkit.parseTargetString)(options.buildTarget, context);
29
- const targetConfiguration = (_context_projectsConfigurations_projects_target_project = context.projectsConfigurations.projects[target.project]) == null ? void 0 : _context_projectsConfigurations_projects_target_project.targets[target.target];
14
+ const target = (0, devkit_1.parseTargetString)(options.buildTarget, context);
15
+ const targetConfiguration = context.projectsConfigurations.projects[target.project]?.targets[target.target];
30
16
  if (!targetConfiguration) {
31
17
  throw new Error(`Invalid buildTarget: ${options.buildTarget}`);
32
18
  }
33
- const isCustomBuildTarget = targetConfiguration.executor !== '@nx/vite:build' && targetConfiguration.executor !== '@nrwl/vite:build';
19
+ const isCustomBuildTarget = targetConfiguration.executor !== '@nx/vite:build' &&
20
+ targetConfiguration.executor !== '@nrwl/vite:build';
34
21
  // Retrieve the option for the configured buildTarget.
35
- const buildTargetOptions = (0, _optionsutils.getNxTargetOptions)(options.buildTarget, context);
36
- const { configuration } = (0, _devkit.parseTargetString)(options.buildTarget, context);
37
- const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
38
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, _buildimpl.getBuildExtraArgs)(buildTargetOptions);
22
+ const buildTargetOptions = (0, options_utils_1.getNxTargetOptions)(options.buildTarget, context);
23
+ const { configuration } = (0, devkit_1.parseTargetString)(options.buildTarget, context);
24
+ const viteConfigPath = (0, options_utils_1.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
25
+ const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, build_impl_1.getBuildExtraArgs)(buildTargetOptions);
39
26
  const { previewOptions, otherOptions } = await getExtraArgs(options, configuration, otherOptionsFromBuild);
40
- var _otherOptions_mode, _ref;
41
- const defaultMode = (_ref = (_otherOptions_mode = otherOptions == null ? void 0 : otherOptions.mode) != null ? _otherOptions_mode : otherOptionsFromBuild == null ? void 0 : otherOptionsFromBuild.mode) != null ? _ref : 'production';
42
- var _process_env_NODE_ENV;
27
+ const defaultMode = otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production';
43
28
  const resolved = await resolveConfig({
44
29
  configFile: viteConfigPath,
45
- mode: defaultMode
46
- }, 'build', defaultMode, (_process_env_NODE_ENV = process.env.NODE_ENV) != null ? _process_env_NODE_ENV : defaultMode);
47
- var _options_staticFilePath, _ref1;
48
- const outDir = (_ref1 = (_options_staticFilePath = options.staticFilePath) != null ? _options_staticFilePath : (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath)) != null ? _ref1 : resolved == null ? void 0 : (_resolved_build = resolved.build) == null ? void 0 : _resolved_build.outDir;
30
+ mode: defaultMode,
31
+ }, 'build', defaultMode, process.env.NODE_ENV ?? defaultMode);
32
+ const outDir = options.staticFilePath ??
33
+ (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath) ??
34
+ resolved?.build?.outDir;
49
35
  if (!outDir) {
50
36
  throw new Error(`Could not infer the "outputPath" or "outDir". It should be set in your vite.config.ts, or as a property of the "${options.buildTarget}" buildTarget or provided explicitly as a "staticFilePath" option.`);
51
37
  }
52
- const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
38
+ const root = projectRoot === '.'
39
+ ? process.cwd()
40
+ : (0, path_1.relative)(context.cwd, (0, devkit_1.joinPathFragments)(context.root, projectRoot));
53
41
  // Merge the options from the build and preview-serve targets.
54
42
  // The latter takes precedence.
55
- const mergedOptions = _extends._({}, {
56
- watch: {}
57
- }, {
58
- build: _extends._({
59
- outDir
60
- }, isCustomBuildTarget ? {} : buildOptions)
61
- }, isCustomBuildTarget ? {} : otherOptionsFromBuild, otherOptions, {
62
- preview: _extends._({}, (0, _optionsutils.getProxyConfig)(context, otherOptions.proxyConfig), previewOptions)
63
- });
64
- var _resolved_root;
43
+ const mergedOptions = {
44
+ ...{ watch: {} },
45
+ build: {
46
+ outDir,
47
+ ...(isCustomBuildTarget ? {} : buildOptions),
48
+ },
49
+ ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),
50
+ ...otherOptions,
51
+ preview: {
52
+ ...(0, options_utils_1.getProxyConfig)(context, otherOptions.proxyConfig),
53
+ ...previewOptions,
54
+ },
55
+ };
65
56
  // vite InlineConfig
66
57
  const serverConfig = mergeConfig({
67
58
  // This should not be needed as it's going to be set in vite.config.ts
68
59
  // but leaving it here in case someone did not migrate correctly
69
- root: (_resolved_root = resolved.root) != null ? _resolved_root : root,
70
- configFile: viteConfigPath
71
- }, _extends._({}, mergedOptions));
60
+ root: resolved.root ?? root,
61
+ configFile: viteConfigPath,
62
+ }, {
63
+ ...mergedOptions,
64
+ });
72
65
  if (serverConfig.mode === 'production') {
73
66
  console.warn('WARNING: preview is not meant to be run in production!');
74
67
  }
75
68
  // vite PreviewServer
76
69
  let server;
77
- const processOnExit = async ()=>{
70
+ const processOnExit = async () => {
78
71
  await closeServer(server);
79
72
  };
80
73
  process.once('SIGINT', processOnExit);
@@ -83,8 +76,8 @@ async function* vitePreviewServerExecutor(options, context) {
83
76
  // Launch the build target.
84
77
  // If customBuildTarget is set to true, do not provide any overrides to it
85
78
  const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;
86
- const build = await (0, _devkit.runExecutor)(target, buildTargetOverrides, context);
87
- for await (const result of build){
79
+ const build = await (0, devkit_1.runExecutor)(target, buildTargetOverrides, context);
80
+ for await (const result of build) {
88
81
  if (result.success) {
89
82
  try {
90
83
  if (!server) {
@@ -93,38 +86,40 @@ async function* vitePreviewServerExecutor(options, context) {
93
86
  server.printUrls();
94
87
  const resolvedUrls = [
95
88
  ...server.resolvedUrls.local,
96
- ...server.resolvedUrls.network
89
+ ...server.resolvedUrls.network,
97
90
  ];
98
- var _resolvedUrls_;
99
91
  yield {
100
92
  success: true,
101
- baseUrl: (_resolvedUrls_ = resolvedUrls[0]) != null ? _resolvedUrls_ : ''
93
+ baseUrl: resolvedUrls[0] ?? '',
102
94
  };
103
- } catch (e) {
95
+ }
96
+ catch (e) {
104
97
  console.error(e);
105
98
  yield {
106
99
  success: false,
107
- baseUrl: ''
100
+ baseUrl: '',
108
101
  };
109
102
  }
110
- } else {
103
+ }
104
+ else {
111
105
  yield {
112
106
  success: false,
113
- baseUrl: ''
107
+ baseUrl: '',
114
108
  };
115
109
  }
116
110
  }
117
- await new Promise((resolve)=>{
118
- process.once('SIGINT', ()=>resolve());
119
- process.once('SIGTERM', ()=>resolve());
120
- process.once('exit', ()=>resolve());
111
+ await new Promise((resolve) => {
112
+ process.once('SIGINT', () => resolve());
113
+ process.once('SIGTERM', () => resolve());
114
+ process.once('exit', () => resolve());
121
115
  });
122
116
  }
123
117
  function closeServer(server) {
124
- return new Promise((resolve)=>{
118
+ return new Promise((resolve) => {
125
119
  if (!server) {
126
120
  resolve();
127
- } else {
121
+ }
122
+ else {
128
123
  const { httpServer } = server;
129
124
  if (httpServer['closeAllConnections']) {
130
125
  // https://github.com/vitejs/vite/pull/14834
@@ -133,16 +128,16 @@ function closeServer(server) {
133
128
  // to import http just for this
134
129
  httpServer.closeAllConnections();
135
130
  }
136
- httpServer.close(()=>resolve());
131
+ httpServer.close(() => resolve());
137
132
  }
138
133
  });
139
134
  }
140
- const _default = vitePreviewServerExecutor;
135
+ exports.default = vitePreviewServerExecutor;
141
136
  async function getExtraArgs(options, configuration, otherOptionsFromBuildTarget) {
142
137
  // support passing extra args to vite cli
143
- const schema = await Promise.resolve().then(()=>require("./schema.json"));
138
+ const schema = await Promise.resolve().then(() => require('./schema.json'));
144
139
  const extraArgs = {};
145
- for (const key of Object.keys(options)){
140
+ for (const key of Object.keys(options)) {
146
141
  if (!schema.properties[key]) {
147
142
  extraArgs[key] = options[key];
148
143
  }
@@ -156,23 +151,25 @@ async function getExtraArgs(options, configuration, otherOptionsFromBuildTarget)
156
151
  'open',
157
152
  'proxy',
158
153
  'cors',
159
- 'headers'
154
+ 'headers',
160
155
  ];
161
156
  let otherOptions = {};
162
- for (const key of Object.keys(extraArgs)){
157
+ for (const key of Object.keys(extraArgs)) {
163
158
  if (previewSchemaKeys.includes(key)) {
164
159
  previewOptions[key] = extraArgs[key];
165
- } else {
160
+ }
161
+ else {
166
162
  otherOptions[key] = extraArgs[key];
167
163
  }
168
164
  }
169
165
  if (configuration) {
170
- otherOptions = _extends._({}, otherOptions, otherOptionsFromBuildTarget != null ? otherOptionsFromBuildTarget : {});
166
+ otherOptions = {
167
+ ...otherOptions,
168
+ ...(otherOptionsFromBuildTarget ?? {}),
169
+ };
171
170
  }
172
171
  return {
173
172
  previewOptions,
174
- otherOptions
173
+ otherOptions,
175
174
  };
176
175
  }
177
-
178
- //# sourceMappingURL=preview-server.impl.js.map
@@ -1,2 +1,3 @@
1
1
  declare const _default: any;
2
2
  export default _default;
3
+ //# sourceMappingURL=compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../../../../../packages/vite/src/executors/test/compat.ts"],"names":[],"mappings":";AAGA,wBAAiD"}
@@ -1,12 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "default", {
3
- enumerable: true,
4
- get: function() {
5
- return _default;
6
- }
7
- });
8
- const _devkit = require("@nx/devkit");
9
- const _vitestimpl = require("./vitest.impl");
10
- const _default = (0, _devkit.convertNxExecutor)(_vitestimpl.default);
11
-
12
- //# sourceMappingURL=compat.js.map
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const vitest_impl_1 = require("./vitest.impl");
5
+ exports.default = (0, devkit_1.convertNxExecutor)(vitest_impl_1.default);
@@ -16,3 +16,4 @@ export declare class NxReporter implements Reporter {
16
16
  onFinished(files: File[], errors?: unknown[]): void;
17
17
  private _handleFinished;
18
18
  }
19
+ //# sourceMappingURL=nx-reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-reporter.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vite/src/executors/test/lib/nx-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE7C,qBAAa,UAAW,YAAW,QAAQ;IAM7B,OAAO,CAAC,KAAK;IALzB,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;KACjC,CAAC;gBAEkB,KAAK,EAAE,OAAO;IAI3B,CAAC,MAAM,CAAC,aAAa,CAAC;;;IAQ7B,OAAO,CAAC,aAAa;IAUrB,oBAAoB;IACpB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,GAAG;IAGvC,oBAAoB;IACpB,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE;IAK5C,OAAO,CAAC,eAAe;CAKxB"}
@@ -1,47 +1,39 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "NxReporter", {
3
- enumerable: true,
4
- get: function() {
5
- return NxReporter;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxReporter = void 0;
4
+ class NxReporter {
5
+ constructor(watch) {
6
+ this.watch = watch;
7
+ this.setupDeferred();
6
8
  }
7
- });
8
- let NxReporter = class NxReporter {
9
9
  async *[Symbol.asyncIterator]() {
10
10
  do {
11
11
  const hasErrors = await this.deferred.promise;
12
- yield {
13
- hasErrors
14
- };
12
+ yield { hasErrors };
15
13
  this.setupDeferred();
16
- }while (this.watch)
14
+ } while (this.watch);
17
15
  }
18
16
  setupDeferred() {
19
17
  let resolve;
20
18
  this.deferred = {
21
- promise: new Promise((res)=>{
19
+ promise: new Promise((res) => {
22
20
  resolve = res;
23
21
  }),
24
- resolve
22
+ resolve,
25
23
  };
26
24
  }
27
- /** Vitest ≥ 0.29 */ onTestRunEnd(files, errors) {
25
+ /** Vitest ≥ 0.29 */
26
+ onTestRunEnd(files, errors) {
28
27
  this._handleFinished(files, errors);
29
28
  }
30
- /** Vitest ≤ 0.28 */ onFinished(files, errors) {
29
+ /** Vitest ≤ 0.28 */
30
+ onFinished(files, errors) {
31
31
  this._handleFinished(files, errors);
32
32
  }
33
33
  // --- private ----------------------------------------------------------
34
34
  _handleFinished(files, errors) {
35
- const hasErrors = files.some((f)=>{
36
- var _f_result;
37
- return ((_f_result = f.result) == null ? void 0 : _f_result.state) === 'fail';
38
- }) || (errors == null ? void 0 : errors.length) > 0;
35
+ const hasErrors = files.some((f) => f.result?.state === 'fail') || errors?.length > 0;
39
36
  this.deferred.resolve(hasErrors);
40
37
  }
41
- constructor(watch){
42
- this.watch = watch;
43
- this.setupDeferred();
44
- }
45
- };
46
-
47
- //# sourceMappingURL=nx-reporter.js.map
38
+ }
39
+ exports.NxReporter = NxReporter;
@@ -2,3 +2,4 @@ import { ExecutorContext } from '@nx/devkit';
2
2
  import { VitestExecutorOptions } from '../schema';
3
3
  export declare function getOptions(options: VitestExecutorOptions, context: ExecutorContext, projectRoot: string): Promise<Record<string, any>>;
4
4
  export declare function getOptionsAsArgv(obj: Record<string, any>): string[];
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../packages/vite/src/executors/test/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAIhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAQlD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,MAAM,gCAuEpB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,CAcnE"}