Skip to content

Conversation

@pranaygp
Copy link
Collaborator

This commit extracts builder infrastructure from @workflow/cli into a new
shared @workflow/builders package. This improves code organization by:

  • Creating a dedicated package for builder functionality
  • Allowing @workflow/next and @workflow/nitro to depend on builders directly
  • Reducing coupling between framework integrations and the CLI
  • Preparing for moving NextBuilder to @workflow/next in the next PR

Changes:

  • Created new @workflow/builders package
  • Moved BaseBuilder, BasicBuilder, and VercelBuildOutputAPIBuilder
  • Moved esbuild plugins (swc, discover-entries, node-module)
  • Moved WorkflowConfig and BuildTarget types
  • Updated @workflow/cli to import from @workflow/builders
  • Updated @workflow/nitro to import from @workflow/builders
  • Re-exported types from CLI for backwards compatibility

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

@vercel
Copy link
Contributor

vercel bot commented Oct 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Oct 26, 2025 7:06am
example-nextjs-workflow-webpack Ready Ready Preview Comment Oct 26, 2025 7:06am
example-workflow Ready Ready Preview Comment Oct 26, 2025 7:06am
workbench-nitro-workflow Ready Ready Preview Comment Oct 26, 2025 7:06am
workflow-docs Ready Ready Preview Comment Oct 26, 2025 7:06am

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2025

🦋 Changeset detected

Latest commit: a4adba7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@workflow/builders Patch
@workflow/cli Patch
@workflow/nitro Patch
@workflow/next Patch
workflow Patch
@workflow/world-testing Patch
@workflow/ai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pranaygp pranaygp changed the base branch from pranaygp/10-25-rename_vercel_static_builder_to_basic_builder to graphite-base/73 October 26, 2025 06:18
import { mkdir, writeFile } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { BaseBuilder } from './base-builder.js';
import { BaseBuilder } from '@workflow/builders';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be moving these builders over in future PRs

