Tags: JamieMason/nx
Tags
fix(vite): update vitest and plugin-react-swc versions for vite 8 com… …pat (nrwl#35062) ## Current Behavior When creating a workspace with `create-nx-workspace` using presets that install vitest (react-monorepo with vite bundler, nuxt with vitest, vue, etc.) and **npm** as the package manager, `npm install` fails with `ERESOLVE unable to resolve dependency tree`. **Root cause:** vitest `~4.0.x` depends on `@vitest/mocker@4.0.x` which has a peer dependency on `vite: "^6.0.0 || ^7.0.0"` — it does **not** support vite 8. Since Nx now defaults to installing `vite@^8.0.0`, npm cannot satisfy `@vitest/mocker`'s peer dependency. Additionally, `@vitejs/plugin-react-swc@^3.5.0` has a peer dependency on `vite: "^4 || ^5 || ^6 || ^7"` (no vite 8 support), and the SWC compiler path in `ensure-dependencies.ts` lacks the vite-version detection logic that the babel path already has. ## Expected Behavior - Workspaces using vite 8 + vitest install successfully with npm - `@vitejs/plugin-react-swc` version is selected based on the installed vite version (v4.3+ for vite 8, v3.x for older vite) ## Changes 1. **Bump `vitestV4Version`** from `~4.0.0`/`~4.0.8` to `~4.1.0` in both `@nx/vite` and `@nx/vitest` — vitest 4.1.x's dependencies support vite 8 2. **Bump `vitestV4CoverageV8Version` and `vitestV4CoverageIstanbulVersion`** to `~4.1.0` to match 3. **Update `vitePluginReactSwcVersion`** from `^3.5.0` to `^4.3.0` (first version with vite 8 peer dep support), add `vitePluginReactSwcV3Version = '^3.5.0'` for backward compat 4. **Add vite-version detection** to the SWC path in `ensure-dependencies.ts` (both `@nx/vite` and `@nx/vitest`), mirroring the existing babel path logic ## Related Issue(s) Fixes NXC-4164
fix(js): add {projectRoot} prefix to d.ts fileset in typescript plugin (
nrwl#35037)
## Current Behavior
The TypeScript plugin emits a bare `**/*.d.ts` fileset input (without a
`{projectRoot}/` prefix) for dependency file tracking. The Nx hasher
expects all filesets to start with either `{projectRoot}/` or
`{workspaceRoot}/`, so it logs a warning for every project:
```
NX **/*.d.ts does not start with {workspaceRoot}/. This will throw an error in Nx 20.
```
## Expected Behavior
No warning is emitted. The fileset correctly uses
`{projectRoot}/**/*.d.ts` so the hasher knows it's scoped to the
dependency project's root.
## Related Issue(s)
N/A — discovered while debugging e2e test failures.
fix(misc): handle non-interactive mode and add template shorthand nam… …es for CNW (nrwl#35045) This PR address some common errors seen during CNW around `--template` and `--preset` during non-interactive flows that are not AI agents. Also sees that some template names are not qualified with `nrwl/<name>-template` so we can normal though (which also makes it shorter in docs). ## Current Behavior In non-interactive contexts (IDE terminals, scripts, SSH without `-t`), `determineTemplate()` returns `'custom'` which routes to the preset flow. Without `--preset` provided, this throws "Preset is required", which affects ~15 users/day (~145 occurrences Mar 18-27). Users must also pass full template paths like `--template=nrwl/angular-template`. ## Expected Behavior Non-interactive mode defaults to `nrwl/empty-template` (template flow) instead of `'custom'` (preset flow) when neither `--preset` nor `--template` is provided. Shorthand template names are supported: - `--template=angular` → `nrwl/angular-template` - `--template=react` → `nrwl/react-template` - `--template=typescript` → `nrwl/typescript-template` - `--template=empty` → `nrwl/empty-template` ## Related Issue(s) Fixes NXC-4153
fix(repo): resolve FreeBSD build disk space issue (nrwl#35030) ## Current Behavior The FreeBSD native build in the publish workflow runs out of disk space (`No space left on device`). The VM has an 11G disk and the Rust build fills it completely. The build was already on the edge — the Mar 25 run succeeded with only 11MB to spare, and the Mar 26 run failed after rustc 1.94.1 slightly increased artifact sizes. A major contributor is OpenJDK17 and its ~30 X11/font dependencies (~500MB) being installed solely for the `@nx/gradle` plugin's project graph step, which is irrelevant to building native Rust bindings. ## Expected Behavior The FreeBSD build completes successfully with comfortable disk headroom by disabling the Gradle plugin via `NX_GRADLE_DISABLE=true`, which eliminates the need for Java and its heavy dependency tree. ## Related Issue(s) Fixes the FreeBSD build failure: https://github.com/nrwl/nx/actions/runs/23613960439/job/68776656960
fix(repo): resolve FreeBSD build disk space issue (nrwl#35030) ## Current Behavior The FreeBSD native build in the publish workflow runs out of disk space (`No space left on device`). The VM has an 11G disk and the Rust build fills it completely. The build was already on the edge — the Mar 25 run succeeded with only 11MB to spare, and the Mar 26 run failed after rustc 1.94.1 slightly increased artifact sizes. A major contributor is OpenJDK17 and its ~30 X11/font dependencies (~500MB) being installed solely for the `@nx/gradle` plugin's project graph step, which is irrelevant to building native Rust bindings. ## Expected Behavior The FreeBSD build completes successfully with comfortable disk headroom by disabling the Gradle plugin via `NX_GRADLE_DISABLE=true`, which eliminates the need for Java and its heavy dependency tree. ## Related Issue(s) Fixes the FreeBSD build failure: https://github.com/nrwl/nx/actions/runs/23613960439/job/68776656960 (cherry picked from commit 9747038)
fix(angular-rspack): ensure rebuild chunks emitted summary accurate (n… …rwl#34979) ## Current Behavior Currently, rebuilds produce a summary table that is not accurate. A key difference in how Rspack sets `chunks.rendered` compared to Webpack resulted in the logic for determining rebuilt chunks to be incorrect. ## Expected Behavior Ensure the summary table for emitted chunks is accurate on rebuild ## Related Issues It does not _fully_ solve nrwl#34936, however it should be a good first step to finding out if too many chunks are being emitted
fix(core): add explicit exports entry for nx/src/native directory (nr… …wl#34967) ## Current Behavior After the nodenext PR (nrwl#34111) added an `exports` map to `packages/nx/package.json`, the nx-cloud light client (ocean) fails to import `nx/src/native`. The wildcard exports pattern `"./src/*"` resolves `nx/src/native` to `./dist/src/native.js` — but the actual file is `./dist/src/native/index.js` (it's a directory with an index file). Node's exports map does literal `*` substitution and does **not** perform CJS-style directory/index resolution. The cloud client wraps all its nx imports in a single try/catch, so when the native import fails, `getDbConnection` is never assigned either, causing `getDbConnection is not a function` errors in CI. This was not an issue with `nx@22.7.0-beta.1` because that version had no `exports` map — Node fell back to normal CJS resolution which handles directory/index lookups. ## Expected Behavior `require('nx/src/native')` correctly resolves to `dist/src/native/index.js` via an explicit export entry, and the cloud client can load the native module and `getDbConnection` without errors. ## Related Issue(s) N/A — discovered during version bump CI failure investigation. --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
fix(core): split-target should handle projects with colons in name be… …tter (nrwl#34725) ## Current Behavior - `splitTarget` causes issues when a project name has more than one colon - Project name substitution is triggered when a project depends on the orginal name of a renamed project, even if the renamed project was renamed before the dep was registered That second one is hard to understand. Imagine the real scenario below: - @nx/gradle was reading settings.gradle.kts and naming the root project `nx` - The package.json inference plugin renames it to `@nx/nx-source` - The package.json inference plugin infers the `nx` project in `packages/nx` - The package.json inference plugin reads a config that has `dependsOn: [nx:build]` - The substitutors run, and update the dependsOn to `@nx/nx-source:build` ## Expected Behavior splitTarget follows the below precedence: - If splitting a target string thats embedded in a specific project configuration, targets on that project are preferred - Targets belonging to the project with the longest name that is valid from joining segments left to right - Targets that have the longest name from joining segments are preferred - Configuration is the remaining segments after picking off the longest valid project containing a valid target. Substitutors prefer registering by root if a project with a given name exists, and only register by name if no project with that root exists (e.g. if a plugin adds a dependsOn to a project that was inferred by a later plugin, this would be common if a custom plugin is reading project.json to get a name or smth). ## AI Summary > # Branch Analysis: `fix/split-target-fixes` vs `master` > > ## Summary > > | Metric | Lines | > |--------|------:| > | **Total raw diff (added+removed, non-test)** | 2,840 + 1,221 = 4,061 | > | **Lines that were just moved (file split)** | ~960 | > | **Truly new/changed lines (non-test)** | ~570 | > | **Test file changes (raw diff)** | 3,109 added / 2,242 removed | > > ## Commits > > | SHA | Message | > |-----|---------| > | `57ec87b3c4` | fix(core): split-target should handle projects with colons in name better | > | `af1ebc90ab` | fix(core): avoid renaming projects based on former name if they were rooted when dep is drawn | > | `b2fffc60c7` | cleanup(core): split project-configuration-utils into focused modules | > | `3bae3048d8` | fix(core): fixup name substitution manager | > > ## File Split: `project-configuration-utils.ts` -> 4 modules > > The original `project-configuration-utils.ts` (1,407 lines) was split into focused modules. **~960 lines were moved as-is** (identical minus whitespace/formatting) into the new files. The remaining changes are actual logic modifications. > > | File | Total Lines | Moved from original | Truly new/changed | > |------|------------:|--------------------:|------------------:| > | `project-configuration-utils.ts` (remaining) | 444 | ~395 | ~49 | > | `target-merging.ts` | 494 | ~430 | } | > | `target-normalization.ts` | 282 | ~250 | } ~111 combined | > | `project-nodes-manager.ts` | 365 | ~285 | } | > | **Subtotal** | 1,585 | ~1,360 | ~160 | > > Additionally, ~39 lines were removed from the original and not moved anywhere (dead code removal or refactored away). > > ## Actual Code Changes (non-test, excluding moved lines) > > ### Major changes > > | File | New | Removed | Net | Description | > |------|----:|--------:|----:|-------------| > | `split-target.ts` | ~211 | ~38 | +173 | New logic for handling projects with colons in names | > | `name-substitution-manager.ts` | ~152 | ~85 | +67 | Fix: avoid renaming rooted projects based on former name | > | Split files (combined, new logic only) | ~111 | — | +111 | New code introduced during the split refactor | > | `project-configuration-utils.ts` (new logic only) | ~49 | ~39 | +10 | Residual new code after split | > > ### Minor edits (import path updates, small fixes) > > | File | Added | Removed | > |------|------:|--------:| > | `parse-target-string.ts` | 7 | 1 | > | `command-line/show/target.ts` | 11 | 7 | > | `devkit-internals.ts` | 3 | 5 | > | `tasks-runner/utils.ts` | 5 | 3 | > | `build-project-graph.ts` | 2 | 4 | > | `error-types.ts` | 2 | 4 | > | `command-line/run/run-one.ts` | 2 | 1 | > | `ngcli-adapter.ts` | 1 | 1 | > | `convert-nx-executor.ts` | 1 | 1 | > | `project-configuration.ts` (generators) | 1 | 1 | > | `package-json.ts` | 1 | 1 | > | `settings.gradle.kts` | 1 | 1 | > | **Minor edits subtotal** | **37** | **30** | > > ### Other new files > > | File | Lines | Description | > |------|------:|-------------| > | `packages/devkit/CLAUDE.md` | 62 | Dev documentation | > | `__fixtures__/merge-create-nodes-args.json` | 100 | Test fixture data | > > ## Final Tally: True Non-Test Changes > > | Category | Lines | > |----------|------:| > | New logic in `split-target.ts` | ~211 | > | New logic in `name-substitution-manager.ts` | ~152 | > | New logic in split module files | ~111 | > | New logic in remaining `project-configuration-utils.ts` | ~49 | > | Minor import/path updates across 12 files | ~37 added / ~30 removed | > | New non-code files (CLAUDE.md, fixture JSON) | 162 | > | **Total truly new/changed lines** | **~570 added, ~160 removed** | > | Moved lines (file split, not real changes) | **~960** | ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com> Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
chore(repo): update nx to 22.7.0-beta.1 (nrwl#34932) ## Current Behavior Workspace uses nx 22.7.0-beta.0 and related @nx/* packages at 22.7.0-beta.0. ## Expected Behavior Workspace uses nx 22.7.0-beta.1 and related @nx/* packages at 22.7.0-beta.1. ## Related Issue(s) N/A — routine version bump. --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com> (cherry picked from commit ef3a517)
fix(core): prevent DB corruption from concurrent initialization (nrwl… …#34861) ## Current Behavior When multiple processes call `connectToNxDb()` concurrently (plugin workers via `startAnalytics()`, daemon, main CLI), two bugs can corrupt the workspace database: **Bug 1: Lock file inode race.** `unlock_file()` deletes the lock file after unlocking, allowing a subsequent `File::create()` to produce a new file with a different inode. Two processes can hold "the lock" simultaneously on different file objects, breaking mutual exclusion. **Bug 2: Partial file cleanup on version mismatch/connection failure.** The `reason` arm and `Err` arm in `initialize_db` call `remove_file(db_path)` which only deletes `.db`, leaving stale `.db-wal` and `.db-shm` on disk. The recursive `initialize_db` creates a fresh `.db`, but SQLite detects the stale WAL (different inode salt) and deletes it — destroying all data that existed only in the WAL. Both bugs lead to: ``` Database file exists but has no metadata table. ``` ## Expected Behavior 1. Lock file persists across lock/unlock cycles — all processes serialize through the same inode 2. When DB recreation is needed, all auxiliary files (`.db`, `.db-wal`, `.db-shm`) are cleaned up together via `remove_all_database_files` --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
PreviousNext