@nx/vite 22.1.0-canary.20251029-4a07faf → 22.1.0-canary.20251106-e9146c7
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.1.0-canary.
|
|
3
|
+
"version": "22.1.0-canary.20251106-e9146c7",
|
|
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.1.0-canary.
|
|
33
|
+
"@nx/devkit": "22.1.0-canary.20251106-e9146c7",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "22.1.0-canary.
|
|
36
|
+
"@nx/js": "22.1.0-canary.20251106-e9146c7",
|
|
37
37
|
"picomatch": "4.0.2",
|
|
38
38
|
"tsconfig-paths": "^4.1.2",
|
|
39
39
|
"semver": "^7.6.3",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"ajv": "^8.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"nx": "22.1.0-canary.
|
|
44
|
+
"nx": "22.1.0-canary.20251106-e9146c7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
48
|
-
"vitest": "^1.3.1 || ^2.0.0 || ^3.0.0"
|
|
48
|
+
"vitest": "^1.3.1 || ^2.0.0 || ^3.0.0 || ^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAGlB,aAAa,EAQd,MAAM,YAAY,CAAC;AAgBpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAiBD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAIF,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAuGxD,CAAC;AAEF,eAAO,MAAM,aAAa,kCAAc,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -105,6 +105,18 @@ async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFi
|
|
|
105
105
|
catch {
|
|
106
106
|
// do nothing
|
|
107
107
|
}
|
|
108
|
+
// Workaround for race condition with ESM-only Vite plugins (e.g. @vitejs/plugin-vue@6+)
|
|
109
|
+
// If vite.config.ts is compiled as CJS, then when both require('@vitejs/plugin-vue') and import('@vitejs/plugin-vue')
|
|
110
|
+
// are pending in the same process, Node will throw an error:
|
|
111
|
+
// Error [ERR_INTERNAL_ASSERTION]: Cannot require() ES Module @vitejs/plugin-vue/dist/index.js because it is not yet fully loaded.
|
|
112
|
+
// This may be caused by a race condition if the module is simultaneously dynamically import()-ed via Promise.all().
|
|
113
|
+
try {
|
|
114
|
+
const importVuePlugin = () => new Function('return import("@vitejs/plugin-vue")')();
|
|
115
|
+
await importVuePlugin();
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Plugin not installed or not needed, ignore
|
|
119
|
+
}
|
|
108
120
|
const { resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
|
|
109
121
|
const viteBuildConfig = await resolveConfig({
|
|
110
122
|
configFile: absoluteConfigFilePath,
|
|
@@ -126,7 +138,7 @@ async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFi
|
|
|
126
138
|
[groupName]: targetGroup,
|
|
127
139
|
},
|
|
128
140
|
};
|
|
129
|
-
const projectRootRelativeTestPaths = await getTestPathsRelativeToProjectRoot(projectRoot);
|
|
141
|
+
const projectRootRelativeTestPaths = await getTestPathsRelativeToProjectRoot(projectRoot, context.workspaceRoot);
|
|
130
142
|
for (const relativePath of projectRootRelativeTestPaths) {
|
|
131
143
|
if (relativePath.includes('../')) {
|
|
132
144
|
throw new Error('@nx/vite/plugin attempted to run tests outside of the project root. This is not supported and should not happen. Please open an issue at https://github.com/nrwl/nx/issues/new/choose with the following information:\n\n' +
|
|
@@ -450,14 +462,17 @@ function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
|
450
462
|
}
|
|
451
463
|
return true;
|
|
452
464
|
}
|
|
453
|
-
async function getTestPathsRelativeToProjectRoot(projectRoot) {
|
|
454
|
-
const fullProjectRoot = (0, node_path_1.join)(
|
|
465
|
+
async function getTestPathsRelativeToProjectRoot(projectRoot, workspaceRoot) {
|
|
466
|
+
const fullProjectRoot = (0, node_path_1.join)(workspaceRoot, projectRoot);
|
|
455
467
|
const { createVitest } = await Promise.resolve().then(() => require('vitest/node'));
|
|
456
468
|
const vitest = await createVitest('test', {
|
|
469
|
+
root: fullProjectRoot,
|
|
457
470
|
dir: fullProjectRoot,
|
|
458
471
|
filesOnly: true,
|
|
459
472
|
watch: false,
|
|
460
473
|
});
|
|
461
474
|
const relevantTestSpecifications = await vitest.getRelevantTestSpecifications();
|
|
462
|
-
return relevantTestSpecifications
|
|
475
|
+
return relevantTestSpecifications
|
|
476
|
+
.filter((ts) => projectRoot === '.' ? true : ts.moduleId.startsWith(fullProjectRoot))
|
|
477
|
+
.map((ts) => (0, node_path_1.relative)(projectRoot, ts.moduleId));
|
|
463
478
|
}
|
package/src/utils/test-utils.js
CHANGED
|
@@ -162,7 +162,7 @@ function mockReactAppGenerator(tree, userAppName) {
|
|
|
162
162
|
"../../node_modules/@nx/react/typings/image.d.ts"
|
|
163
163
|
],
|
|
164
164
|
"exclude": [
|
|
165
|
-
"jest.config.
|
|
165
|
+
"jest.config.cts",
|
|
166
166
|
"**/*.spec.ts",
|
|
167
167
|
"**/*.test.ts",
|
|
168
168
|
"**/*.spec.tsx",
|
|
@@ -234,7 +234,7 @@ function mockReactMixedAppGenerator(tree) {
|
|
|
234
234
|
"../../node_modules/@nx/react/typings/image.d.ts"
|
|
235
235
|
],
|
|
236
236
|
"exclude": [
|
|
237
|
-
"jest.config.
|
|
237
|
+
"jest.config.cts",
|
|
238
238
|
"**/*.spec.ts",
|
|
239
239
|
"**/*.test.ts",
|
|
240
240
|
"**/*.spec.tsx",
|
|
@@ -452,7 +452,7 @@ function mockReactLibNonBuildableJestTestRunnerGenerator(tree) {
|
|
|
452
452
|
"../../node_modules/@nx/react/typings/image.d.ts"
|
|
453
453
|
],
|
|
454
454
|
"exclude": [
|
|
455
|
-
"jest.config.
|
|
455
|
+
"jest.config.cts",
|
|
456
456
|
"src/**/*.spec.ts",
|
|
457
457
|
"src/**/*.test.ts",
|
|
458
458
|
"src/**/*.spec.tsx",
|