Skip to content

Unexpected cache behavior when combining "dependentTasksOutputFiles" and "--excludeTaskDependencies" #35855

@Kilghaz

Description

@Kilghaz

Current Behavior

The combination of using inputs with "dependentTasksOutputFiles" produces a different stable hash when running the the target with "--excludeTaskDependencies" and without.

This results in potentially completely different outcomes for a target, depending on the state of the cache and the usage of the "--excludeTaskDependencies" flag.

Expected Behavior

At least display a warning, when the combination of --excludeTaskDependencies and dependentTasksOutputFiles is detected. Alternatively, throw an error, because the behavior might be very unexpected.

GitHub Repo

No response

Steps to Reproduce

libs/lib/project.json

  {
    "name": "lib",
    "targets": {
      "build": {
        "command": "tsc --emitDeclarationOnly --outDir dist/libs/lib",
        "outputs": ["{workspaceRoot}/dist/libs/lib"],
        "inputs": ["{projectRoot}/**/*.ts"]
      } 
    } 
  } 

apps/app/project.json

  {
    "name": "lib",
    "targets": {
      "build": {
        "command": "tsc --emitDeclarationOnly --outDir dist/libs/lib",
        "outputs": ["{workspaceRoot}/dist/libs/lib"],
        "inputs": ["{projectRoot}/**/*.ts"]
      }
    }
  }

apps/app/project.json

  {
    "name": "app",
    "targets": {
      "build": {
        "command": "tsc -p apps/app",
        "outputs": ["{workspaceRoot}/dist/apps/app"],
        "inputs": [
          "{projectRoot}/**/*.ts",
          { "dependentTasksOutputFiles": "**/*.d.ts", "transitive": true }
        ],
        "dependsOn": ["^build"]
      }
    }
  }

Normal run

  • Run nx build app, actually runs all targets
  • Run nx build app again, returns output from cache

Run with --excludeTaskDependencies

  • Run nx build app, actually runs all targets
  • Run nx build app --excludeTaskDependencies, just runs app:build

Nx Report

NX   Report complete - copy this into the issue template

Node           : 25.6.1
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 11.9.0
daemon         : Disabled

nx (global)    : 22.5.4
nx             : 22.5.4
@nx/js         : 22.5.4
@nx/eslint     : 22.5.4
@nx/workspace  : 22.5.4
@nx/jest       : 22.5.4
@nx/devkit     : 22.5.4
@nx/plugin     : 22.5.4
typescript     : 5.9.3
---------------------------------------
Local workspace plugins:
cosign
docker
trivy
---------------------------------------
Cache Usage: 2.28 GB / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions