@nx/vite 24.0.0-beta.2 → 24.0.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.
Files changed (67) hide show
  1. package/dist/executors.d.ts +0 -3
  2. package/dist/executors.js +0 -7
  3. package/dist/plugins/nx-copy-assets.plugin.d.ts +4 -5
  4. package/dist/plugins/nx-copy-assets.plugin.js +5 -49
  5. package/dist/plugins/nx-tsconfig-paths.plugin.d.ts +5 -7
  6. package/dist/plugins/nx-tsconfig-paths.plugin.js +6 -247
  7. package/dist/src/generators/configuration/configuration.js +2 -39
  8. package/dist/src/generators/configuration/schema.d.ts +0 -1
  9. package/dist/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts +0 -1
  10. package/dist/src/generators/convert-to-inferred/lib/build-post-target-transformer.js +3 -66
  11. package/dist/src/generators/init/init.js +20 -32
  12. package/dist/src/generators/init/schema.d.ts +0 -1
  13. package/dist/src/generators/init/schema.json +1 -1
  14. package/dist/src/generators/setup-paths-plugin/schema.d.ts +0 -1
  15. package/dist/src/generators/setup-paths-plugin/schema.json +2 -2
  16. package/dist/src/generators/setup-paths-plugin/setup-paths-plugin.js +16 -91
  17. package/dist/src/migrations/update-23-0-0/ai-instructions-for-vitest-3.md +5 -5
  18. package/dist/src/migrations/update-23-0-0/ai-instructions-for-vitest-4.md +6 -6
  19. package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +12 -0
  20. package/dist/src/migrations/update-24-0-0/migrate-config-helpers.md +86 -0
  21. package/dist/src/migrations/update-24-0-0/migrate-nx-vite-ts-paths.d.ts +2 -0
  22. package/dist/src/migrations/update-24-0-0/migrate-nx-vite-ts-paths.js +154 -0
  23. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.d.ts +4 -0
  24. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.js +11 -0
  25. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.md +37 -0
  26. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
  27. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +46 -0
  28. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +71 -0
  29. package/dist/src/plugins/plugin.d.ts +9 -5
  30. package/dist/src/plugins/plugin.js +34 -45
  31. package/dist/src/utils/deprecation.d.ts +2 -9
  32. package/dist/src/utils/deprecation.js +5 -35
  33. package/dist/src/utils/e2e-web-server-info-utils.d.ts +2 -2
  34. package/dist/src/utils/e2e-web-server-info-utils.js +4 -4
  35. package/dist/src/utils/executor-utils.d.ts +0 -10
  36. package/dist/src/utils/executor-utils.js +0 -51
  37. package/dist/src/utils/generator-utils.d.ts +0 -10
  38. package/dist/src/utils/generator-utils.js +36 -106
  39. package/dist/src/utils/options-utils.d.ts +0 -16
  40. package/dist/src/utils/options-utils.js +0 -73
  41. package/dist/src/utils/versions.d.ts +2 -0
  42. package/dist/src/utils/versions.js +3 -1
  43. package/dist/src/utils/vite-config-edit-utils.d.ts +9 -1
  44. package/dist/src/utils/vite-config-edit-utils.js +143 -1
  45. package/executors.json +2 -34
  46. package/generators.json +1 -1
  47. package/migrations.json +19 -0
  48. package/package.json +6 -7
  49. package/dist/src/executors/build/build.impl.d.ts +0 -11
  50. package/dist/src/executors/build/build.impl.js +0 -205
  51. package/dist/src/executors/build/compat.d.ts +0 -2
  52. package/dist/src/executors/build/compat.js +0 -6
  53. package/dist/src/executors/build/schema.json +0 -82
  54. package/dist/src/executors/dev-server/compat.d.ts +0 -2
  55. package/dist/src/executors/dev-server/compat.js +0 -6
  56. package/dist/src/executors/dev-server/dev-server.impl.d.ts +0 -7
  57. package/dist/src/executors/dev-server/dev-server.impl.js +0 -137
  58. package/dist/src/executors/dev-server/schema.json +0 -40
  59. package/dist/src/executors/preview-server/compat.d.ts +0 -2
  60. package/dist/src/executors/preview-server/compat.js +0 -6
  61. package/dist/src/executors/preview-server/preview-server.impl.d.ts +0 -7
  62. package/dist/src/executors/preview-server/preview-server.impl.js +0 -184
  63. package/dist/src/executors/preview-server/schema.json +0 -44
  64. package/dist/src/utils/nx-tsconfig-paths-find-file.d.ts +0 -2
  65. package/dist/src/utils/nx-tsconfig-paths-find-file.js +0 -22
  66. package/dist/src/utils/nx-tsconfig-paths-load-file.d.ts +0 -12
  67. package/dist/src/utils/nx-tsconfig-paths-load-file.js +0 -71
