@nx/vite 23.0.0-beta.24 → 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.
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": {
@@ -98,43 +62,6 @@
98
62
  }
99
63
  },
100
64
  "packageJsonUpdates": {
101
- "20.7.1": {
102
- "version": "20.7.1-beta.0",
103
- "packages": {
104
- "@analogjs/vite-plugin-angular": {
105
- "version": "~1.14.1",
106
- "alwaysAddToPackageJson": false
107
- },
108
- "@analogjs/vitest-angular": {
109
- "version": "~1.14.1",
110
- "alwaysAddToPackageJson": false
111
- }
112
- }
113
- },
114
- "20.5.0": {
115
- "version": "20.5.0-beta.3",
116
- "requires": {
117
- "vite": ">=5.0.0 <6.0.0"
118
- },
119
- "packages": {
120
- "vite": {
121
- "version": "^6.0.0",
122
- "alwaysAddToPackageJson": false
123
- }
124
- }
125
- },
126
- "20.5.0-vite-plugin-dts": {
127
- "version": "20.5.0-beta.3",
128
- "requires": {
129
- "vite-plugin-dts": ">=3.0.0 <4.0.0"
130
- },
131
- "packages": {
132
- "vite-plugin-dts": {
133
- "version": "~4.5.0",
134
- "alwaysAddToPackageJson": false
135
- }
136
- }
137
- },
138
65
  "21.1.2": {
139
66
  "version": "21.1.2-beta.0",
140
67
  "packages": {
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@nx/vite",
3
- "version": "23.0.0-beta.24",
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.24",
105
- "@nx/js": "23.0.0-beta.24",
106
- "@nx/vitest": "23.0.0-beta.24"
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.24",
110
- "nx": "23.0.0-beta.24"
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
- ```