@@ -1,6 +1,6 @@
import { mkdir } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { BaseBuilder } from './base-builder.js';
import { BaseBuilder } from '@workflow/builders';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be moving these builders over in future PRs

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The index.ts file was importing constants from a non-existent constants.js file, causing TypeScript compilation to fail.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index a305ca5..32a74a6 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -8,4 +8,3 @@ export { applySwcTransform } from './apply-swc-transform.js';
 export { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';
 export { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
 export { createSwcPlugin } from './swc-esbuild-plugin.js';
-export { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from './constants.js';

Analysis

Missing constants.js file causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/builders/src/index.ts at line 11 due to missing constants.js file

How to reproduce:

cd packages/builders && pnpm run build

Result:

src/index.ts(11,60): error TS2307: Cannot find module './constants.js' or its corresponding type declarations.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The constants.ts file was missing but required by index.ts for exporting STEP_QUEUE_TRIGGER and WORKFLOW_QUEUE_TRIGGER constants.

View Details
📝 Patch Details
diff --git a/packages/builders/src/constants.ts b/packages/builders/src/constants.ts
new file mode 100644
index 0000000..97e01ae
--- /dev/null
+++ b/packages/builders/src/constants.ts
@@ -0,0 +1,2 @@
+export const STEP_QUEUE_TRIGGER = 'step' as const;
+export const WORKFLOW_QUEUE_TRIGGER = 'workflow' as const;
\ No newline at end of file

Analysis

Missing constants file causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/builders/src/index.ts line 11 due to missing constants module

How to reproduce:

cd packages/builders && pnpm run build

Result:

src/index.ts(11,60): error TS2307: Cannot find module './constants.js' or its corresponding type declarations.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The file imports constants from a non-existent ./constants.js module, causing TypeScript compilation to fail.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index a305ca5..396d2cd 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -8,4 +8,4 @@ export { applySwcTransform } from './apply-swc-transform.js';
 export { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';
 export { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
 export { createSwcPlugin } from './swc-esbuild-plugin.js';
-export { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from './constants.js';
+

Analysis

Missing constants.js module causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/builders/src/index.ts due to missing import of non-existent ./constants.js file

How to reproduce:

cd packages/builders && pnpm run build

Result:

src/index.ts(11,60): error TS2307: Cannot find module './constants.js' or its corresponding type declarations.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The file tried to import constants from a non-existent ./constants.js module, causing TypeScript compilation to fail. The unused export statement was removed since the constants weren't referenced anywhere in the codebase.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index a305ca5..396d2cd 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -8,4 +8,4 @@ export { applySwcTransform } from './apply-swc-transform.js';
 export { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';
 export { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
 export { createSwcPlugin } from './swc-esbuild-plugin.js';
-export { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from './constants.js';
+

Analysis

Missing constants file causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/builders/src/index.ts line 11 due to import from non-existent ./constants.js module

How to reproduce:

cd packages/builders && npx tsc

Result:

src/index.ts(11,60): error TS2307: Cannot find module './constants.js' or its corresponding type declarations.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The TypeScript compiler failed because line 11 attempts to import STEP_QUEUE_TRIGGER and WORKFLOW_QUEUE_TRIGGER from a non-existent constants.js file. This import was added during the builders package creation but the constants file was never created.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index a305ca5..396d2cd 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -8,4 +8,4 @@ export { applySwcTransform } from './apply-swc-transform.js';
 export { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';
 export { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
 export { createSwcPlugin } from './swc-esbuild-plugin.js';
-export { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from './constants.js';
+

Analysis

TypeScript compilation failure due to missing constants file

What fails: TypeScript compiler fails on packages/builders/src/index.ts line 11 due to import from non-existent './constants.js' file

How to reproduce:

cd packages/builders && pnpm run build

Result:

src/index.ts(11,60): error TS2307: Cannot find module './constants.js' or its corresponding type declarations.

export function isValidBuildTarget(
target: string | undefined
): target is BuildTarget {
return target === 'standalone' || target === 'vercel-build-output-api';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return target === 'standalone' || target === 'vercel-build-output-api';
return (
target === 'standalone' ||
target === 'vercel-build-output-api' ||
target === 'next'
);

The isValidBuildTarget function doesn't validate the 'next' build target even though it's included in the validBuildTargets array and is a valid BuildTarget type.

View Details

Analysis

isValidBuildTarget() function doesn't validate the 'next' build target

What fails: The isValidBuildTarget() type guard function in packages/builders/src/types.ts only validates 'standalone' and 'vercel-build-output-api', but the BuildTarget type includes 'next' from the validBuildTargets array. This breaks the type safety contract of the function.

How to reproduce:

const validBuildTargets = ['standalone', 'vercel-build-output-api', 'next'] as const;
type BuildTarget = (typeof validBuildTargets)[number];

function isValidBuildTarget(target: string | undefined): target is BuildTarget {
  return target === 'standalone' || target === 'vercel-build-output-api';
}

// In packages/next/src/index.ts line 92, 'next' is used:
const config = { buildTarget: 'next' as BuildTarget }; // Valid type
isValidBuildTarget(config.buildTarget); // Returns false - inconsistency!

Result: isValidBuildTarget('next') returns false even though 'next' is:

  • Present in the validBuildTargets array (line 4)
  • A valid BuildTarget type value (line 6)
  • Used in real code (packages/next/src/index.ts:92, packages/cli/src/lib/builders/webhook-route.test.ts:26,71,104, packages/nitro/src/builders.ts:8)

Expected: The type guard should validate all values in the validBuildTargets array to maintain consistency with the BuildTarget type definition in strict TypeScript mode.

Fix verified: Updated the type guard to include 'next':

return (
  target === 'standalone' ||
  target === 'vercel-build-output-api' ||
  target === 'next'
);

All tests pass, including webhook-route.test.ts tests that use buildTarget: 'next'.

…cture

This commit extracts builder infrastructure from @workflow/cli into a new
shared @workflow/builders package. This improves code organization by:

- Creating a dedicated package for builder functionality
- Allowing @workflow/next and @workflow/nitro to depend on builders directly
- Reducing coupling between framework integrations and the CLI
- Preparing for moving NextBuilder to @workflow/next in the next PR

Changes:
- Created new @workflow/builders package
- Moved BaseBuilder, BasicBuilder, and VercelBuildOutputAPIBuilder
- Moved esbuild plugins (swc, discover-entries, node-module)
- Moved WorkflowConfig and BuildTarget types
- Updated @workflow/cli to import from @workflow/builders
- Updated @workflow/nitro to import from @workflow/builders
- Re-exported types from CLI for backwards compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants