- Schema validation for options, with
--helpoutput in the terminal. - Nx caching — Nx can cache executor outputs and replay them on cache hits.
- Composability — executors can invoke other executors via
runExecutor. - Nx Console integration — options are rendered as a form in the editor.
Creating an executor
1
Add the plugin package if you don't have one yet
2
Scaffold a new executor
Defining the schema
schema.json describes the options your executor accepts:
schema.d.ts mirrors the JSON schema:
Executor function signature
Every executor exports a default async function that receives the resolved options and anExecutorContext. It must return Promise<{ success: boolean }>.
Accessing project information via context
TheExecutorContext object contains the full project graph and the name of the project and target being run:
Registering an executor in project.json
Add the executor to the relevant project’stargets block in project.json:
Composing executors with runExecutor
Executors can invoke other executors. This is useful when a task is a combination of multiple steps:Custom hashers
By default, Nx hashes all files in a project to determine cache validity. If your executor only depends on a subset of files, or on external data not in the project, you can provide a custom hasher. Generate an executor with a hasher included:hasher.ts and registering it in executors.json:
Task and a HasherContext:
