@nx/vitest 23.3.0-beta.1 → 23.3.0-beta.3

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.
@@ -5,6 +5,7 @@ exports.updateNxJsonSettings = updateNxJsonSettings;
5
5
  exports.initGenerator = initGenerator;
6
6
  const internal_1 = require("@nx/devkit/internal");
7
7
  const devkit_1 = require("@nx/devkit");
8
+ const semver_1 = require("semver");
8
9
  const versions_1 = require("../../utils/versions");
9
10
  const plugin_1 = require("../../plugins/plugin");
10
11
  const version_utils_1 = require("../../utils/version-utils");
@@ -23,6 +24,14 @@ function updateDependencies(tree, schema) {
23
24
  : installedMajor === 7
24
25
  ? versions_1.viteV7Version
25
26
  : versions_1.viteVersion;
27
+ // Vite below 8 depends on esbuild (8 bundles rolldown instead), whose install
28
+ // script only validates the prebuilt binary that ships as an optional
29
+ // dependency.
30
+ if ((0, semver_1.major)((0, semver_1.coerce)(viteVersionToUse)) < 8) {
31
+ (0, internal_1.acknowledgeBuildScripts)(tree, (0, devkit_1.detectPackageManager)(tree.root), {
32
+ esbuild: false,
33
+ });
34
+ }
26
35
  return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
27
36
  '@nx/vitest': versions_1.nxVersion,
28
37
  vitest: versions_1.vitestVersion,
@@ -92,18 +92,6 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context,
92
92
  catch {
93
93
  // do nothing
94
94
  }
95
- // Workaround for race condition with ESM-only Vite plugins (e.g. @vitejs/plugin-vue@6+)
96
- // If vite.config.ts is compiled as CJS, then when both require('@vitejs/plugin-vue') and import('@vitejs/plugin-vue')
97
- // are pending in the same process, Node will throw an error:
98
- // Error [ERR_INTERNAL_ASSERTION]: Cannot require() ES Module @vitejs/plugin-vue/dist/index.js because it is not yet fully loaded.
99
- // This may be caused by a race condition if the module is simultaneously dynamically import()-ed via Promise.all().
100
- try {
101
- const importVuePlugin = () => new Function('return import("@vitejs/plugin-vue")')();
102
- await importVuePlugin();
103
- }
104
- catch {
105
- // Plugin not installed or not needed, ignore
106
- }
107
95
  // Workaround for race condition with vitest/node on Node 24+
108
96
  // When multiple vitest.config files are processed in parallel, Node can throw:
109
97
  // Error [ERR_INTERNAL_ASSERTION]: Cannot require() ES Module vitest/dist/node.js
@@ -117,10 +105,10 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context,
117
105
  // vitest/node not available or not needed, ignore
118
106
  }
119
107
  const { resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
120
- const viteBuildConfig = await resolveConfig({
108
+ const viteBuildConfig = await (0, internal_1.retryOnRequireEsmRace)(() => resolveConfig({
121
109
  configFile: absoluteConfigFilePath,
122
110
  mode: 'development',
123
- }, 'build');
111
+ }, 'build'));
124
112
  // A root config that aggregates project configs via `test.projects` is just an
125
113
  // orchestrator; the actual tests live in the individual project configs. Skip it
126
114
  // entirely so it does not register a project rooted at the workspace root (which
@@ -160,7 +148,7 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context,
160
148
  // Capture the raw root after user hooks: graph construction and the
161
149
  // atom run resolve it against different cwds.
162
150
  let configuredViteRoot;
163
- const viteServeConfig = await resolveConfig({
151
+ const viteServeConfig = await (0, internal_1.retryOnRequireEsmRace)(() => resolveConfig({
164
152
  configFile: absoluteConfigFilePath,
165
153
  mode: 'test',
166
154
  plugins: [
@@ -186,7 +174,7 @@ async function buildVitestTargets(configFilePath, projectRoot, options, context,
186
174
  },
187
175
  },
188
176
  ],
189
- }, 'serve');
177
+ }, 'serve'));
190
178
  const projectRootRelativeTestPaths = await getTestPathsRelativeToProjectRoot(projectRoot, context.workspaceRoot,
191
179
  // Only the glob path reads this config; the opt-out path forces the
192
180
  // runtime by receiving no config, and takes `test.dir` separately.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureDependencies = ensureDependencies;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/js/internal");
5
6
  const semver_1 = require("semver");
6
7
  const versions_1 = require("./versions");
7
8
  async function ensureDependencies(tree, schema) {
@@ -27,6 +28,8 @@ async function ensureDependencies(tree, schema) {
27
28
  }
28
29
  if (schema.uiFramework === 'react') {
29
30
  if (schema.compiler === 'swc') {
31
+ // @vitejs/plugin-react-swc depends on @swc/core.
32
+ (0, internal_1.acknowledgeSwcBuildScripts)(tree);
30
33
  devDependencies['@vitejs/plugin-react-swc'] = versions_1.vitePluginReactSwcVersion;
31
34
  }
32
35
  else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/vitest",
3
3
  "description": "The Nx Plugin for Vitest to enable fast unit testing with Vitest.",
4
- "version": "23.3.0-beta.1",
4
+ "version": "23.3.0-beta.3",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -81,13 +81,13 @@
81
81
  "tslib": "^2.3.0",
82
82
  "semver": "^7.6.3",
83
83
  "@phenomnomnominal/tsquery": "~6.2.0",
84
- "@nx/devkit": "23.3.0-beta.1",
85
- "@nx/js": "23.3.0-beta.1"
84
+ "@nx/devkit": "23.3.0-beta.3",
85
+ "@nx/js": "23.3.0-beta.3"
86
86
  },
87
87
  "peerDependencies": {
88
- "vitest": "^3.0.0 || ^4.0.0",
88
+ "vitest": "^3.0.0 || ^4.0.0 || ^5.0.0",
89
89
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
90
- "@nx/eslint": "23.3.0-beta.1"
90
+ "@nx/eslint": "23.3.0-beta.3"
91
91
  },
92
92
  "peerDependenciesMeta": {
93
93
  "@nx/eslint": {
@@ -101,6 +101,6 @@
101
101
  }
102
102
  },
103
103
  "devDependencies": {
104
- "nx": "23.3.0-beta.1"
104
+ "nx": "23.3.0-beta.3"
105
105
  }
106
106
  }