@@ -1,82 +0,0 @@
1
- {
2
- "version": 2,
3
- "outputCapture": "direct-nodejs",
4
- "title": "Vite Prod Builder",
5
- "cli": "nx",
6
- "description": "Builds a Vite application for production.",
7
- "type": "object",
8
- "x-deprecated": "The `@nx/vite:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
9
- "presets": [
10
- {
11
- "name": "Default minimum setup",
12
- "keys": []
13
- }
14
- ],
15
- "properties": {
16
- "outputPath": {
17
- "type": "string",
18
- "description": "The output path of the generated files.",
19
- "x-completion-type": "directory",
20
- "x-priority": "important"
21
- },
22
- "buildLibsFromSource": {
23
- "type": "boolean",
24
- "description": "Read buildable libraries from source instead of building them separately.",
25
- "default": true
26
- },
27
- "skipTypeCheck": {
28
- "type": "boolean",
29
- "description": "Skip type-checking via TypeScript. Skipping type-checking speeds up the build but type errors are not caught.",
30
- "default": false
31
- },
32
- "tsConfig": {
33
- "type": "string",
34
- "description": "The path to custom tsconfig file for type-checking when skipTypeCheck is false. Required when tsconfig file is not at the projectRoot level.",
35
- "x-completion-type": "file",
36
- "x-completion-glob": "tsconfig.*.json"
37
- },
38
- "configFile": {
39
- "type": "string",
40
- "description": "The name of the Vite configuration file.",
41
- "x-completion-type": "file",
42
- "x-completion-glob": "vite.config.@(js|ts)"
43
- },
44
- "watch": {
45
- "description": "Enable re-building when files change.",
46
- "oneOf": [
47
- {
48
- "type": "boolean"
49
- },
50
- {
51
- "type": "object"
52
- }
53
- ],
54
- "default": false
55
- },
56
- "generatePackageJson": {
57
- "description": "Generate a package.json for the build output.",
58
- "type": "boolean"
59
- },
60
- "includeDevDependenciesInPackageJson": {
61
- "description": "Include devDependencies in the generated package.json.",
62
- "type": "boolean"
63
- },
64
- "skipOverrides": {
65
- "type": "boolean",
66
- "description": "Do not add a `overrides` and `resolutions` entries to the generated package.json file. Only works in conjunction with `generatePackageJson` option."
67
- },
68
- "skipPackageManager": {
69
- "type": "boolean",
70
- "description": "Do not add a `packageManager` entry to the generated package.json file. Only works in conjunction with `generatePackageJson` option."
71
- },
72
- "useEnvironmentsApi": {
73
- "alias": "app",
74
- "type": "boolean",
75
- "description": "Use the new Environments API for building multiple environments at once. Only works with Vite 6.0.0 or higher.",
76
- "default": false
77
- }
78
- },
79
- "definitions": {},
80
- "required": [],
81
- "examplesFile": "../../../docs/build-examples.md"
82
- }
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const devkit_1 = require("@nx/devkit");
5
- const dev_server_impl_1 = tslib_1.__importDefault(require("./dev-server.impl"));
6
- exports.default = (0, devkit_1.convertNxExecutor)(dev_server_impl_1.default);
@@ -1,7 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { ViteDevServerExecutorOptions } from './schema';
3
- export declare function viteDevServerExecutor(options: ViteDevServerExecutorOptions, context: ExecutorContext): AsyncGenerator<{
4
- success: boolean;
5
- baseUrl: string;
6
- }>;
7
- export default viteDevServerExecutor;
@@ -1,137 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.viteDevServerExecutor = viteDevServerExecutor;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const options_utils_1 = require("../../utils/options-utils");
7
- const schema_json_1 = tslib_1.__importDefault(require("./schema.json"));
8
- const executor_utils_1 = require("../../utils/executor-utils");
9
- const deprecation_1 = require("../../utils/deprecation");
10
- const path_1 = require("path");
11
- const build_impl_1 = require("../build/build.impl");
12
- async function* viteDevServerExecutor(options, context) {
13
- (0, deprecation_1.warnViteDevServerExecutorDeprecation)();
14
- process.env.VITE_CJS_IGNORE_WARNING = 'true';
15
- // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
16
- const { mergeConfig, createServer, resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
17
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
18
- const root = projectRoot === '.'
19
- ? process.cwd()
20
- : (0, path_1.relative)(context.cwd, (0, devkit_1.joinPathFragments)(context.root, projectRoot));
21
- (0, executor_utils_1.createBuildableTsConfig)(projectRoot, options, context);
22
- // Retrieve the option for the configured buildTarget.
23
- const buildTargetOptions = (0, options_utils_1.getNxTargetOptions)(options.buildTarget, context);
24
- const { configuration } = (0, devkit_1.parseTargetString)(options.buildTarget, context);
25
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, build_impl_1.getBuildExtraArgs)(buildTargetOptions);
26
- const viteConfigPath = (0, options_utils_1.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
27
- const { serverOptions, otherOptions } = await getServerExtraArgs(options, configuration, buildOptions, otherOptionsFromBuild);
28
- const defaultMode = otherOptions?.mode ?? buildTargetOptions?.['mode'] ?? 'development';
29
- const resolved = await resolveConfig({
30
- configFile: viteConfigPath,
31
- mode: defaultMode,
32
- }, 'serve', defaultMode, process.env.NODE_ENV ?? defaultMode);
33
- // vite InlineConfig
34
- const serverConfig = mergeConfig({
35
- // This should not be needed as it's going to be set in vite.config.ts
36
- // but leaving it here in case someone did not migrate correctly
37
- root: resolved.root ?? root,
38
- configFile: viteConfigPath,
39
- }, {
40
- server: {
41
- ...(await (0, options_utils_1.getViteServerOptions)(options, context)),
42
- ...serverOptions,
43
- },
44
- ...otherOptions,
45
- });
46
- try {
47
- const server = await createServer(serverConfig);
48
- await runViteDevServer(server);
49
- const resolvedUrls = [
50
- ...server.resolvedUrls.local,
51
- ...server.resolvedUrls.network,
52
- ];
53
- yield {
54
- success: true,
55
- baseUrl: resolvedUrls[0] ?? '',
56
- };
57
- }
58
- catch (e) {
59
- console.error(e);
60
- yield {
61
- success: false,
62
- baseUrl: '',
63
- };
64
- }
65
- await new Promise((resolve) => {
66
- process.once('SIGINT', () => resolve());
67
- process.once('SIGTERM', () => resolve());
68
- process.once('exit', () => resolve());
69
- });
70
- }
71
- // vite ViteDevServer
72
- async function runViteDevServer(server) {
73
- await server.listen();
74
- server.printUrls();
75
- const processOnExit = async () => {
76
- await server.close();
77
- };
78
- process.once('SIGINT', processOnExit);
79
- process.once('SIGTERM', processOnExit);
80
- process.once('exit', processOnExit);
81
- }
82
- exports.default = viteDevServerExecutor;
83
- async function getServerExtraArgs(options, configuration, buildOptionsFromBuildTarget, otherOptionsFromBuildTarget) {
84
- // support passing extra args to vite cli
85
- const extraArgs = {};
86
- for (const key of Object.keys(options)) {
87
- if (!schema_json_1.default.properties[key]) {
88
- extraArgs[key] = options[key];
89
- }
90
- }
91
- let serverOptions = {};
92
- const serverSchemaKeys = [
93
- 'hmr',
94
- 'warmup',
95
- 'watch',
96
- 'middlewareMode',
97
- 'fs',
98
- 'origin',
99
- 'preTransformRequests',
100
- 'sourcemapIgnoreList',
101
- 'port',
102
- 'strictPort',
103
- 'host',
104
- 'https',
105
- 'open',
106
- 'proxy',
107
- 'cors',
108
- 'headers',
109
- ];
110
- let otherOptions = {};
111
- for (const key of Object.keys(extraArgs)) {
112
- if (serverSchemaKeys.includes(key)) {
113
- serverOptions[key] = extraArgs[key];
114
- }
115
- else {
116
- otherOptions[key] = extraArgs[key];
117
- }
118
- }
119
- if (configuration) {
120
- const normalizeWatchOption = (watch) => {
121
- return watch === false ? undefined : watch;
122
- };
123
- serverOptions = {
124
- ...serverOptions,
125
- watch: normalizeWatchOption(buildOptionsFromBuildTarget?.watch) ??
126
- normalizeWatchOption(serverOptions?.watch),
127
- };
128
- otherOptions = {
129
- ...otherOptions,
130
- ...(otherOptionsFromBuildTarget ?? {}),
131
- };
132
- }
133
- return {
134
- serverOptions,
135
- otherOptions,
136
- };
137
- }
@@ -1,40 +0,0 @@
1
- {
2
- "version": 2,
3
- "continuous": true,
4
- "outputCapture": "direct-nodejs",
5
- "title": "Vite Dev Server",
6
- "cli": "nx",
7
- "description": "Starts a dev server using Vite.",
8
- "type": "object",
9
- "x-deprecated": "The `@nx/vite:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
10
- "presets": [
11
- {
12
- "name": "Default minimum setup",
13
- "keys": ["buildTarget"]
14
- },
15
- {
16
- "name": "Using a Different Port",
17
- "keys": ["buildTarget", "port"]
18
- }
19
- ],
20
- "properties": {
21
- "buildTarget": {
22
- "type": "string",
23
- "description": "Target which builds the application. Only used to retrieve the configuration as the dev-server does not build the code.",
24
- "x-priority": "important"
25
- },
26
- "buildLibsFromSource": {
27
- "type": "boolean",
28
- "description": "Read buildable libraries from source instead of building them separately.",
29
- "default": true
30
- },
31
- "proxyConfig": {
32
- "type": "string",
33
- "description": "Path to the proxy configuration file.",
34
- "x-completion-type": "file"
35
- }
36
- },
37
- "definitions": {},
38
- "required": ["buildTarget"],
39
- "examplesFile": "../../../docs/dev-server-examples.md"
40
- }
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const devkit_1 = require("@nx/devkit");
5
- const preview_server_impl_1 = tslib_1.__importDefault(require("./preview-server.impl"));
6
- exports.default = (0, devkit_1.convertNxExecutor)(preview_server_impl_1.default);
@@ -1,7 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { VitePreviewServerExecutorOptions } from './schema';
3
- export declare function vitePreviewServerExecutor(options: VitePreviewServerExecutorOptions, context: ExecutorContext): AsyncGenerator<{
4
- success: boolean;
5
- baseUrl: any;
6
- }, void, unknown>;
7
- export default vitePreviewServerExecutor;
@@ -1,184 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.vitePreviewServerExecutor = vitePreviewServerExecutor;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const options_utils_1 = require("../../utils/options-utils");
7
- const schema_json_1 = tslib_1.__importDefault(require("./schema.json"));
8
- const path_1 = require("path");
9
- const build_impl_1 = require("../build/build.impl");
10
- const executor_utils_1 = require("../../utils/executor-utils");
11
- const deprecation_1 = require("../../utils/deprecation");
12
- async function* vitePreviewServerExecutor(options, context) {
13
- (0, deprecation_1.warnVitePreviewServerExecutorDeprecation)();
14
- process.env.VITE_CJS_IGNORE_WARNING = 'true';
15
- // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
16
- const { mergeConfig, preview, resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
17
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
18
- const target = (0, devkit_1.parseTargetString)(options.buildTarget, context);
19
- const targetConfiguration = context.projectsConfigurations.projects[target.project]?.targets[target.target];
20
- if (!targetConfiguration) {
21
- throw new Error(`Invalid buildTarget: ${options.buildTarget}`);
22
- }
23
- const isCustomBuildTarget = targetConfiguration.executor !== '@nx/vite:build' &&
24
- targetConfiguration.executor !== '@nrwl/vite:build';
25
- // Retrieve the option for the configured buildTarget.
26
- const buildTargetOptions = (0, options_utils_1.getNxTargetOptions)(options.buildTarget, context);
27
- const { configuration } = (0, devkit_1.parseTargetString)(options.buildTarget, context);
28
- const viteConfigPath = (0, options_utils_1.normalizeViteConfigFilePath)(context.root, projectRoot, buildTargetOptions.configFile);
29
- const { buildOptions, otherOptions: otherOptionsFromBuild } = await (0, build_impl_1.getBuildExtraArgs)({
30
- ...buildTargetOptions,
31
- ...{
32
- // Enable watch mode by default for the build target.
33
- watch: options.watch ?? true,
34
- },
35
- });
36
- const { previewOptions, otherOptions } = await getExtraArgs(options, configuration, otherOptionsFromBuild);
37
- const defaultMode = otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production';
38
- const resolved = await resolveConfig({
39
- configFile: viteConfigPath,
40
- mode: defaultMode,
41
- }, 'build', defaultMode, process.env.NODE_ENV ?? defaultMode, true);
42
- const outDir = options.staticFilePath ??
43
- (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectRoot), buildTargetOptions.outputPath) ??
44
- resolved?.build?.outDir;
45
- if (!outDir) {
46
- throw new Error(`Could not infer the "outputPath" or "outDir". It should be set in your vite.config.ts, or as a property of the "${options.buildTarget}" buildTarget or provided explicitly as a "staticFilePath" option.`);
47
- }
48
- const root = projectRoot === '.'
49
- ? process.cwd()
50
- : (0, path_1.relative)(context.cwd, (0, devkit_1.joinPathFragments)(context.root, projectRoot));
51
- // Merge the options from the build and preview-serve targets.
52
- // The latter takes precedence.
53
- const mergedOptions = {
54
- ...{ watch: {} },
55
- build: {
56
- outDir,
57
- ...(isCustomBuildTarget ? {} : buildOptions),
58
- },
59
- ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),
60
- ...otherOptions,
61
- preview: {
62
- ...(0, options_utils_1.getProxyConfig)(context, otherOptions.proxyConfig),
63
- ...previewOptions,
64
- },
65
- };
66
- // vite InlineConfig
67
- const serverConfig = mergeConfig({
68
- // This should not be needed as it's going to be set in vite.config.ts
69
- // but leaving it here in case someone did not migrate correctly
70
- root: resolved.root ?? root,
71
- configFile: viteConfigPath,
72
- }, {
73
- ...mergedOptions,
74
- });
75
- if (serverConfig.mode === 'production') {
76
- console.warn('WARNING: preview is not meant to be run in production!');
77
- }
78
- // vite PreviewServer
79
- let server;
80
- const processOnExit = async () => {
81
- await closeServer(server);
82
- };
83
- process.once('SIGINT', processOnExit);
84
- process.once('SIGTERM', processOnExit);
85
- process.once('exit', processOnExit);
86
- // Launch the build target.
87
- // If customBuildTarget is set to true, do not provide any overrides to it
88
- const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;
89
- const build = await (0, devkit_1.runExecutor)(target, buildTargetOverrides, context);
90
- for await (const result of build) {
91
- if (result.success) {
92
- try {
93
- if (!server) {
94
- server = await preview(serverConfig);
95
- }
96
- server.printUrls();
97
- const resolvedUrls = [
98
- ...server.resolvedUrls.local,
99
- ...server.resolvedUrls.network,
100
- ];
101
- yield {
102
- success: true,
103
- baseUrl: resolvedUrls[0] ?? '',
104
- };
105
- }
106
- catch (e) {
107
- console.error(e);
108
- yield {
109
- success: false,
110
- baseUrl: '',
111
- };
112
- }
113
- }
114
- else {
115
- yield {
116
- success: false,
117
- baseUrl: '',
118
- };
119
- }
120
- }
121
- await new Promise((resolve) => {
122
- process.once('SIGINT', () => resolve());
123
- process.once('SIGTERM', () => resolve());
124
- process.once('exit', () => resolve());
125
- });
126
- }
127
- function closeServer(server) {
128
- return new Promise((resolve) => {
129
- if (!server) {
130
- resolve();
131
- }
132
- else {
133
- const { httpServer } = server;
134
- if (httpServer['closeAllConnections']) {
135
- // https://github.com/vitejs/vite/pull/14834
136
- // closeAllConnections was added in Node v18.2.0
137
- // typically is "as http.Server" but no reason
138
- // to import http just for this
139
- httpServer.closeAllConnections();
140
- }
141
- httpServer.close(() => resolve());
142
- }
143
- });
144
- }
145
- exports.default = vitePreviewServerExecutor;
146
- async function getExtraArgs(options, configuration, otherOptionsFromBuildTarget) {
147
- // support passing extra args to vite cli
148
- const extraArgs = {};
149
- for (const key of Object.keys(options)) {
150
- if (!schema_json_1.default.properties[key]) {
151
- extraArgs[key] = options[key];
152
- }
153
- }
154
- const previewOptions = {};
155
- const previewSchemaKeys = [
156
- 'port',
157
- 'strictPort',
158
- 'host',
159
- 'https',
160
- 'open',
161
- 'proxy',
162
- 'cors',
163
- 'headers',
164
- ];
165
- let otherOptions = {};
166
- for (const key of Object.keys(extraArgs)) {
167
- if (previewSchemaKeys.includes(key)) {
168
- previewOptions[key] = extraArgs[key];
169
- }
170
- else {
171
- otherOptions[key] = extraArgs[key];
172
- }
173
- }
174
- if (configuration) {
175
- otherOptions = {
176
- ...otherOptions,
177
- ...(otherOptionsFromBuildTarget ?? {}),
178
- };
179
- }
180
- return {
181
- previewOptions,
182
- otherOptions,
183
- };
184
- }
@@ -1,44 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "version": 2,
4
- "cli": "nx",
5
- "title": "Vite Preview Server",
6
- "description": "Preview Server for Vite.",
7
- "continuous": true,
8
- "type": "object",
9
- "x-deprecated": "The `@nx/vite:preview-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/vite:convert-to-inferred` to migrate to the `@nx/vite/plugin` inferred plugin. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.",
10
- "presets": [
11
- {
12
- "name": "Default minimum setup",
13
- "keys": ["buildTarget"]
14
- },
15
- {
16
- "name": "Using a Different Port",
17
- "keys": ["buildTarget", "port"]
18
- }
19
- ],
20
- "properties": {
21
- "buildTarget": {
22
- "type": "string",
23
- "description": "Target which builds the application."
24
- },
25
- "proxyConfig": {
26
- "type": "string",
27
- "description": "Path to the proxy configuration file.",
28
- "x-completion-type": "file"
29
- },
30
- "staticFilePath": {
31
- "type": "string",
32
- "description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath",
33
- "x-completion-type": "directory"
34
- },
35
- "watch": {
36
- "type": "boolean",
37
- "description": "Enable re-building when files change. If not specified, watch mode will be enabled by default.",
38
- "default": true
39
- }
40
- },
41
- "definitions": {},
42
- "required": ["buildTarget"],
43
- "examplesFile": "../../../docs/preview-server-examples.md"
44
- }
@@ -1,2 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- export declare function findFile(path: string, extensions: string[], existsSyncImpl?: typeof existsSync): string;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findFile = findFile;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- function findFile(path, extensions, existsSyncImpl = node_fs_1.existsSync) {
7
- const queryLessPath = path.replace(/\?\S*$/, '');
8
- for (const ext of extensions) {
9
- const dir = (0, node_path_1.dirname)(path);
10
- // Support file extensions such as .css and .js in the import path.
11
- // While still allowing for '.suffix'
12
- const name = (0, node_path_1.basename)(queryLessPath, ext);
13
- const resolvedPath = (0, node_path_1.resolve)(dir, name + ext);
14
- if (existsSyncImpl(resolvedPath)) {
15
- return resolvedPath;
16
- }
17
- const resolvedIndexPath = (0, node_path_1.resolve)(path, `index${ext}`);
18
- if (existsSyncImpl(resolvedIndexPath)) {
19
- return resolvedIndexPath;
20
- }
21
- }
22
- }
@@ -1,12 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import type { ConfigLoaderSuccessResult } from 'tsconfig-paths';
3
- /**
4
- * Fallback resolver used when `tsconfig-paths` produces nothing that exists on
5
- * disk, whether because no alias matched or because the match pointed at a
6
- * missing file.
7
- *
8
- * A wildcard alias captures the suffix of the import and substitutes it into
9
- * the `*` of each mapped path. The `*` is not always trailing, so the suffix
10
- * cannot simply be appended.
11
- */
12
- export declare function loadFileFromPaths(tsconfig: ConfigLoaderSuccessResult, importPath: string, extensions: string[], existsSyncImpl?: typeof existsSync): string;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadFileFromPaths = loadFileFromPaths;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const nx_tsconfig_paths_find_file_1 = require("./nx-tsconfig-paths-find-file");
7
- /**
8
- * Fallback resolver used when `tsconfig-paths` produces nothing that exists on
9
- * disk, whether because no alias matched or because the match pointed at a
10
- * missing file.
11
- *
12
- * A wildcard alias captures the suffix of the import and substitutes it into
13
- * the `*` of each mapped path. The `*` is not always trailing, so the suffix
14
- * cannot simply be appended.
15
- */
16
- function loadFileFromPaths(tsconfig, importPath, extensions, existsSyncImpl = node_fs_1.existsSync) {
17
- let resolvedFile;
18
- for (const alias of sortAliasesBySpecificity(Object.keys(tsconfig.paths), importPath)) {
19
- const paths = tsconfig.paths[alias];
20
- const isWildcard = alias.endsWith('/*');
21
- const normalizedImport = alias.replace(/\/\*$/, '');
22
- if (importPath === normalizedImport ||
23
- importPath.startsWith(normalizedImport + '/')) {
24
- const suffix = importPath.slice(normalizedImport.length + 1);
25
- for (const path of paths) {
26
- // The replacements go through a function because a string replacement
27
- // would expand `$&` and friends as substitution patterns.
28
- const joinedPath = (0, node_path_1.join)(tsconfig.absoluteBaseUrl, isWildcard
29
- ? path.replace('*', () => suffix)
30
- : path.replace(/\/\*$/, ''));
31
- const candidate = isWildcard
32
- ? joinedPath
33
- : importPath.replace(normalizedImport, () => joinedPath);
34
- resolvedFile = (0, nx_tsconfig_paths_find_file_1.findFile)(candidate, extensions, existsSyncImpl);
35
- // The candidate ends with the import's own tail only when the wildcard
36
- // is last. Anything the mapped path appends after the `*`
37
- // (`packages/foo/*.ts`) is the tail instead, so dropping an extension
38
- // from it would resolve a sibling the mapping never pointed at.
39
- const endsWithImportTail = !isWildcard || path.endsWith('*');
40
- if (resolvedFile === undefined && endsWithImportTail) {
41
- const foundExtension = extensions.find((ext) => importPath.endsWith(ext));
42
- if (foundExtension) {
43
- resolvedFile = (0, nx_tsconfig_paths_find_file_1.findFile)(candidate.slice(0, -foundExtension.length), extensions, existsSyncImpl);
44
- }
45
- }
46
- if (resolvedFile !== undefined) {
47
- return resolvedFile;
48
- }
49
- }
50
- }
51
- }
52
- return resolvedFile;
53
- }
54
- /**
55
- * TypeScript picks between competing aliases by specificity, never by
56
- * declaration order: an exact hit on a non-wildcard alias first, then the
57
- * longest wildcard prefix.
58
- */
59
- function sortAliasesBySpecificity(aliases, importPath) {
60
- const isWildcard = (alias) => alias.endsWith('/*');
61
- const rank = (alias) => isWildcard(alias) ? 1 : importPath === alias ? 2 : 0;
62
- const prefixLength = (alias) => alias.replace(/\/\*$/, '').length;
63
- return [...aliases].sort((a, b) => {
64
- const byRank = rank(b) - rank(a);
65
- if (byRank !== 0)
66
- return byRank;
67
- // Prefix length only separates wildcards. Reordering two aliases
68
- // TypeScript matches neither way would change resolution for no gain.
69
- return isWildcard(a) ? prefixLength(b) - prefixLength(a) : 0;
70
- });
71
- }