@nx/vite 23.0.0-beta.23 → 23.0.0-beta.25

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.
@@ -0,0 +1,9 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function migrateCreateNodesV2ToCreateNodes(tree: Tree): Promise<void>;
3
+ /**
4
+ * Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
5
+ * when they come from one of the given module specifiers. Only the named
6
+ * bindings are touched — the module specifier, the `import`/`export` keyword,
7
+ * any `type` modifier, and any default import are left untouched.
8
+ */
9
+ export declare function rewriteCreateNodesV2Imports(source: string, specifiers: ReadonlySet<string>): string;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = migrateCreateNodesV2ToCreateNodes;
4
+ exports.rewriteCreateNodesV2Imports = rewriteCreateNodesV2Imports;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
7
+ const DEPRECATED_NAME = 'createNodesV2';
8
+ const CANONICAL_NAME = 'createNodes';
9
+ // Module specifiers from which `@nx/vite` publicly exposes `createNodesV2`.
10
+ // A named import or re-export of `createNodesV2` from one of these is rewritten
11
+ // to the canonical `createNodes` export.
12
+ const TARGET_SPECIFIERS = new Set(['@nx/vite/plugin']);
13
+ let ts;
14
+ async function migrateCreateNodesV2ToCreateNodes(tree) {
15
+ let touchedCount = 0;
16
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
17
+ if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
18
+ return;
19
+ }
20
+ const original = tree.read(filePath, 'utf-8');
21
+ if (!original || !original.includes(DEPRECATED_NAME)) {
22
+ return;
23
+ }
24
+ const updated = rewriteCreateNodesV2Imports(original, TARGET_SPECIFIERS);
25
+ if (updated !== original) {
26
+ tree.write(filePath, updated);
27
+ touchedCount += 1;
28
+ }
29
+ });
30
+ if (touchedCount > 0) {
31
+ devkit_1.logger.info(`Renamed \`${DEPRECATED_NAME}\` imports to \`${CANONICAL_NAME}\` in ${touchedCount} file(s).`);
32
+ }
33
+ await (0, devkit_1.formatFiles)(tree);
34
+ }
35
+ /**
36
+ * Rewrites named imports and re-exports of `createNodesV2` to `createNodes`
37
+ * when they come from one of the given module specifiers. Only the named
38
+ * bindings are touched — the module specifier, the `import`/`export` keyword,
39
+ * any `type` modifier, and any default import are left untouched.
40
+ */
41
+ function rewriteCreateNodesV2Imports(source, specifiers) {
42
+ ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
43
+ const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
44
+ /* setParentNodes */ true, ts.ScriptKind.TSX);
45
+ const changes = [];
46
+ for (const stmt of sourceFile.statements) {
47
+ if (ts.isImportDeclaration(stmt)) {
48
+ collectImportRewrite(sourceFile, stmt, specifiers, changes);
49
+ }
50
+ else if (ts.isExportDeclaration(stmt)) {
51
+ collectExportRewrite(sourceFile, stmt, specifiers, changes);
52
+ }
53
+ }
54
+ return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
55
+ }
56
+ function isTargetSpecifier(node, specifiers) {
57
+ return ts.isStringLiteral(node) && specifiers.has(node.text);
58
+ }
59
+ function collectImportRewrite(sourceFile, stmt, specifiers, changes) {
60
+ if (!isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
61
+ return;
62
+ }
63
+ const namedBindings = stmt.importClause?.namedBindings;
64
+ // Only `import { ... }` carries renameable named bindings. `import x`,
65
+ // `import * as ns`, and side-effect imports reference the module wholesale
66
+ // and keep working through the `createNodesV2` runtime alias, so we leave
67
+ // them be. A mixed `import def, { createNodesV2 }` still has its named
68
+ // bindings rewritten below — the default binding is untouched.
69
+ if (!namedBindings || !ts.isNamedImports(namedBindings)) {
70
+ return;
71
+ }
72
+ rewriteNamedBindings(sourceFile, namedBindings, changes);
73
+ }
74
+ function collectExportRewrite(sourceFile, stmt, specifiers, changes) {
75
+ if (!stmt.moduleSpecifier ||
76
+ !isTargetSpecifier(stmt.moduleSpecifier, specifiers)) {
77
+ return;
78
+ }
79
+ // `export { ... } from '...'` can be rewritten; `export * from '...'` has no
80
+ // named bindings to rename.
81
+ if (!stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) {
82
+ return;
83
+ }
84
+ rewriteNamedBindings(sourceFile, stmt.exportClause, changes);
85
+ }
86
+ /**
87
+ * Re-renders the `{ ... }` of a named import/export, renaming any
88
+ * `createNodesV2` specifier to `createNodes`. If renaming would collide with a
89
+ * `createNodes` that is already present (e.g. `{ createNodes, createNodesV2 }`),
90
+ * the duplicate is dropped. Returns without recording a change when the binding
91
+ * list contains no `createNodesV2`.
92
+ */
93
+ function rewriteNamedBindings(sourceFile, namedBindings, changes) {
94
+ const elements = namedBindings.elements;
95
+ const hasDeprecated = elements.some((el) => (el.propertyName ?? el.name).text === DEPRECATED_NAME);
96
+ if (!hasDeprecated) {
97
+ return;
98
+ }
99
+ const seen = new Set();
100
+ const rendered = [];
101
+ for (const el of elements) {
102
+ const text = renderSpecifier(el);
103
+ if (!seen.has(text)) {
104
+ seen.add(text);
105
+ rendered.push(text);
106
+ }
107
+ }
108
+ const start = namedBindings.getStart(sourceFile);
109
+ changes.push({
110
+ type: devkit_1.ChangeType.Delete,
111
+ start,
112
+ length: namedBindings.getEnd() - start,
113
+ }, {
114
+ type: devkit_1.ChangeType.Insert,
115
+ index: start,
116
+ text: `{ ${rendered.join(', ')} }`,
117
+ });
118
+ }
119
+ function renderSpecifier(el) {
120
+ const typePrefix = el.isTypeOnly ? 'type ' : '';
121
+ const rename = (name) => name === DEPRECATED_NAME ? CANONICAL_NAME : name;
122
+ // `{ name }` — no alias, so the local binding follows the rename.
123
+ if (!el.propertyName) {
124
+ return `${typePrefix}${rename(el.name.text)}`;
125
+ }
126
+ // `{ propertyName as name }` — only the imported (left) side is renamed; the
127
+ // local alias is preserved. A now-redundant alias such as
128
+ // `createNodesV2 as createNodes` collapses to `createNodes`.
129
+ const canonicalImported = rename(el.propertyName.text);
130
+ const localName = el.name.text;
131
+ return canonicalImported === localName
132
+ ? `${typePrefix}${localName}`
133
+ : `${typePrefix}${canonicalImported} as ${localName}`;
134
+ }
@@ -0,0 +1,25 @@
1
+ #### Rename `createNodesV2` imports to `createNodes`
2
+
3
+ `@nx/vite` renamed its primary inferred-plugin export from `createNodesV2` to `createNodes`. The `createNodesV2` name is preserved as a deprecated alias for now, but new code should use `createNodes`.
4
+
5
+ This migration scans every `.ts`, `.tsx`, `.cts`, and `.mts` file in your workspace and rewrites named imports and re-exports of `createNodesV2` from `@nx/vite/plugin` to `createNodes`.
6
+
7
+ #### Sample Code Changes
8
+
9
+ ##### Before
10
+
11
+ ```ts
12
+ import { createNodesV2 } from '@nx/vite/plugin';
13
+ ```
14
+
15
+ ##### After
16
+
17
+ ```ts
18
+ import { createNodes } from '@nx/vite/plugin';
19
+ ```
20
+
21
+ Aliases are preserved (`createNodesV2 as cn` becomes `createNodes as cn`), and if a file already imports both names (`{ createNodes, createNodesV2 }`) the redundant binding is dropped.
22
+
23
+ #### What is not rewritten
24
+
25
+ Only static `import`/`export` named bindings from `@nx/vite/plugin` are rewritten. Namespace imports, dynamic `import(...)`, `require(...)` destructuring, and property access such as `plugin.createNodesV2` are left untouched — they keep working through the `createNodesV2` runtime alias. Update those by hand if you want to drop the deprecated name everywhere.
package/migrations.json CHANGED
@@ -1,41 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-20-0-4": {
4
- "version": "20.0.4-beta.0",
5
- "description": "Add gitignore entry for temporary vite config files.",
6
- "implementation": "./dist/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore",
7
- "documentation": "./dist/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.md"
8
- },
9
- "update-20-0-6": {
10
- "version": "20.0.6-beta.0",
11
- "description": "Add gitignore entry for temporary vite config files and remove previous incorrect glob.",
12
- "implementation": "./dist/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore",
13
- "documentation": "./dist/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.md"
14
- },
15
- "update-20-5-0-install-jiti": {
16
- "version": "20.5.0-beta.2",
17
- "requires": {
18
- "vite": ">=6.0.0"
19
- },
20
- "description": "Install jiti as a devDependency to allow vite to parse TS postcss files.",
21
- "implementation": "./dist/src/migrations/update-20-5-0/install-jiti",
22
- "documentation": "./dist/src/migrations/update-20-5-0/install-jiti.md"
23
- },
24
- "update-20-5-0-update-resolve-conditions": {
25
- "version": "20.5.0-beta.3",
26
- "requires": {
27
- "vite": ">=6.0.0"
28
- },
29
- "description": "Update resolve.conditions to include defaults that are no longer provided by Vite.",
30
- "implementation": "./dist/src/migrations/update-20-5-0/update-resolve-conditions",
31
- "documentation": "./dist/src/migrations/update-20-5-0/update-resolve-conditions.md"
32
- },
33
- "eslint-ignore-vite-temp-files": {
34
- "version": "20.5.0-beta.3",
35
- "description": "Add vite config temporary files to the ESLint configuration ignore patterns if ESLint is used.",
36
- "implementation": "./dist/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files",
37
- "documentation": "./dist/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.md"
38
- },
39
3
  "update-22-2-0": {
40
4
  "version": "22.2.0-beta.1",
41
5
  "requires": {
@@ -89,46 +53,15 @@
89
53
  "description": "Migrate workspaces past breaking changes for Vitest 4.",
90
54
  "implementation": "./dist/src/migrations/update-23-0-0/migrate-to-vitest-4",
91
55
  "prompt": "./dist/src/migrations/update-23-0-0/ai-instructions-for-vitest-4.md"
56
+ },
57
+ "update-23-0-0-migrate-create-nodes-v2-import": {
58
+ "version": "23.0.0-beta.24",
59
+ "description": "Rename imports of `createNodesV2` from `@nx/vite/plugin` to the canonical `createNodes` export.",
60
+ "implementation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes",
61
+ "documentation": "./dist/src/migrations/update-23-0-0/migrate-create-nodes-v2-to-create-nodes.md"
92
62
  }
93
63
  },
