Skip to main content

Nx

Nx Configuration

Configuration options when using DxCore with Nx.

⚠️ Experimental: Nx support is experimental. APIs and behavior may change without notice.

Adapter Capabilities

The Nx adapter expects a task graph in Nx’s JSON format piped to stdin. Use nx run-many --targets=<tasks> --graph=stdout to produce the task graph. The graph provides task-level dependency information and per-task cache configuration, but does not include task hashes or cache status at plan time.

Field Available Description
Task ID Yes Derived from project and target
Package name Yes Nx project name
Dependencies Yes Task dependency edges
Cacheable Yes From target cache config in nx.json or project.json
Task hash No Not available at plan time
Cache status No Not available at plan time

Build System Flag

Pass -b nx to both dispatcher and agent commands:

# Dispatcher
nx run-many --targets=build,test --graph=stdout | dxcore dispatch \
-c $URL -s $SESSION -t $TOKEN -b nx
# Agent
dxcore agent \
-c $URL -a agent-1 -s $SESSION -t $TOKEN -b nx

Working Directory

Use -w if your Nx workspace root differs from the repository root:

nx run-many --targets=build,test --graph=stdout | dxcore dispatch \
-c $URL -s $SESSION -t $TOKEN -b nx -w ./workspace

Cache Behavior

DxCore does not provide its own caching. For Nx workspaces, caching is handled by the Nx cache system (local or Nx Cloud remote cache). DxCore is not involved in cache reads or writes.

Because the Nx adapter does not receive cache status at plan time (it is not included in the graph output), the coordinator has no knowledge of which tasks will be cache hits. Nx’s own cache operates transparently at execution time when the agent runs npx nx run <package>:<task>.

Sharding Tasks

Place a dxcore.json file in the project directory to shard specific targets:

{
"shards": {
"test": 3,
"e2e": 2
}
}

The dispatcher scans **/dxcore.json in the working directory and sends the resolved shard config to the coordinator as part of the graph submission. The coordinator never accesses the filesystem directly. See Shard Configuration for the full format.

Tip

Sharding is especially useful for Nx e2e targets that run Playwright or Cypress suites, which can take minutes per project.

Next Steps