@nx/vite 22.0.0-beta.2 → 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 +4 -4
- package/plugins/nx-tsconfig-paths.plugin.d.ts.map +1 -1
- package/plugins/nx-tsconfig-paths.plugin.js +17 -10
- package/src/executors/preview-server/preview-server.impl.d.ts.map +1 -1
- package/src/executors/preview-server/preview-server.impl.js +7 -1
- package/src/executors/preview-server/schema.d.ts +1 -0
- package/src/executors/preview-server/schema.json +5 -0
- package/src/plugins/plugin.d.ts +2 -2
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +3 -39
- package/src/utils/options-utils.d.ts.map +1 -1
- package/src/utils/options-utils.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "22.0.0-beta.
|
|
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.
|
|
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.
|
|
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.
|
|
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;
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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;;;
|
|
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)(
|
|
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({
|
|
@@ -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": {},
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateDependencies,
|
|
1
|
+
import { CreateDependencies, CreateNodesV2 } from '@nx/devkit';
|
|
2
2
|
export interface VitePluginOptions {
|
|
3
3
|
buildTargetName?: string;
|
|
4
4
|
testTargetName?: string;
|
|
@@ -17,6 +17,6 @@ export interface VitePluginOptions {
|
|
|
17
17
|
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
18
18
|
*/
|
|
19
19
|
export declare const createDependencies: CreateDependencies;
|
|
20
|
+
export declare const createNodes: CreateNodesV2<VitePluginOptions>;
|
|
20
21
|
export declare const createNodesV2: CreateNodesV2<VitePluginOptions>;
|
|
21
|
-
export declare const createNodes: CreateNodes<VitePluginOptions>;
|
|
22
22
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,
|
|
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;AAkBpB,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;CAC9B;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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
@@ -30,7 +30,7 @@ const createDependencies = () => {
|
|
|
30
30
|
};
|
|
31
31
|
exports.createDependencies = createDependencies;
|
|
32
32
|
const viteVitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';
|
|
33
|
-
exports.
|
|
33
|
+
exports.createNodes = [
|
|
34
34
|
viteVitestConfigGlob,
|
|
35
35
|
async (configFilePaths, options, context) => {
|
|
36
36
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
@@ -92,43 +92,7 @@ exports.createNodesV2 = [
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
];
|
|
95
|
-
exports.
|
|
96
|
-
viteVitestConfigGlob,
|
|
97
|
-
async (configFilePath, options, context) => {
|
|
98
|
-
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
99
|
-
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
100
|
-
// Do not create a project if package.json and project.json isn't there.
|
|
101
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
102
|
-
if (!siblingFiles.includes('package.json') &&
|
|
103
|
-
!siblingFiles.includes('project.json')) {
|
|
104
|
-
return {};
|
|
105
|
-
}
|
|
106
|
-
const tsConfigFiles = siblingFiles.filter((p) => picomatch('tsconfig*{.json,.*.json}')(p)) ??
|
|
107
|
-
[];
|
|
108
|
-
const hasReactRouterConfig = siblingFiles.some((configFile) => {
|
|
109
|
-
const parts = configFile.split('.');
|
|
110
|
-
return (parts[0] === 'react-router' && parts[1] === 'config' && parts.length > 2);
|
|
111
|
-
});
|
|
112
|
-
const normalizedOptions = normalizeOptions(options);
|
|
113
|
-
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
114
|
-
const { projectType, metadata, targets } = await buildViteTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context);
|
|
115
|
-
const project = {
|
|
116
|
-
root: projectRoot,
|
|
117
|
-
targets,
|
|
118
|
-
metadata,
|
|
119
|
-
};
|
|
120
|
-
// If project is buildable, then the project type.
|
|
121
|
-
// If it is not buildable, then leave it to other plugins/project.json to set the project type.
|
|
122
|
-
if (project.targets[normalizedOptions.buildTargetName]) {
|
|
123
|
-
project.projectType = projectType;
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
projects: {
|
|
127
|
-
[projectRoot]: project,
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
];
|
|
95
|
+
exports.createNodesV2 = exports.createNodes;
|
|
132
96
|
async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context) {
|
|
133
97
|
const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
134
98
|
// Workaround for the `build$3 is not a function` error that we sometimes see in agents.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"options-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/vite/src/utils/options-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAMhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAgCpB;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAYpB;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,eAAe,GACvB,MAAM,GAAG,SAAS,CAapB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,4BAA4B,EACrC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyBlC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,CAO9C;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,OAG1E"}
|
|
@@ -31,11 +31,11 @@ function normalizeViteConfigFilePath(contextRoot, projectRoot, configFile) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
function getProjectTsConfigPath(projectRoot) {
|
|
34
|
-
return (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json'))
|
|
34
|
+
return (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'tsconfig.app.json'))
|
|
35
35
|
? (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json')
|
|
36
|
-
: (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.lib.json'))
|
|
36
|
+
: (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'tsconfig.lib.json'))
|
|
37
37
|
? (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.lib.json')
|
|
38
|
-
: (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json'))
|
|
38
|
+
: (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'tsconfig.json'))
|
|
39
39
|
? (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json')
|
|
40
40
|
: undefined;
|
|
41
41
|
}
|