94
64
  "packageJsonUpdates": {
95
- "20.7.1": {
96
- "version": "20.7.1-beta.0",
97
- "packages": {
98
- "@analogjs/vite-plugin-angular": {
99
- "version": "~1.14.1",
100
- "alwaysAddToPackageJson": false
101
- },
102
- "@analogjs/vitest-angular": {
103
- "version": "~1.14.1",
104
- "alwaysAddToPackageJson": false
105
- }
106
- }
107
- },
108
- "20.5.0": {
109
- "version": "20.5.0-beta.3",
110
- "requires": {
111
- "vite": ">=5.0.0 <6.0.0"
112
- },
113
- "packages": {
114
- "vite": {
115
- "version": "^6.0.0",
116
- "alwaysAddToPackageJson": false
117
- }
118
- }
119
- },
120
- "20.5.0-vite-plugin-dts": {
121
- "version": "20.5.0-beta.3",
122
- "requires": {
123
- "vite-plugin-dts": ">=3.0.0 <4.0.0"
124
- },
125
- "packages": {
126
- "vite-plugin-dts": {
127
- "version": "~4.5.0",
128
- "alwaysAddToPackageJson": false
129
- }
130
- }
131
- },
132
65
  "21.1.2": {
133
66
  "version": "21.1.2-beta.0",
134
67
  "packages": {
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@nx/vite",
3
- "version": "23.0.0-beta.23",
3
+ "version": "23.0.0-beta.25",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
8
8
  "!dist/tsconfig.tsbuildinfo",
9
- "!dist/spec",
10
9
  "migrations.json",
11
10
  "executors.json",
12
11
  "generators.json"
@@ -91,7 +90,8 @@
91
90
  "executors": "./executors.json",
92
91
  "ng-update": {
93
92
  "requirements": {},
94
- "migrations": "./migrations.json"
93
+ "migrations": "./migrations.json",
94
+ "supportsOptionalUpdates": true
95
95
  },
96
96
  "dependencies": {
97
97
  "@phenomnomnominal/tsquery": "~6.2.0",
@@ -101,13 +101,13 @@
101
101
  "semver": "^7.6.3",
102
102
  "tslib": "^2.3.0",
103
103
  "ajv": "^8.0.0",
104
- "@nx/devkit": "23.0.0-beta.23",
105
- "@nx/js": "23.0.0-beta.23",
106
- "@nx/vitest": "23.0.0-beta.23"
104
+ "@nx/devkit": "23.0.0-beta.25",
105
+ "@nx/js": "23.0.0-beta.25",
106
+ "@nx/vitest": "23.0.0-beta.25"
107
107
  },
108
108
  "devDependencies": {
109
- "@nx/eslint": "23.0.0-beta.23",
110
- "nx": "23.0.0-beta.23"
109
+ "@nx/eslint": "23.0.0-beta.25",
110
+ "nx": "23.0.0-beta.25"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function addViteTempFilesToGitIgnore(tree: Tree): void;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = addViteTempFilesToGitIgnore;
4
- const ignore_vite_temp_files_1 = require("../../utils/ignore-vite-temp-files");
5
- function addViteTempFilesToGitIgnore(tree) {
6
- // need to check if .gitignore exists before adding to it
7
- // then need to check if it contains the following pattern
8
- // **/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*
9
- // if it does, remove just this pattern
10
- if (tree.exists('.gitignore')) {
11
- const gitIgnoreContents = tree.read('.gitignore', 'utf-8');
12
- if (gitIgnoreContents.includes('**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*')) {
13
- tree.write('.gitignore', gitIgnoreContents.replace('**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*', ''));
14
- }
15
- }
16
- (0, ignore_vite_temp_files_1.addViteTempFilesToGitIgnore)(tree);
17
- }
@@ -1,12 +0,0 @@
1
- #### Add Vite Temp Files to Git Ignore
2
-
3
- Add gitignore entry for temporary vite config files.
4
-
5
- #### Sample Code Changes
6
-
7
- Adds the following entries to the `.gitignore` file.
8
-
9
- ```text title=".gitignore"
10
- vite.config.*.timestamp*
11
- vitest.config.*.timestamp*
12
- ```
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const ignore_vite_temp_files_1 = require("../../utils/ignore-vite-temp-files");
6
- const versions_1 = require("../../utils/versions");
7
- async function default_1(tree) {
8
- if (!(0, ignore_vite_temp_files_1.isEslintInstalled)(tree)) {
9
- return;
10
- }
11
- (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
12
- // CommonJS `require` instead of dynamic ESM `import` — `ensurePackage`
13
- // exposes the temp install via `Module._initPaths`, which ESM ignores.
14
- const { addIgnoresToLintConfig, isEslintConfigSupported, useFlatConfig, } = require('@nx/eslint/internal');
15
- if (!isEslintConfigSupported(tree)) {
16
- return;
17
- }
18
- const isUsingFlatConfig = useFlatConfig(tree);
19
- if (isUsingFlatConfig) {
20
- // using flat config, so we update the root eslint config
21
- addIgnoresToLintConfig(tree, '', [
22
- '**/vite.config.*.timestamp*',
23
- '**/vitest.config.*.timestamp*',
24
- ]);
25
- }
26
- else {
27
- // not using flat config, so we update each project's eslint config
28
- const projects = (0, devkit_1.getProjects)(tree);
29
- for (const [, { root: projectRoot }] of projects) {
30
- const viteConfigFiles = await (0, devkit_1.globAsync)(tree, [
31
- `${projectRoot}/**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}`,
32
- ]);
33
- if (!viteConfigFiles.length) {
34
- // the project doesn't use vite or vitest, so we skip it
35
- continue;
36
- }
37
- addIgnoresToLintConfig(tree, projectRoot, [
38
- '**/vite.config.*.timestamp*',
39
- '**/vitest.config.*.timestamp*',
40
- ]);
41
- }
42
- }
43
- await (0, devkit_1.formatFiles)(tree);
44
- }
@@ -1,45 +0,0 @@
1
- #### Sample Code Changes
2
-
3
- Add `vite.config.*.timestamp*` and `vitest.config.*.timestamp*` to the root `eslint.config.mjs` file (using **ESLint Flat Config**).
4
-
5
- ##### Before
6
-
7
- ```js title="eslint.config.mjs"
8
- export default [
9
- {
10
- ignores: ['dist'],
11
- },
12
- ];
13
- ```
14
-
15
- ##### After
16
-
17
- ```js title="eslint.config.mjs" {3}
18
- export default [
19
- {
20
- ignores: ['dist', 'vite.config.*.timestamp*', 'vitest.config.*.timestamp*'],
21
- },
22
- ];
23
- ```
24
-
25
- Add `vite.config.*.timestamp*` and `vitest.config.*.timestamp*` to the project's `.eslintrc.json` file (using **eslintrc** format config).
26
-
27
- ##### Before
28
-
29
- ```json title="apps/app1/eslintrc.json"
30
- {
31
- "ignorePatterns": ["!**/*"]
32
- }
33
- ```
34
-
35
- ##### After
36
-
37
- ```json title="apps/app1/eslintrc.json" {4-5}
38
- {
39
- "ignorePatterns": [
40
- "!**/*",
41
- "vite.config.*.timestamp*",
42
- "vitest.config.*.timestamp*"
43
- ]
44
- }
45
- ```
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export default function installJiti(tree: Tree): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = installJiti;
4
- const devkit_1 = require("@nx/devkit");
5
- const versions_1 = require("../../utils/versions");
6
- async function installJiti(tree) {
7
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
8
- jiti: versions_1.jitiVersion,
9
- });
10
- return installTask;
11
- }
@@ -1,6 +0,0 @@
1
- #### Installs the `jiti` package
2
-
3
- This migration ensures that the [`jiti`](https://github.com/unjs/jiti) package is installed.
4
- This is a requirement for Vite to parse `postcss` configuration files that use TypeScript.
5
-
6
- Learn more: [https://vite.dev/guide/migration#postcss-load-config](https://vite.dev/guide/migration#postcss-load-config)
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const devkit_1 = require("@nx/devkit");
5
- const tsquery_1 = require("@phenomnomnominal/tsquery");
6
- const picomatch = require("picomatch");
7
- const REMIX_IMPORT_SELECTOR = 'ImportDeclaration:has(StringLiteral[value=@remix-run/dev]),CallExpression:has(Identifier[name=require]) StringLiteral[value=@remix-run/dev]';
8
- const DEFINE_CONFIG_OBJECT_SELECTOR = `CallExpression:has(Identifier[name=defineConfig]) > ObjectLiteralExpression`;
9
- const RESOLVE_PROPERTY_SELECTOR = `PropertyAssignment:has(Identifier[name=resolve]) > ObjectLiteralExpression`;
10
- const CONDITIONS_PROPERTY_SELECTOR = `PropertyAssignment:has(Identifier[name=conditions]) > ArrayLiteralExpression`;
11
- const _conditions_array_values = [
12
- 'module',
13
- 'browser',
14
- 'development|production',
15
- ];
16
- const _condition_obj = `conditions: ${JSON.stringify(_conditions_array_values)},`;
17
- const _resolve = `resolve: {
18
- ${_condition_obj}
19
- },`;
20
- async function default_1(tree) {
21
- const viteFiles = [];
22
- (0, devkit_1.visitNotIgnoredFiles)(tree, '', (filePath) => {
23
- if (picomatch('**/vite.*config*.{js,ts,mjs,mts,cjs,cts}')(filePath)) {
24
- viteFiles.push(filePath);
25
- }
26
- });
27
- for (const file of viteFiles) {
28
- const contents = tree.read(file, 'utf-8');
29
- const sourceFile = (0, tsquery_1.ast)(contents);
30
- const remixImportNodes = (0, tsquery_1.query)(sourceFile, REMIX_IMPORT_SELECTOR);
31
- if (remixImportNodes.length > 0) {
32
- continue;
33
- }
34
- const defineConfigObjectNodes = (0, tsquery_1.query)(sourceFile, DEFINE_CONFIG_OBJECT_SELECTOR);
35
- if (defineConfigObjectNodes.length === 0) {
36
- console.warn(`Could not migrate vite config at ${file}. No "defineConfig" object found. Apply "resolve.conditions: ['module', 'browser', 'development|production']" manually to your vite config.`);
37
- continue;
38
- }
39
- let newContents = contents;
40
- const defineConfigObjectNode = defineConfigObjectNodes[0];
41
- const resolvePropertyNodes = (0, tsquery_1.query)(defineConfigObjectNode, RESOLVE_PROPERTY_SELECTOR);
42
- if (resolvePropertyNodes.length === 0) {
43
- // Do not add resolve property if it does not already exist
44
- continue;
45
- }
46
- else {
47
- const resolvePropertyNode = resolvePropertyNodes[0];
48
- const conditionsPropertyNodes = (0, tsquery_1.query)(resolvePropertyNode, CONDITIONS_PROPERTY_SELECTOR);
49
- if (conditionsPropertyNodes.length === 0) {
50
- // do not add conditions property if it does not already exist
51
- continue;
52
- }
53
- else {
54
- const conditionPropertyNode = conditionsPropertyNodes[0];
55
- const conditionsArrayValues = JSON.parse(conditionPropertyNode.getText().replace(/['`]/g, '"'));
56
- const newConditionArrayValues = [
57
- ...new Set([...conditionsArrayValues, ..._conditions_array_values]),
58
- ];
59
- newContents =
60
- newContents.slice(0, conditionPropertyNode.getStart()) +
61
- `${JSON.stringify(newConditionArrayValues)}` +
62
- newContents.slice(conditionPropertyNode.getEnd());
63
- }
64
- }
65
- tree.write(file, newContents);
66
- }
67
- await (0, devkit_1.formatFiles)(tree);
68
- }
@@ -1,42 +0,0 @@
1
- #### Update `resolve.conditions` to include defaults
2
-
3
- In previous Vite versions, the `resolve.conditions` option had defaults that were added internally (i.e. `['module', 'browser', 'development|production']`).
4
- This default was removed in Vite 6, so this migration adds it to your existing configuration to ensure that the behavior remains intact.
5
-
6
- Learn more: [https://vite.dev/guide/migration#default-value-for-resolve-conditions](https://vite.dev/guide/migration#default-value-for-resolve-conditions)
7
-
8
- :::note[Remix]
9
- Remix does not currently support Vite 6 and therefore any `vite.config` file for Remix will not be migrated.
10
- :::
11
-
12
- #### Sample Code Changes
13
-
14
- ##### Before
15
-
16
- ```typescript title="vite.config.ts"
17
- import { defineConfig } from 'vite';
18
-
19
- export default defineConfig({
20
- resolve: {
21
- conditions: ['require'],
22
- },
23
- build: {
24
- outDir: 'dist',
25
- },
26
- });
27
- ```
28
-
29
- ##### After
30
-
31
- ```typescript title="vite.config.ts" {4-6}
32
- import { defineConfig } from 'vite';
33
-
34
- export default defineConfig({
35
- resolve: {
36
- conditions: ['require', 'module', 'browser', 'development|production'],
37
- },
38
- build: {
39
- outDir: 'dist',
40
- },
41
- });
42
- ```