NestLocalBuilder

Builder that scans a NestJS project for workflow files and compiles them into the step, workflow, and webhook bundles plus a manifest. WorkflowModule.forRoot() creates and runs one automatically on startup. Instantiate it yourself only when you need to build bundles outside the module lifecycle (e.g. a custom build script for production with skipBuild).

Usage

scripts/build-workflows.ts
import { NestLocalBuilder } from "workflow/nest/builder";

const builder = new NestLocalBuilder({
  dirs: ["src"],
});

await builder.build();

console.log(`Workflow bundles written to ${builder.outDir}`);

API signature

Constructor

new NestLocalBuilder(options?) creates a builder for the given options.

Parameters

ParameterTypeDescription
optionsNestBuilderOptionsOptional. Configures the workflow build.

NestBuilderOptions

OptionTypeDefaultDescription
workingDirstringprocess.cwd()Working directory for the NestJS application.
dirsstring[]['src']Directories to scan for workflow files.
outDirstring'.nestjs/workflow' (relative to workingDir)Output directory for generated workflow bundles.
watchbooleanfalseEnable watch mode for development.
moduleType'es6' | 'commonjs''es6'SWC module compilation type. When 'commonjs', the builder rewrites externalized imports in the steps bundle to use require() through createRequire, avoiding ECMAScript module (ESM) and CommonJS (CJS) named-export interop issues with SWC's output.
distDirstring'dist'Directory where NestJS compiles .ts source files to .js (relative to workingDir). Used when moduleType is 'commonjs' to resolve compiled file paths. Should match the outDir in your tsconfig.json.
sourcemapboolean | 'inline' | 'linked' | 'external' | 'both''inline' (dev) / false (prod)Controls source maps on generated workflow bundles. Accepts the same values as esbuild's sourcemap option. Defaults to 'inline' in development and false in production. Can also be set via the WORKFLOW_SOURCEMAP environment variable.

Methods

build()

Builds the workflow bundles. Writes steps.mjs, workflows.mjs, webhook.mjs, and manifest.json to the output directory (plus a .gitignore covering the generated files when not deploying to Vercel). Returns Promise<void>.

Properties

outDir

Read-only getter that returns the output directory for generated workflow bundles: the outDir option as passed, or the default .nestjs/workflow resolved against workingDir.

Returns

The constructor returns a NestLocalBuilder instance.