NestJS module that builds workflow bundles and registers the workflow controller.
NestJS module that provides workflow functionality. It builds the workflow bundles on module initialization (onModuleInit) and registers the WorkflowController that serves the workflow runtime routes.
Add WorkflowModule.forRoot() to the imports array of your root module.
import { Module } from "@nestjs/common";
import { WorkflowModule } from "workflow/nest";
@Module({
imports: [WorkflowModule.forRoot()],
})
export class AppModule {}If your NestJS project compiles to CommonJS via SWC, pass moduleType and distDir so the builder can rewrite imports in the generated bundles:
import { Module } from "@nestjs/common";
import { WorkflowModule } from "workflow/nest";
@Module({
imports: [
WorkflowModule.forRoot({
moduleType: "commonjs",
distDir: "dist",
}),
],
})
export class AppModule {}Static Methods
forRoot(options?)
Configures the module and returns a NestJS DynamicModule registered as global. It calls configureWorkflowController with the resolved output directory, and (unless skipBuild is set) creates a NestLocalBuilder that builds the workflow bundles when the module initializes.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | WorkflowModuleOptions | Optional. Configures the workflow build. |
WorkflowModuleOptions
Extends NestBuilderOptions — all builder options are accepted, plus skipBuild:
| Option | Type | Default | Description |
|---|---|---|---|
skipBuild | boolean | false | Skip building workflow bundles on startup. Useful in production when the bundles are pre-built. |
workingDir | string | process.cwd() | Working directory for the NestJS application. |
dirs | string[] | ['src'] | Directories to scan for workflow files. |
outDir | string | '.nestjs/workflow' (relative to workingDir) | Output directory for generated workflow bundles. |
watch | boolean | false | Enable watch mode for development. |
moduleType | 'es6' | 'commonjs' | 'es6' | SWC module compilation type. Set to 'commonjs' if your NestJS project compiles to CJS via SWC. |
distDir | string | 'dist' | Directory where NestJS compiles .ts source files to .js (relative to workingDir). Used when moduleType is 'commonjs'. Should match the outDir in your tsconfig.json. |
Returns
forRoot() returns a DynamicModule to include in the imports array of your root module.












