@nx/vite 22.0.0-beta.3 → 22.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/vite",
3
- "version": "22.0.0-beta.3",
3
+ "version": "22.0.0-beta.4",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for building and testing applications using Vite",
6
6
  "repository": {
@@ -30,10 +30,10 @@
30
30
  "migrations": "./migrations.json"
31
31
  },
32
32
  "dependencies": {
33
- "@nx/devkit": "22.0.0-beta.3",
33
+ "@nx/devkit": "22.0.0-beta.4",
34
34
  "@phenomnomnominal/tsquery": "~5.0.1",
35
35
  "enquirer": "~2.3.6",
36
- "@nx/js": "22.0.0-beta.3",
36
+ "@nx/js": "22.0.0-beta.4",
37
37
  "picomatch": "4.0.2",
38
38
  "tsconfig-paths": "^4.1.2",
39
39
  "semver": "^7.6.3",
@@ -41,7 +41,7 @@
41
41
  "ajv": "^8.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "nx": "22.0.0-beta.3"
44
+ "nx": "22.0.0-beta.4"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"nx-tsconfig-paths.plugin.d.ts","sourceRoot":"","sources":["../../../../packages/vite/plugins/nx-tsconfig-paths.plugin.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAM9B,MAAM,WAAW,oBAAoB;IACnC;;;;QAII;IACJ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;QAKI;IACJ,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;IACnC;;;QAGI;IACJ,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAiKzD,MAAM,CAsEZ"}
1
+ {"version":3,"file":"nx-tsconfig-paths.plugin.d.ts","sourceRoot":"","sources":["../../../../packages/vite/plugins/nx-tsconfig-paths.plugin.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAK9B,MAAM,WAAW,oBAAoB;IACnC;;;;QAII;IACJ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;QAKI;IACJ,UAAU,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;IACnC;;;QAGI;IACJ,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAqKzD,MAAM,CAsEZ"}
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nxViteTsPaths = nxViteTsPaths;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
7
  const node_fs_1 = require("node:fs");
6
8
  const node_path_1 = require("node:path");
7
9
  const tsconfig_paths_1 = require("tsconfig-paths");
8
- const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
9
- const nx_vite_build_coordination_plugin_1 = require("./nx-vite-build-coordination.plugin");
10
10
  const nx_tsconfig_paths_find_file_1 = require("../src/utils/nx-tsconfig-paths-find-file");
11
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
12
11
  const options_utils_1 = require("../src/utils/options-utils");
12
+ const nx_vite_build_coordination_plugin_1 = require("./nx-vite-build-coordination.plugin");
13
13
  function nxViteTsPaths(options = {}) {
14
14
  let foundTsConfigPath;
15
15
  let matchTsPathEsm;
@@ -45,22 +45,29 @@ function nxViteTsPaths(options = {}) {
45
45
  (0, node_path_1.join)(devkit_1.workspaceRoot, 'tmp', projectRootFromWorkspaceRoot, process.env.NX_TASK_TARGET_TARGET ?? 'build', 'tsconfig.generated.json'));
46
46
  if (!foundTsConfigPath)
47
47
  return;
48
- if (!options.buildLibsFromSource &&
49
- !global.NX_GRAPH_CREATION &&
50
- config.mode !== 'test') {
48
+ if (!options.buildLibsFromSource && !global.NX_GRAPH_CREATION) {
51
49
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)({
52
50
  exitOnError: false,
53
51
  resetDaemonClient: true,
54
52
  });
55
53
  // When using incremental building and the serve target is called
56
54
  // we need to get the deps for the 'build' target instead.
57
- const depsBuildTarget = process.env.NX_TASK_TARGET_TARGET === 'serve'
55
+ const depsBuildTarget = process.env.NX_TASK_TARGET_TARGET === 'serve' ||
56
+ process.env.NX_TASK_TARGET_TARGET === 'test'
58
57
  ? 'build'
59
58
  : process.env.NX_TASK_TARGET_TARGET;
60
59
  const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(undefined, projectGraph, devkit_1.workspaceRoot, process.env.NX_TASK_TARGET_PROJECT, depsBuildTarget, process.env.NX_TASK_TARGET_CONFIGURATION);
61
- // This tsconfig is used via the Vite ts paths plugin.
62
- // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).
63
- foundTsConfigPath = (0, buildable_libs_utils_1.createTmpTsConfig)(foundTsConfigPath, devkit_1.workspaceRoot, (0, node_path_1.relative)(devkit_1.workspaceRoot, projectRoot), dependencies, true);
60
+ if (process.env.NX_GENERATED_TSCONFIG_PATH) {
61
+ // This is needed for vitest browser mode because it runs two vite dev servers
62
+ // so we want to reuse the same tsconfig file for both servers
63
+ foundTsConfigPath = process.env.NX_GENERATED_TSCONFIG_PATH;
64
+ }
65
+ else {
66
+ // This tsconfig is used via the Vite ts paths plugin.
67
+ // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).
68
+ foundTsConfigPath = (0, buildable_libs_utils_1.createTmpTsConfig)(foundTsConfigPath, devkit_1.workspaceRoot, (0, node_path_1.relative)(devkit_1.workspaceRoot, projectRoot), dependencies, true);
69
+ process.env.NX_GENERATED_TSCONFIG_PATH = foundTsConfigPath;
70
+ }
64
71
  if (config.command === 'serve') {
65
72
  const buildableLibraryDependencies = dependencies
66
73
  .filter((dep) => dep.node.type === 'lib')
@@ -1 +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
+ {"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;;;kBAqKzB;AAoBD,eAAe,yBAAyB,CAAC"}
@@ -22,7 +22,13 @@ async function* vitePreviewServerExecutor(options, context) {
22
22
  const buildTargetOptions = (0, options_utils_1.getNxTargetOptions)(options.buildTarget, context);
23
23
  const { configuration } = (0, devkit_1.parseTargetString)(options.buildTarget, context);
24
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);
25
+ const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, build_impl_1.getBuildExtraArgs)({
26
+ ...buildTargetOptions,
27
+ ...{
28
+ // Enable watch mode by default for the build target.
29
+ watch: options.watch ?? true,
30
+ },
31
+ });
26
32
  const { previewOptions, otherOptions } = await getExtraArgs(options, configuration, otherOptionsFromBuild);
27
33
  const defaultMode = otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production';
28
34
  const resolved = await resolveConfig({
@@ -2,4 +2,5 @@ export interface VitePreviewServerExecutorOptions {
2
2
  buildTarget: string;
3
3
  proxyConfig?: string;
4
4
  staticFilePath?: string;
5
+ watch?: boolean;
5
6
  }
@@ -30,6 +30,11 @@
30
30
  "type": "string",
31
31
  "description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath",
32
32
  "x-completion-type": "directory"
33
+ },
34
+ "watch": {
35
+ "type": "boolean",
36
+ "description": "Enable re-building when files change. If not specified, watch mode will be enabled by default.",
37
+ "default": true
33
38
  }
34
39
  },
35
40
  "definitions": {},