From 78854ec2b982e463b2d899b2592745c67820036e Mon Sep 17 00:00:00 2001 From: Karthik Kalyanaraman Date: Thu, 5 Feb 2026 22:43:38 -0800 Subject: [PATCH] Remove dirs option --- .changeset/fifty-keys-stare.md | 5 +++ .../workflow-next/with-workflow.mdx | 40 +------------------ docs/content/docs/getting-started/next.mdx | 39 ------------------ packages/next/src/index.ts | 16 +------- 4 files changed, 8 insertions(+), 92 deletions(-) create mode 100644 .changeset/fifty-keys-stare.md diff --git a/.changeset/fifty-keys-stare.md b/.changeset/fifty-keys-stare.md new file mode 100644 index 0000000000..a373cbdd33 --- /dev/null +++ b/.changeset/fifty-keys-stare.md @@ -0,0 +1,5 @@ +--- +"workflow": patch +--- + +Remove `dirs` option from `workflows` config object in `withWorkflow()` and related documentation diff --git a/docs/content/docs/api-reference/workflow-next/with-workflow.mdx b/docs/content/docs/api-reference/workflow-next/with-workflow.mdx index d92da97264..892b076832 100644 --- a/docs/content/docs/api-reference/workflow-next/with-workflow.mdx +++ b/docs/content/docs/api-reference/workflow-next/with-workflow.mdx @@ -49,42 +49,4 @@ export default async function config( } return nextConfig; } -``` - -## Configuration - -The second argument to `withWorkflow` accepts the following options: - -### `workflows.dirs` - -Directories to scan for workflows and steps. If provided, this completely overrides the defaults. - -- **Type:** `string[]` -- **Default:** `['pages', 'app', 'src/pages', 'src/app']` - -```typescript title="next.config.ts" lineNumbers -import { withWorkflow } from "workflow/next"; -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = {}; - -export default withWorkflow(nextConfig, { - workflows: { - dirs: ['workflows', 'src/workflows'], // [!code highlight] - }, -}); -``` - -### `workflows.local.port` - -Port for the local workflow server during development. - -- **Type:** `number` -- **Default:** Uses the `PORT` environment variable - -### `workflows.local.dataDir` - -Directory for storing local workflow data during development. - -- **Type:** `string` -- **Default:** `'.next/workflow-data'` +``` diff --git a/docs/content/docs/getting-started/next.mdx b/docs/content/docs/getting-started/next.mdx index eea396681d..ccc83064cd 100644 --- a/docs/content/docs/getting-started/next.mdx +++ b/docs/content/docs/getting-started/next.mdx @@ -257,45 +257,6 @@ Check the [Deploying](/docs/deploying) section to learn how your workflows can b ## Troubleshooting -### Out of Memory (OOM) during build - -When using `withWorkflow()` in a large Next.js application, the "Discovering workflow directives" phase may consume excessive memory, causing builds to fail with OOM errors on standard build machines (e.g., 16 GB RAM). - -**Solution:** Use the `workflows.dirs` option to limit the directories scanned for workflow directives. By default, `withWorkflow` scans `['pages', 'app', 'src/pages', 'src/app']`, which in large applications can include thousands of files. - -If your workflows are located in a specific directory, configure `dirs` to only scan that directory: - -```typescript title="next.config.ts" lineNumbers -import { withWorkflow } from "workflow/next"; -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = {}; - -export default withWorkflow(nextConfig, { - workflows: { - // Only scan the workflows directory instead of the entire app - dirs: ['workflows'], // [!code highlight] - }, -}); -``` - -If you need workflows in both app routes and a dedicated directory: - -```typescript title="next.config.ts" lineNumbers -import { withWorkflow } from "workflow/next"; -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = {}; - -export default withWorkflow(nextConfig, { - workflows: { - dirs: ['app/api', 'workflows'], // [!code highlight] - }, -}); -``` - -This significantly reduces memory usage and build times by avoiding scanning unrelated application code. - ### Next.js 16.1+ compatibility If you see this error when upgrading to Next.js 16.1 or later: diff --git a/packages/next/src/index.ts b/packages/next/src/index.ts index 192ba921aa..1d96e05615 100644 --- a/packages/next/src/index.ts +++ b/packages/next/src/index.ts @@ -4,12 +4,6 @@ import semver from 'semver'; import { getNextBuilder } from './builder.js'; import { maybeInvalidateCacheOnSwcChange } from './swc-cache.js'; -/** - * Default directories to scan for workflows and steps. - * These are the standard Next.js app directories. - */ -const DEFAULT_WORKFLOW_DIRS = ['pages', 'app', 'src/pages', 'src/app']; - export function withWorkflow( nextConfigOrFn: | NextConfig @@ -25,13 +19,6 @@ export function withWorkflow( port?: number; dataDir?: string; }; - /** - * Directories to scan for workflows and steps. - * If provided, this completely overrides the defaults. - * - * @default ['pages', 'app', 'src/pages', 'src/app'] - */ - dirs?: string[]; }; } = {} ) { @@ -149,7 +136,8 @@ export function withWorkflow( const NextBuilder = await getNextBuilder(); const workflowBuilder = new NextBuilder({ watch: shouldWatch, - dirs: workflows?.dirs ?? DEFAULT_WORKFLOW_DIRS, + // discover workflows from pages/app entries + dirs: ['pages', 'app', 'src/pages', 'src/app'], workingDir: process.cwd(), buildTarget: 'next', workflowsBundlePath: '', // not used in base