@nx/vite 22.1.0-beta.2 → 22.1.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 +4 -4
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +18 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "22.1.0-beta.
|
|
3
|
+
"version": "22.1.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.1.0-beta.
|
|
33
|
+
"@nx/devkit": "22.1.0-beta.4",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "22.1.0-beta.
|
|
36
|
+
"@nx/js": "22.1.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.1.0-beta.
|
|
44
|
+
"nx": "22.1.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":"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,8 +462,8 @@ 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', {
|
|
457
469
|
dir: fullProjectRoot,
|
|
@@ -459,5 +471,7 @@ async function getTestPathsRelativeToProjectRoot(projectRoot) {
|
|
|
459
471
|
watch: false,
|
|
460
472
|
});
|
|
461
473
|
const relevantTestSpecifications = await vitest.getRelevantTestSpecifications();
|
|
462
|
-
return relevantTestSpecifications
|
|
474
|
+
return relevantTestSpecifications
|
|
475
|
+
.filter((ts) => projectRoot === '.' ? true : ts.moduleId.startsWith(fullProjectRoot))
|
|
476
|
+
.map((ts) => (0, node_path_1.relative)(projectRoot, ts.moduleId));
|
|
463
477
|
}
|