nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.53k stars 2.35k forks source link

nx release doesn't replace `workspace:` dependency to a semantic version if dependency doesn't have any changes #27729

Open RokasVaitkevicius opened 1 month ago

RokasVaitkevicius commented 1 month ago

Current Behavior

I have two packages: SDK and types.

SDK has a direct dependency to types through workspace protocol:

  "dependencies": {
    "package-types": "workspace:^",
      ....
  },

When SDK package has changes, but types package doesn't and I run nx release it doesn't replace its dependency version to a semantic version (f.e. 1.0.0).

When both of them have changes - all is good, types version is bumped and in SDK workspace is replaced correctly.

Expected Behavior

I'd expect it to always replace workspace dependency to the version that types package is currently in.

Attaching my nx.json for reference:

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "defaultBase": "main",
  "release": {
    "projects": ["src/sdk/*", "src/types/*"],
    "projectsRelationship": "independent",
    "version": {
      "conventionalCommits": true,
      "generatorOptions": {
        "fallbackCurrentVersionResolver": "disk",
        "skipLockFileUpdate": true,
        "updateDependents": "inherit"
      }
    },
    "changelog": {
      "automaticFromRef": true,
      "projectChangelogs": {
        "createRelease": "github",
        "file": false
      },
      "renderOptions": {
        "authors": false
      }
    },
    "conventionalCommits": {
      "types": {
        "ci": false,
        "platform": false,
        "publish": false,
        "tests": false,
        "docs": {
          "semverBump": "patch"
        },
        "chore": {
          "semverBump": "patch"
        },
        "refactor": {
          "semverBump": "patch"
        }
      }
    }
  },
  "targetDefaults": {
    "build": {
      "dependsOn": ["^build"],
      "cache": true
    },
    "test": {
      "dependsOn": ["^build"],
      "cache": true
    },
    "lint": {
      "cache": true
    },
    "migration:run": {
      "dependsOn": ["build"],
      "cache": true
    },
    "start:dev": {
      "dependsOn": ["^build"],
      "cache": false
    }
  }
}

Maybe I'm missing some sort of onfiguration?

GitHub Repo

No response

Steps to Reproduce

  1. Have two packages: SDK and types
  2. SDK has to have dependency to types and be linked to it using workspace
  3. Only make changes in SDK package and run nx release
  4. workspace dependency is not replaced

Nx Report

Node           : 20.11.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.9.0

nx (global)  : 19.6.4
nx           : 19.6.4
@nx/js       : 19.6.4
typescript   : 5.5.2

Failure Logs

UPDATE src/sdk/address-sdk/package.json [dry-run]

    "name": "package-sdk",
-   "version": "3.4.0",
+   "version": "3.4.1",

No changes are done to package-types dependency it just bumps SDK version when testing locally with pnpx nx release --verbose --yes --dry-run



### Package Manager Version

9.9.0

### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)

### Additional Information

I'm not entirely sure if it's a bug or feature request, or maybe it's related to pnpm? But I've tried for example `pnpm pack` and it replaced dependency version correctly. I assume nx under the hood uses pacakge manager publish command?

Maybe I'me just missing some sort of configuration in `nx.json`?
JamesHenry commented 1 month ago

"updateDependents": "inherit"

This value doesn’t exist, it’s auto or never, I think you want auto