@workflow/builders 5.0.0-beta.2 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apply-swc-transform.d.ts +1 -1
- package/dist/apply-swc-transform.d.ts.map +1 -1
- package/dist/apply-swc-transform.js.map +1 -1
- package/dist/base-builder.d.ts +3 -3
- package/dist/base-builder.d.ts.map +1 -1
- package/dist/base-builder.js +13 -8
- package/dist/base-builder.js.map +1 -1
- package/dist/get-input-files.test.js +48 -1
- package/dist/get-input-files.test.js.map +1 -1
- package/dist/swc-esbuild-plugin.d.ts +1 -1
- package/dist/swc-esbuild-plugin.d.ts.map +1 -1
- package/dist/swc-esbuild-plugin.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -21,7 +21,7 @@ export type WorkflowManifest = {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
export declare function applySwcTransform(filename: string, source: string, mode: 'workflow' | 'step' | '
|
|
24
|
+
export declare function applySwcTransform(filename: string, source: string, mode: 'workflow' | 'step' | 'detect' | false,
|
|
25
25
|
/**
|
|
26
26
|
* Optional absolute path to the file being transformed.
|
|
27
27
|
* Used for module specifier resolution when filename is relative.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-swc-transform.d.ts","sourceRoot":"","sources":["../src/apply-swc-transform.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE;QACN,CAAC,gBAAgB,EAAE,MAAM,GAAG;YAC1B,CAAC,YAAY,EAAE,MAAM,GAAG;gBACtB,MAAM,EAAE,MAAM,CAAC;aAChB,CAAC;SACH,CAAC;KACH,CAAC;IACF,SAAS,CAAC,EAAE;QACV,CAAC,gBAAgB,EAAE,MAAM,GAAG;YAC1B,CAAC,YAAY,EAAE,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O,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC,CA6ED"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-swc-transform.js","sourceRoot":"","sources":["../src/apply-swc-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,iFAAiF;AACjF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAGlC,CAAC;AAEJ,SAAS,mBAAmB,CAAC,WAAoB;IAC/C,MAAM,GAAG,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,IAAI,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,+BAA+B,CAAC,GAAG,CAAC,CAAC;QAC9C,qBAAqB,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA0BD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,MAAc,EACd,
|
|
1
|
+
{"version":3,"file":"apply-swc-transform.js","sourceRoot":"","sources":["../src/apply-swc-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,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UAAU;iBACpB;gBACD,eAAe,EAAE,gBAAgB,CAAC,eAAe;gBACjD,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB;aACtD;SACF;QACD,sDAAsD;QACtD,qDAAqD;QACrD,4CAA4C;QAC5C,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAC5C,wCAAwC,CACzC,CAAC;IAEF,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAChC,oBAAoB,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CACd,CAAC;IAEtB,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,gBAAgB,EAAE,eAAe,IAAI,EAAE;KACxC,CAAC;AACJ,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { transform } from '@swc/core';\nimport { getDecoratorOptionsForDirectory } from './config-helpers.js';\nimport { resolveModuleSpecifier } from './module-specifier.js';\n\nconst require = createRequire(import.meta.url);\n\n// Cache decorator options per directory - tsconfig doesn't change during a build\nconst decoratorOptionsCache = new Map<\n string,\n ReturnType<typeof getDecoratorOptionsForDirectory>\n>();\n\nfunction getDecoratorOptions(projectRoot?: string) {\n const cwd = projectRoot ?? process.cwd();\n let cached = decoratorOptionsCache.get(cwd);\n if (!cached) {\n cached = getDecoratorOptionsForDirectory(cwd);\n decoratorOptionsCache.set(cwd, cached);\n }\n return cached;\n}\n\nexport type WorkflowManifest = {\n steps?: {\n [relativeFileName: string]: {\n [functionName: string]: {\n stepId: string;\n };\n };\n };\n workflows?: {\n [relativeFileName: string]: {\n [functionName: string]: {\n workflowId: string;\n };\n };\n };\n classes?: {\n [relativeFileName: string]: {\n [className: string]: {\n classId: string;\n };\n };\n };\n};\n\nexport async function applySwcTransform(\n filename: string,\n source: string,\n mode: 'workflow' | 'step' | 'detect' | false,\n /**\n * Optional absolute path to the file being transformed.\n * Used for module specifier resolution when filename is relative.\n * If not provided, filename is joined with process.cwd().\n */\n absolutePath?: string,\n /**\n * Optional project root used for module specifier resolution.\n * Defaults to process.cwd() for backwards compatibility.\n */\n projectRoot?: string\n): Promise<{\n code: string;\n workflowManifest: WorkflowManifest;\n}> {\n const resolvedProjectRoot = projectRoot ?? process.cwd();\n const decoratorOptions = await getDecoratorOptions(resolvedProjectRoot);\n\n const swcPluginPath = require.resolve('@workflow/swc-plugin', {\n paths: [dirname(fileURLToPath(import.meta.url))],\n });\n\n // Determine if this is a TypeScript file\n const isTypeScript =\n filename.endsWith('.ts') ||\n filename.endsWith('.tsx') ||\n filename.endsWith('.mts') ||\n filename.endsWith('.cts');\n\n // Resolve module specifier for packages (node_modules or workspace packages)\n const absoluteFilename = absolutePath\n ? absolutePath\n : isAbsolute(filename)\n ? filename\n : join(resolvedProjectRoot, filename);\n const { moduleSpecifier } = resolveModuleSpecifier(\n absoluteFilename,\n resolvedProjectRoot\n );\n\n // Transform with SWC to support syntax esbuild doesn't\n const result = await transform(source, {\n filename,\n swcrc: false,\n jsc: {\n parser: {\n ...(isTypeScript\n ? {\n syntax: 'typescript',\n tsx: filename.endsWith('.tsx'),\n decorators: decoratorOptions.decorators,\n }\n : {\n syntax: 'ecmascript',\n jsx: filename.endsWith('.jsx'),\n decorators: decoratorOptions.decorators,\n }),\n },\n target: 'es2022',\n experimental: mode\n ? {\n plugins: [[swcPluginPath, { mode, moduleSpecifier }]],\n }\n : undefined,\n transform: {\n react: {\n runtime: 'preserve',\n },\n legacyDecorator: decoratorOptions.legacyDecorator,\n decoratorMetadata: decoratorOptions.decoratorMetadata,\n },\n },\n // TODO: investigate proper source map support as they\n // won't even be used in Node.js by default unless we\n // intercept errors and apply them ourselves\n sourceMaps: false,\n minify: false,\n });\n\n const workflowCommentMatch = result.code.match(\n /\\/\\*\\*__internal_workflows({.*?})\\*\\//s\n );\n\n const parsedWorkflows = JSON.parse(\n workflowCommentMatch?.[1] || '{}'\n ) as WorkflowManifest;\n\n return {\n code: result.code,\n workflowManifest: parsedWorkflows || {},\n };\n}\n"]}
|
package/dist/base-builder.d.ts
CHANGED
|
@@ -171,10 +171,10 @@ export declare abstract class BaseBuilder {
|
|
|
171
171
|
*/
|
|
172
172
|
protected get shouldExposePublicManifest(): boolean;
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
174
|
+
* Resolves the workflow manifest diagnostics path, when this builder should
|
|
175
|
+
* emit one.
|
|
176
176
|
*/
|
|
177
|
-
protected
|
|
177
|
+
protected getDiagnosticsManifestPath(): string | undefined;
|
|
178
178
|
/**
|
|
179
179
|
* Creates a manifest JSON file containing step/workflow/class metadata
|
|
180
180
|
* and graph data for visualization.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-builder.d.ts","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA2BjD,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,8BAAsB,WAAW;IAC/B,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;gBAErB,MAAM,EAAE,cAAc;IAIlC,SAAS,KAAK,oBAAoB,IAAI,MAAM,CAE3C;IAED;;;OAGG;IACH,SAAS,KAAK,wBAAwB,IAAI,OAAO,CAEhD;IAED,SAAS,CAAC,kBAAkB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtD,OAAO,CAAC,4B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AC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;QACpC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAC7B,oBAAoB,CAAC,EAAE,KAAK,CAAC;YAC3B,IAAI,EAAE,cAAc,CAAC;YACrB,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;YACjB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;SAC9B,CAAC,CAAC;KACJ,GACA,OAAO,CAAC,IAAI,CAAC;IAwBhB;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI3C;;OAEG;cACa,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,kBAAkB;IAWhC;;;OAGG;IACH,SAAS,KAAK,0BAA0B,IAAI,OAAO,CAElD;IAED;;;OAGG;IACH,SAAS,CAAC,0BAA0B,IAAI,MAAM,GAAG,SAAS;IAgB1D;;;;;OAKG;cACa,cAAc,CAAC,EAC7B,kBAAkB,EAClB,WAAW,EACX,QAAQ,GACT,EAAE;QACD,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAsD/B,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,wBAAwB;IAyDhC,OAAO,CAAC,sBAAsB;CAc/B"}
|
package/dist/base-builder.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { mkdir, readFile, realpath, rename, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { basename, dirname, join, relative, resolve } from 'node:path';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
|
-
import { pluralize
|
|
5
|
+
import { pluralize } from '@workflow/utils';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import enhancedResolveOriginal from 'enhanced-resolve';
|
|
8
8
|
import * as esbuild from 'esbuild';
|
|
@@ -830,7 +830,7 @@ export const POST = workflowEntrypoint(workflowCode);`;
|
|
|
830
830
|
],
|
|
831
831
|
plugins: [
|
|
832
832
|
createSwcPlugin({
|
|
833
|
-
mode: '
|
|
833
|
+
mode: 'step',
|
|
834
834
|
projectRoot: this.transformProjectRoot,
|
|
835
835
|
sideEffectEntries: normalizedClientSideEffectEntries,
|
|
836
836
|
}),
|
|
@@ -984,11 +984,16 @@ export const OPTIONS = handler;`;
|
|
|
984
984
|
return process.env.WORKFLOW_PUBLIC_MANIFEST === '1';
|
|
985
985
|
}
|
|
986
986
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
987
|
+
* Resolves the workflow manifest diagnostics path, when this builder should
|
|
988
|
+
* emit one.
|
|
989
989
|
*/
|
|
990
|
-
|
|
991
|
-
|
|
990
|
+
getDiagnosticsManifestPath() {
|
|
991
|
+
if (this.config.diagnosticsDir) {
|
|
992
|
+
return resolve(this.config.workingDir, this.config.diagnosticsDir, 'workflows-manifest.json');
|
|
993
|
+
}
|
|
994
|
+
if (this.config.buildTarget === 'vercel-build-output-api') {
|
|
995
|
+
return this.resolvePath('.vercel/output/diagnostics/workflows-manifest.json');
|
|
996
|
+
}
|
|
992
997
|
}
|
|
993
998
|
/**
|
|
994
999
|
* Creates a manifest JSON file containing step/workflow/class metadata
|
|
@@ -1008,8 +1013,8 @@ export const OPTIONS = handler;`;
|
|
|
1008
1013
|
const manifestJson = JSON.stringify(output, null, 2);
|
|
1009
1014
|
await mkdir(manifestDir, { recursive: true });
|
|
1010
1015
|
await writeFile(join(manifestDir, 'manifest.json'), manifestJson);
|
|
1011
|
-
|
|
1012
|
-
|
|
1016
|
+
const diagnosticsManifestPath = this.getDiagnosticsManifestPath();
|
|
1017
|
+
if (diagnosticsManifestPath) {
|
|
1013
1018
|
await this.ensureDirectory(diagnosticsManifestPath);
|
|
1014
1019
|
await writeFile(diagnosticsManifestPath, manifestJson);
|
|
1015
1020
|
}
|
package/dist/base-builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-builder.js","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,uBAAuB,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM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OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;iBACpB,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAE5B,MAAM,YAAY,GAChB,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAE/D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;oBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,KAAK,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;iBAC/D,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,sBAAsB,CAC5B,OAAoC;QAEpC,MAAM,MAAM,GAAwD,EAAE,CAAC;QACvE,IAAI,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC;QAE5B,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACtB,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;YACrD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { mkdir, readFile, realpath, rename, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join, relative, resolve } from 'node:path';\nimport { promisify } from 'node:util';\nimport { pluralize, usesVercelWorld } from '@workflow/utils';\nimport chalk from 'chalk';\nimport enhancedResolveOriginal from 'enhanced-resolve';\nimport * as esbuild from 'esbuild';\nimport { findUp } from 'find-up';\nimport { glob } from 'tinyglobby';\nimport {\n applySwcTransform,\n type WorkflowManifest,\n} from './apply-swc-transform.js';\nimport { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';\nimport { getEsbuildTsconfigOptions } from './esbuild-tsconfig.js';\nimport { getImportPath } from './module-specifier.js';\nimport { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';\nimport { createPseudoPackagePlugin } from './pseudo-package-esbuild-plugin.js';\nimport { createSwcPlugin } from './swc-esbuild-plugin.js';\nimport type { WorkflowConfig } from './types.js';\nimport { extractWorkflowGraphs } from './workflows-extractor.js';\n\nconst enhancedResolve = promisify(enhancedResolveOriginal);\n\nconst EMIT_SOURCEMAPS_FOR_DEBUGGING =\n process.env.WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING === '1';\n\n/**\n * Normalize an array of file paths by appending the `realpath()` of each entry\n * (to handle symlinks, e.g. pnpm/workspace layouts) and deduplicating.\n */\nasync function withRealpaths(entries: string[]): Promise<string[]> {\n return Array.from(\n new Set(\n (\n await Promise.all(\n entries.map(async (entry) => {\n const resolved = await realpath(entry).catch(() => undefined);\n return resolved ? [entry, resolved] : [entry];\n })\n )\n ).flat()\n )\n );\n}\n\nexport interface DiscoveredEntries {\n discoveredSteps: Set<string>;\n discoveredWorkflows: Set<string>;\n discoveredSerdeFiles: Set<string>;\n}\n\n/**\n * Base class for workflow builders. Provides common build logic for transforming\n * workflow source files into deployable bundles using esbuild and SWC.\n *\n * Subclasses must implement the build() method to define builder-specific logic.\n */\nexport abstract class BaseBuilder {\n protected config: WorkflowConfig;\n\n constructor(config: WorkflowConfig) {\n this.config = config;\n }\n\n protected get transformProjectRoot(): string {\n return this.config.projectRoot || this.config.workingDir;\n }\n\n /**\n * Whether informational BaseBuilder logs should be printed.\n * Subclasses can override this to silence progress logs while keeping warnings/errors.\n */\n protected get shouldLogBaseBuilderInfo(): boolean {\n return true;\n }\n\n protected logBaseBuilderInfo(...args: unknown[]): void {\n if (this.shouldLogBaseBuilderInfo) {\n console.log(...args);\n }\n }\n\n private logCreateWorkflowsBundleInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateWorkflowsBundleLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n private logCreateWebhookBundleInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateWebhookBundleLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n private logCreateManifestInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateManifestLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n /**\n * When outputting CJS, esbuild replaces `import.meta` with an empty object,\n * making `import.meta.url` (and `import.meta.resolve`) undefined. This method\n * returns banner code and `define` entries that polyfill them using CJS\n * equivalents (`__filename`, `require.resolve`) so user code (e.g. Prisma)\n * that relies on `import.meta.url` works correctly in bundled CJS output.\n */\n private getCjsImportMetaPolyfill(format: string): {\n banner: string;\n define: Record<string, string>;\n } {\n if (format !== 'cjs') return { banner: '', define: {} };\n return {\n banner:\n 'var __import_meta_url = typeof __filename !== \"undefined\" ? require(\"url\").pathToFileURL(__filename).href : undefined;\\n' +\n 'var __import_meta_resolve = typeof require !== \"undefined\" && typeof __filename !== \"undefined\" ' +\n '? (s) => require(\"url\").pathToFileURL(require.resolve(s)).href : undefined;\\n',\n define: {\n 'import.meta.url': '__import_meta_url',\n 'import.meta.resolve': '__import_meta_resolve',\n },\n };\n }\n\n /**\n * When outputting fully-bundled ESM, CJS dependencies that call require()\n * for Node.js builtins (e.g. debug → require('tty')) break because esbuild's\n * CJS-to-ESM __require shim doesn't have access to a real require function.\n * This banner provides one via createRequire so bundled CJS code works in ESM.\n */\n private getEsmRequireBanner(format: string): string {\n if (format !== 'esm') return '';\n return 'import { createRequire as __createRequire } from \"node:module\";\\nvar require = __createRequire(import.meta.url);\\n';\n }\n\n /**\n * Performs the complete build process for workflows.\n * Subclasses must implement this to define their specific build steps.\n */\n abstract build(): Promise<void>;\n\n /**\n * Finds tsconfig.json/jsconfig.json for the project.\n * Used by esbuild to properly resolve module imports during bundling.\n */\n protected async findTsConfigPath(): Promise<string | undefined> {\n const cwd = this.config.workingDir || process.cwd();\n return findUp(['tsconfig.json', 'jsconfig.json'], { cwd });\n }\n\n /**\n * Discovers all source files in the configured directories.\n * Searches for TypeScript and JavaScript files while excluding common build\n * and dependency directories.\n */\n protected async getInputFiles(): Promise<string[]> {\n const ignore = [\n '**/node_modules/**',\n '**/.git/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.output/**',\n '**/.vercel/**',\n '**/.workflow-data/**',\n '**/.workflow-vitest/**',\n '**/.well-known/workflow/**',\n '**/.svelte-kit/**',\n '**/.turbo/**',\n '**/.cache/**',\n '**/.yarn/**',\n '**/.pnpm-store/**',\n ];\n\n // Use relative patterns with `cwd` per directory so that `dot: true`\n // applies consistently to both the search pattern *and* the ignore\n // patterns. When absolute patterns are used with tinyglobby, the `**`\n // in ignore patterns does not match dot-prefixed path segments.\n const results = await Promise.all(\n this.config.dirs.map((dir) => {\n const cwd = resolve(this.config.workingDir, dir);\n return glob(['**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'], {\n cwd,\n ignore,\n absolute: true,\n dot: true,\n });\n })\n );\n\n return results.flat();\n }\n\n /**\n * Caches discovered workflow entries by input array reference.\n * Uses WeakMap to allow garbage collection when input arrays are no longer referenced.\n * This cache is invalidated automatically when the inputs array reference changes\n * (e.g., when files are added/removed during watch mode).\n */\n private discoveredEntries: WeakMap<string[], DiscoveredEntries> =\n new WeakMap();\n\n protected async discoverEntries(\n inputs: string[],\n outdir: string,\n tsconfigPath?: string\n ): Promise<DiscoveredEntries> {\n const previousResult = this.discoveredEntries.get(inputs);\n\n if (previousResult) {\n return previousResult;\n }\n const state: DiscoveredEntries = {\n discoveredSteps: new Set(),\n discoveredWorkflows: new Set(),\n discoveredSerdeFiles: new Set(),\n };\n\n const discoverStart = Date.now();\n\n // Resolve the SDK runtime entry point so that the discovery pass\n // traces through it and discovers serde classes (like `Run`) that\n // live inside SDK packages. Without this, files like `run.js` are\n // only discovered when user code happens to import them.\n // This is resolved here (rather than in callers) so that the original\n // `inputs` array reference is preserved for WeakMap caching — callers\n // like createWorkflowsBundle and createStepsBundle can share the same\n // cache entry when they pass the same inputFiles array.\n const resolvedWorkflowRuntime = await enhancedResolve(\n outdir,\n 'workflow/runtime'\n ).catch(() => undefined);\n const entryPoints = resolvedWorkflowRuntime\n ? [...inputs, resolvedWorkflowRuntime]\n : inputs;\n\n const effectiveTsconfigPath =\n tsconfigPath ?? (await this.findTsConfigPath());\n const esbuildTsconfigOptions = await getEsbuildTsconfigOptions(\n effectiveTsconfigPath\n );\n try {\n await esbuild.build({\n treeShaking: true,\n entryPoints,\n plugins: [\n createDiscoverEntriesPlugin(state, this.transformProjectRoot),\n ],\n platform: 'node',\n write: false,\n outdir,\n bundle: true,\n sourcemap: false,\n absWorkingDir: this.config.workingDir,\n logLevel: 'silent',\n ...esbuildTsconfigOptions,\n // External packages that should not be bundled during discovery\n external: this.config.externalPackages || [],\n });\n } catch (_) {}\n\n this.logBaseBuilderInfo(\n `Discovering workflow directives`,\n `${Date.now() - discoverStart}ms`\n );\n\n this.discoveredEntries.set(inputs, state);\n return state;\n }\n\n /**\n * Writes debug information to a JSON file for troubleshooting build issues.\n * Uses atomic write (temp file + rename) to prevent race conditions when\n * multiple builds run concurrently.\n */\n private async writeDebugFile(\n outfile: string,\n debugData: object,\n merge?: boolean\n ): Promise<void> {\n const prefix = this.config.debugFilePrefix || '';\n const targetPath = `${dirname(outfile)}/${prefix}${basename(outfile)}.debug.json`;\n let existing = {};\n\n try {\n if (merge) {\n try {\n const content = await readFile(targetPath, 'utf8');\n existing = JSON.parse(content);\n } catch (e) {\n // File doesn't exist yet or is corrupted - start fresh.\n // Don't log error for ENOENT (file not found) as that's expected on first run.\n if ((e as NodeJS.ErrnoException).code !== 'ENOENT') {\n console.warn('Error reading debug file, starting fresh:', e);\n }\n }\n }\n\n const mergedData = JSON.stringify(\n {\n ...existing,\n ...debugData,\n },\n null,\n 2\n );\n\n // Write atomically: write to temp file, then rename.\n // rename() is atomic on POSIX systems and provides best-effort atomicity on Windows.\n // Prevents race conditions where concurrent builds read partially-written files.\n const tempPath = `${targetPath}.${randomUUID()}.tmp`;\n await writeFile(tempPath, mergedData);\n await rename(tempPath, targetPath);\n } catch (error: unknown) {\n console.warn('Failed to write debug file:', error);\n }\n }\n\n /**\n * Logs and optionally throws on esbuild errors and warnings.\n * @param throwOnError - If true, throws an error when esbuild errors are present\n */\n private logEsbuildMessages(\n result: { errors?: any[]; warnings?: any[] },\n phase: string,\n throwOnError = true,\n options?: {\n suppressWarnings?: boolean;\n }\n ): void {\n if (result.errors && result.errors.length > 0) {\n console.error(`❌ esbuild errors in ${phase}:`);\n const errorMessages: string[] = [];\n for (const error of result.errors) {\n console.error(` ${error.text}`);\n errorMessages.push(error.text);\n if (error.location) {\n const location = ` at ${error.location.file}:${error.location.line}:${error.location.column}`;\n console.error(location);\n errorMessages.push(location);\n }\n }\n\n if (throwOnError) {\n throw new Error(\n `Build failed during ${phase}:\\n${errorMessages.join('\\n')}`\n );\n }\n }\n\n if (\n !options?.suppressWarnings &&\n result.warnings &&\n result.warnings.length > 0\n ) {\n console.warn(`! esbuild warnings in ${phase}:`);\n for (const warning of result.warnings) {\n console.warn(` ${warning.text}`);\n if (warning.location) {\n console.warn(\n ` at ${warning.location.file}:${warning.location.line}:${warning.location.column}`\n );\n }\n }\n }\n }\n\n /**\n * Converts an absolute file path to a normalized relative path for the manifest.\n */\n private getRelativeFilepath(absolutePath: string): string {\n const normalizedFile = absolutePath.replace(/\\\\/g, '/');\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Handle files discovered outside the working directory\n if (relativePath.startsWith('../')) {\n relativePath = relativePath\n .split('/')\n .filter((part) => part !== '..')\n .join('/');\n }\n return relativePath;\n }\n\n /**\n * Creates a bundle for workflow step functions.\n * Steps have full Node.js runtime access and handle side effects, API calls, etc.\n *\n * @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code\n * @returns Build context (for watch mode) and the collected workflow manifest\n */\n protected async createStepsBundle({\n inputFiles,\n format = 'esm',\n outfile,\n externalizeNonSteps,\n rewriteTsExtensions,\n tsconfigPath,\n discoveredEntries,\n }: {\n tsconfigPath?: string;\n inputFiles: string[];\n outfile: string;\n format?: 'cjs' | 'esm';\n externalizeNonSteps?: boolean;\n rewriteTsExtensions?: boolean;\n discoveredEntries?: DiscoveredEntries;\n }): Promise<{\n context: esbuild.BuildContext | undefined;\n manifest: WorkflowManifest;\n }> {\n const stepsBundleStart = Date.now();\n const workflowManifest: WorkflowManifest = {};\n const builtInSteps = 'workflow/internal/builtins';\n\n const resolvedBuiltInSteps = await enhancedResolve(\n dirname(outfile),\n 'workflow/internal/builtins'\n ).catch((err) => {\n throw new Error(\n [\n chalk.red('Failed to resolve built-in steps sources.'),\n `${chalk.yellow.bold('hint:')} run \\`${chalk.cyan.italic('npm install workflow')}\\` to resolve this issue.`,\n '',\n `Caused by: ${chalk.red(String(err))}`,\n ].join('\\n')\n );\n });\n\n // Discovery of workflow/step/serde entries. The SDK runtime entry point\n // (workflow/runtime) is resolved inside discoverEntries() itself so that\n // callers can pass the original inputFiles reference and benefit from\n // WeakMap caching across createWorkflowsBundle / createStepsBundle calls.\n const discovered =\n discoveredEntries ??\n (await this.discoverEntries(inputFiles, dirname(outfile), tsconfigPath));\n const stepFiles = [...discovered.discoveredSteps].sort();\n const workflowFiles = [...discovered.discoveredWorkflows].sort();\n const serdeFiles = [...discovered.discoveredSerdeFiles].sort();\n\n // Include serde files that aren't already step files for cross-context class registration.\n // Classes need to be registered in the step bundle so they can be deserialized\n // when receiving data from workflows and serialized when returning data to workflows.\n const stepFilesSet = new Set(stepFiles);\n const serdeOnlyFiles = serdeFiles.filter((f) => !stepFilesSet.has(f));\n\n // log the step files for debugging\n await this.writeDebugFile(outfile, {\n stepFiles,\n workflowFiles,\n serdeOnlyFiles,\n });\n\n // Helper to create import statement from file path\n // For workspace/node_modules packages, uses the package name so esbuild\n // will resolve through package.json exports with the appropriate conditions\n const createImport = (file: string) => {\n const { importPath, isPackage } = getImportPath(\n file,\n this.config.workingDir\n );\n\n if (isPackage) {\n // Use package name - esbuild will resolve via package.json exports\n return `import '${importPath}';`;\n }\n\n // Local app file - use relative path\n // Normalize both paths to forward slashes before calling relative()\n // This is critical on Windows where relative() can produce unexpected results with mixed path formats\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n const normalizedFile = file.replace(/\\\\/g, '/');\n // Calculate relative path from working directory to the file\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Ensure relative paths start with ./ so esbuild resolves them correctly.\n // Paths like \".output/...\" are not valid relative specifiers and must\n // become \"./.output/...\".\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n };\n\n // Create a virtual entry that imports all files. All step definitions\n // will get registered thanks to the swc transform.\n const stepImports = stepFiles.map(createImport).join('\\n');\n\n // Include serde-only files for class registration side effects\n const serdeImports = serdeOnlyFiles.map(createImport).join('\\n');\n\n const entryContent = `\n // Built in steps\n import '${builtInSteps}';\n // User steps\n ${stepImports}\n // Serde files for cross-context class registration\n ${serdeImports}\n // API entrypoint\n export { stepEntrypoint as POST } from 'workflow/runtime';`;\n\n // Bundle with esbuild and our custom SWC plugin\n const entriesToBundle = externalizeNonSteps\n ? [\n ...stepFiles,\n ...serdeFiles,\n ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),\n ]\n : undefined;\n const normalizedEntriesToBundle = entriesToBundle\n ? await withRealpaths(entriesToBundle)\n : undefined;\n const normalizedSideEffectEntries = await withRealpaths([\n ...stepFiles,\n ...serdeOnlyFiles,\n ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),\n ]);\n const esbuildTsconfigOptions =\n await getEsbuildTsconfigOptions(tsconfigPath);\n const { banner: importMetaBanner, define: importMetaDefine } =\n this.getCjsImportMetaPolyfill(format);\n const esmRequireBanner = this.getEsmRequireBanner(format);\n\n const esbuildCtx = await esbuild.context({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${importMetaBanner}${esmRequireBanner}`,\n },\n stdin: {\n contents: entryContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n format,\n platform: 'node',\n conditions: ['node'],\n target: 'es2022',\n write: true,\n treeShaking: true,\n keepNames: true,\n minify: false,\n jsx: 'preserve',\n logLevel: 'error',\n // Use tsconfig for path alias resolution.\n // For symlinked configs this uses tsconfigRaw to preserve cwd-relative aliases.\n ...esbuildTsconfigOptions,\n define: importMetaDefine,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n // Inline source maps for better stack traces in step execution.\n // Steps execute in Node.js context and inline sourcemaps ensure we get\n // meaningful stack traces with proper file names and line numbers when errors\n // occur in deeply nested function calls across multiple files.\n sourcemap: 'inline',\n plugins: [\n // Handle pseudo-packages like 'server-only' and 'client-only' by providing\n // empty modules. Must run first to intercept these before other resolution.\n createPseudoPackagePlugin(),\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: normalizedEntriesToBundle,\n outdir: outfile ? dirname(outfile) : undefined,\n projectRoot: this.transformProjectRoot,\n workflowManifest,\n rewriteTsExtensions,\n sideEffectEntries: normalizedSideEffectEntries,\n }),\n ],\n // Plugin should catch most things, but this lets users hard override\n // if the plugin misses anything that should be externalized\n external: ['bun', 'bun:*', ...(this.config.externalPackages || [])],\n });\n\n const stepsResult = await esbuildCtx.rebuild();\n\n this.logEsbuildMessages(stepsResult, 'steps bundle creation');\n this.logBaseBuilderInfo(\n 'Created steps bundle',\n `${Date.now() - stepsBundleStart}ms`\n );\n\n // Handle workflow-only files that may have been tree-shaken from the bundle.\n // These files have no steps, so esbuild removes them, but we still need their\n // workflow metadata for the manifest. Transform them separately.\n const workflowOnlyFiles = workflowFiles.filter(\n (f) => !stepFiles.includes(f)\n );\n await Promise.all(\n workflowOnlyFiles.map(async (workflowFile) => {\n try {\n const source = await readFile(workflowFile, 'utf8');\n const relativeFilepath = this.getRelativeFilepath(workflowFile);\n const { workflowManifest: fileManifest } = await applySwcTransform(\n relativeFilepath,\n source,\n 'workflow',\n workflowFile,\n this.transformProjectRoot\n );\n if (fileManifest.workflows) {\n workflowManifest.workflows = Object.assign(\n workflowManifest.workflows || {},\n fileManifest.workflows\n );\n }\n if (fileManifest.classes) {\n workflowManifest.classes = Object.assign(\n workflowManifest.classes || {},\n fileManifest.classes\n );\n }\n } catch (error) {\n // Log warning but continue - don't fail build for workflow-only file issues\n console.warn(\n `Warning: Failed to extract workflow metadata from ${workflowFile}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n })\n );\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n\n if (this.config.watch) {\n return { context: esbuildCtx, manifest: workflowManifest };\n }\n await esbuildCtx.dispose();\n return { context: undefined, manifest: workflowManifest };\n }\n\n /**\n * Creates a bundle for workflow orchestration functions.\n * Workflows run in a sandboxed VM and coordinate step execution.\n *\n * @param bundleFinalOutput - If false, skips the final bundling step (used by Next.js)\n */\n protected async createWorkflowsBundle({\n inputFiles,\n format = 'esm',\n outfile,\n bundleFinalOutput = true,\n keepInterimBundleContext = this.config.watch,\n tsconfigPath,\n discoveredEntries,\n }: {\n tsconfigPath?: string;\n inputFiles: string[];\n outfile: string;\n format?: 'cjs' | 'esm';\n bundleFinalOutput?: boolean;\n keepInterimBundleContext?: boolean;\n discoveredEntries?: DiscoveredEntries;\n }): Promise<{\n manifest: WorkflowManifest;\n interimBundleCtx?: esbuild.BuildContext;\n bundleFinal?: (interimBundleResult: string) => Promise<void>;\n }> {\n const discovered =\n discoveredEntries ??\n (await this.discoverEntries(inputFiles, dirname(outfile), tsconfigPath));\n const workflowFiles = [...discovered.discoveredWorkflows].sort();\n const serdeFiles = [...discovered.discoveredSerdeFiles].sort();\n\n // Include serde files that aren't already workflow files for cross-context class registration.\n // Classes need to be registered in the workflow bundle so they can be deserialized\n // when receiving data from steps or when serializing data to send to steps.\n const workflowFilesSet = new Set(workflowFiles);\n const serdeOnlyFiles = serdeFiles.filter((f) => !workflowFilesSet.has(f));\n\n // log the workflow files for debugging\n await this.writeDebugFile(outfile, { workflowFiles, serdeOnlyFiles });\n\n // Helper to create import statement from file path\n // For packages, uses the package name so esbuild will resolve through\n // package.json exports with conditions: ['workflow']\n const createImport = (file: string) => {\n const { importPath, isPackage } = getImportPath(\n file,\n this.config.workingDir\n );\n\n if (isPackage) {\n // Use package name - esbuild will resolve via package.json exports\n // and apply the 'workflow' condition\n return `import '${importPath}';`;\n }\n\n // Local app file - use relative path\n // Normalize both paths to forward slashes before calling relative()\n // This is critical on Windows where relative() can produce unexpected results with mixed path formats\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n const normalizedFile = file.replace(/\\\\/g, '/');\n // Calculate relative path from working directory to the file\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Ensure relative paths start with ./ so esbuild resolves them correctly.\n // Paths like \".output/...\" are not valid relative specifiers and must\n // become \"./.output/...\".\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n };\n\n // Create a virtual entry that imports all workflow files\n // The SWC plugin in workflow mode emits `globalThis.__private_workflows.set(workflowId, fn)`\n // calls directly, so we just need to import the files (Map is initialized via banner)\n const workflowImports = workflowFiles.map(createImport).join('\\n');\n\n // Include serde-only files for class registration side effects\n const serdeImports = serdeOnlyFiles.map(createImport).join('\\n');\n\n const imports = serdeImports\n ? `${workflowImports}\\n// Serde files for cross-context class registration\\n${serdeImports}`\n : workflowImports;\n\n const bundleStartTime = Date.now();\n const workflowManifest: WorkflowManifest = {};\n const esbuildTsconfigOptions =\n await getEsbuildTsconfigOptions(tsconfigPath);\n const normalizedWorkflowSideEffectEntries = await withRealpaths([\n ...workflowFiles,\n ...serdeOnlyFiles,\n ]);\n\n // Bundle with esbuild and our custom SWC plugin in workflow mode.\n // this bundle will be run inside a vm isolate\n const interimBundleCtx = await esbuild.context({\n stdin: {\n contents: imports,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n bundle: true,\n absWorkingDir: this.config.workingDir,\n format: 'cjs', // Runs inside the VM which expects cjs\n platform: 'neutral', // The platform is neither node nor browser\n mainFields: ['module', 'main'], // To support npm style imports\n conditions: ['workflow'], // Allow packages to export 'workflow' compliant versions\n target: 'es2022',\n write: false,\n treeShaking: true,\n keepNames: true,\n minify: false,\n // Initialize the workflow registry at the very top of the bundle\n // This must be in banner (not the virtual entry) because esbuild's bundling\n // can reorder code, and the .set() calls need the Map to exist first\n banner: {\n js: 'globalThis.__private_workflows = new Map();',\n },\n // Inline source maps for better stack traces in workflow VM execution.\n // This intermediate bundle is executed via runInContext() in a VM, so we need\n // inline source maps to get meaningful stack traces instead of \"evalmachine.<anonymous>\".\n sourcemap: 'inline',\n // Use tsconfig for path alias resolution.\n // For symlinked configs this uses tsconfigRaw to preserve cwd-relative aliases.\n ...esbuildTsconfigOptions,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n plugins: [\n // Handle pseudo-packages like 'server-only' and 'client-only' by providing\n // empty modules. Must run first to intercept these before other resolution.\n createPseudoPackagePlugin(),\n createSwcPlugin({\n mode: 'workflow',\n projectRoot: this.transformProjectRoot,\n workflowManifest,\n sideEffectEntries: normalizedWorkflowSideEffectEntries,\n }),\n // This plugin must run after the swc plugin to ensure dead code elimination\n // happens first, preventing false positives on Node.js imports in unused code paths\n createNodeModuleErrorPlugin(),\n ],\n // NOTE: We intentionally do NOT use the external option here for workflow bundles.\n // When packages are marked external with format: 'cjs', esbuild generates require() calls.\n // However, the workflow VM (vm.runInContext) does not have require() defined - it only\n // provides module.exports and exports. External packages would fail at runtime with:\n // ReferenceError: require is not defined\n // Instead, we bundle everything and rely on:\n // - createPseudoPackagePlugin() to handle server-only/client-only with empty modules\n // - createNodeModuleErrorPlugin() to catch Node.js builtin imports at build time\n });\n let shouldDisposeInterimBundleCtx = !keepInterimBundleContext;\n try {\n const interimBundle = await interimBundleCtx.rebuild();\n\n this.logEsbuildMessages(\n interimBundle,\n 'intermediate workflow bundle',\n true,\n {\n suppressWarnings: this.config.suppressCreateWorkflowsBundleWarnings,\n }\n );\n this.logCreateWorkflowsBundleInfo(\n 'Created intermediate workflow bundle',\n `${Date.now() - bundleStartTime}ms`\n );\n\n if (this.config.workflowManifestPath) {\n const resolvedPath = resolve(\n process.cwd(),\n this.config.workflowManifestPath\n );\n let prefix = '';\n\n if (resolvedPath.endsWith('.cjs')) {\n prefix = 'module.exports = ';\n } else if (\n resolvedPath.endsWith('.js') ||\n resolvedPath.endsWith('.mjs')\n ) {\n prefix = 'export default ';\n }\n\n await mkdir(dirname(resolvedPath), { recursive: true });\n await writeFile(\n resolvedPath,\n prefix + JSON.stringify(workflowManifest, null, 2)\n );\n }\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n\n if (\n !interimBundle.outputFiles ||\n interimBundle.outputFiles.length === 0\n ) {\n throw new Error('No output files generated from esbuild');\n }\n\n // Serde compliance warnings: check if workflow bundle has Node.js imports\n // alongside serde-registered classes (these will fail at runtime in the sandbox)\n if (\n workflowManifest.classes &&\n Object.keys(workflowManifest.classes).length > 0\n ) {\n const { analyzeSerdeCompliance } = await import('./serde-checker.js');\n const bundleText = interimBundle.outputFiles[0].text;\n const serdeResult = analyzeSerdeCompliance({\n sourceCode: '',\n workflowCode: bundleText,\n manifest: workflowManifest,\n });\n // De-dupe warnings: group identical issues across classes\n const issuesToClasses = new Map<string, Set<string>>();\n for (const cls of serdeResult.classes) {\n if (!cls.compliant) {\n for (const issue of cls.issues) {\n let affectedClasses = issuesToClasses.get(issue);\n if (!affectedClasses) {\n affectedClasses = new Set<string>();\n issuesToClasses.set(issue, affectedClasses);\n }\n affectedClasses.add(cls.className);\n }\n }\n }\n for (const [issue, affectedClasses] of issuesToClasses) {\n const classNames = [...affectedClasses];\n const classLabel =\n classNames.length === 1\n ? `class \"${classNames[0]}\"`\n : `classes ${classNames.map((name) => `\"${name}\"`).join(', ')}`;\n console.warn(\n chalk.yellow(`⚠ Serde warning for ${classLabel}: `) + issue\n );\n }\n }\n\n const bundleFinal = async (interimBundle: string) => {\n const workflowBundleCode = interimBundle;\n\n const workflowFunctionCode = `// biome-ignore-all lint: generated file\n/* eslint-disable */\nimport { workflowEntrypoint } from 'workflow/runtime';\n\nconst workflowCode = \\`${workflowBundleCode.replace(/[\\\\`$]/g, '\\\\$&')}\\`;\n\nexport const POST = workflowEntrypoint(workflowCode);`;\n\n // we skip the final bundling step for Next.js so it can bundle itself\n if (!bundleFinalOutput) {\n if (!outfile) {\n throw new Error(`Invariant: missing outfile for workflow bundle`);\n }\n // Ensure the output directory exists\n const outputDir = dirname(outfile);\n await mkdir(outputDir, { recursive: true });\n\n // Atomic write: write to temp file then rename to prevent\n // file watchers from reading partial file during write\n const tempPath = `${outfile}.${randomUUID()}.tmp`;\n await writeFile(tempPath, workflowFunctionCode);\n await rename(tempPath, outfile);\n return;\n }\n\n const bundleStartTime = Date.now();\n\n // Now bundle this so we can resolve the @workflow/core dependency\n // we could remove this if we do nft tracing or similar instead\n const finalEsmRequireBanner = this.getEsmRequireBanner(format);\n const finalWorkflowResult = await esbuild.build({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${finalEsmRequireBanner}`,\n },\n stdin: {\n contents: workflowFunctionCode,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile,\n // Source maps for the final workflow bundle wrapper (not important since this code\n // doesn't run in the VM - only the intermediate bundle sourcemap is relevant)\n sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n format,\n platform: 'node',\n target: 'es2022',\n write: true,\n keepNames: true,\n minify: false,\n external: ['@aws-sdk/credential-provider-web-identity'],\n });\n\n this.logEsbuildMessages(\n finalWorkflowResult,\n 'final workflow bundle',\n true,\n {\n suppressWarnings: this.config.suppressCreateWorkflowsBundleWarnings,\n }\n );\n this.logCreateWorkflowsBundleInfo(\n 'Created final workflow bundle',\n `${Date.now() - bundleStartTime}ms`\n );\n };\n await bundleFinal(interimBundle.outputFiles[0].text);\n\n if (keepInterimBundleContext) {\n shouldDisposeInterimBundleCtx = false;\n return {\n manifest: workflowManifest,\n interimBundleCtx,\n bundleFinal,\n };\n }\n return { manifest: workflowManifest };\n } catch (error) {\n shouldDisposeInterimBundleCtx = true;\n throw error;\n } finally {\n if (shouldDisposeInterimBundleCtx) {\n try {\n await interimBundleCtx.dispose();\n } catch (disposeError) {\n console.warn(\n 'Warning: Failed to dispose workflow bundle context',\n disposeError\n );\n }\n }\n }\n }\n\n /**\n * Creates a client library bundle for workflow execution.\n * The client library allows importing and calling workflows from application code.\n * Only generated if clientBundlePath is specified in config.\n */\n protected async createClientLibrary(): Promise<void> {\n if (!this.config.clientBundlePath) {\n // Silently exit since no client bundle was requested\n return;\n }\n\n this.logBaseBuilderInfo(\n 'Generating a client library at',\n this.config.clientBundlePath\n );\n this.logBaseBuilderInfo(\n 'NOTE: The recommended way to use workflow with a framework like NextJS is using the loader/plugin with webpack/turbobpack/rollup'\n );\n\n // Ensure we have the directory for the client bundle\n const outputDir = dirname(this.config.clientBundlePath);\n await mkdir(outputDir, { recursive: true });\n\n const inputFiles = await this.getInputFiles();\n\n // Discover serde files from the input files' dependency tree for cross-context class registration.\n // Classes need to be registered in the client bundle so they can be serialized\n // when passing data to workflows via start() and deserialized when receiving workflow results.\n const { discoveredSerdeFiles } = await this.discoverEntries(\n inputFiles,\n outputDir\n );\n\n // Identify serde files that aren't in the inputFiles (deduplicated)\n const inputFilesNormalized = new Set(\n inputFiles.map((f) => f.replace(/\\\\/g, '/'))\n );\n const serdeOnlyFiles = [...discoveredSerdeFiles].filter(\n (f) => !inputFilesNormalized.has(f)\n );\n\n // Re-exports for input files (user's workflow/step definitions).\n // These must use valid relative specifiers because some frameworks pass\n // generated files like \".output/server/index.mjs\" as input files.\n const reexports = inputFiles\n .map((file) => {\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, file).replace(\n /\\\\/g,\n '/'\n );\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `export * from '${relativePath}';`;\n })\n .join('\\n');\n\n // Side-effect imports for serde files not in inputFiles (for class registration)\n const serdeImports = serdeOnlyFiles\n .map((file) => {\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, file).replace(\n /\\\\/g,\n '/'\n );\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n })\n .join('\\n');\n\n // Combine: serde imports (for registration side effects) + re-exports\n const entryContent = serdeImports\n ? `// Serde files for cross-context class registration\\n${serdeImports}\\n${reexports}`\n : reexports;\n\n // Bundle with esbuild and our custom SWC plugin\n const normalizedClientSideEffectEntries = await withRealpaths([\n ...inputFiles,\n ...serdeOnlyFiles,\n ]);\n const clientResult = await esbuild.build({\n banner: {\n js: '// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n',\n },\n stdin: {\n contents: entryContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile: this.config.clientBundlePath,\n bundle: true,\n format: 'esm',\n platform: 'node',\n jsx: 'preserve',\n target: 'es2022',\n write: true,\n treeShaking: true,\n external: ['@workflow/core'],\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n plugins: [\n createSwcPlugin({\n mode: 'client',\n projectRoot: this.transformProjectRoot,\n sideEffectEntries: normalizedClientSideEffectEntries,\n }),\n ],\n });\n\n this.logEsbuildMessages(clientResult, 'client library bundle');\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n }\n\n /**\n * Creates a webhook handler bundle for resuming workflows via HTTP callbacks.\n *\n * @param bundle - If true, bundles dependencies (needed for Build Output API)\n */\n protected async createWebhookBundle({\n outfile,\n bundle = false,\n }: {\n outfile: string;\n bundle?: boolean;\n }): Promise<void> {\n this.logCreateWebhookBundleInfo('Creating webhook route');\n await mkdir(dirname(outfile), { recursive: true });\n\n // Create a static route that calls resumeWebhook\n // This route works for both Next.js and Vercel Build Output API\n const routeContent = `import { resumeWebhook } from 'workflow/api';\n\nasync function handler(request) {\n const url = new URL(request.url);\n // Extract token from pathname: /.well-known/workflow/v1/webhook/{token}\n const pathParts = url.pathname.split('/');\n const token = decodeURIComponent(pathParts[pathParts.length - 1]);\n\n if (!token) {\n return new Response('Missing token', { status: 400 });\n }\n\n try {\n const response = await resumeWebhook(token, request);\n return response;\n } catch (error) {\n // TODO: differentiate between invalid token and other errors\n console.error('Error during resumeWebhook', error);\n return new Response(null, { status: 404 });\n }\n}\n\nexport const GET = handler;\nexport const POST = handler;\nexport const PUT = handler;\nexport const PATCH = handler;\nexport const DELETE = handler;\nexport const HEAD = handler;\nexport const OPTIONS = handler;`;\n\n if (!bundle) {\n // For Next.js, just write the unbundled file\n await writeFile(outfile, routeContent);\n return;\n }\n\n // For Build Output API, bundle with esbuild to resolve imports\n\n const webhookEsmRequireBanner = this.getEsmRequireBanner('esm');\n const webhookBundleStart = Date.now();\n const result = await esbuild.build({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${webhookEsmRequireBanner}`,\n },\n stdin: {\n contents: routeContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'webhook-route.js',\n loader: 'js',\n },\n outfile,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n jsx: 'preserve',\n format: 'esm',\n platform: 'node',\n conditions: ['import', 'module', 'node', 'default'],\n target: 'es2022',\n write: true,\n treeShaking: true,\n keepNames: true,\n minify: false,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,\n mainFields: ['module', 'main'],\n // Don't externalize anything - bundle everything including workflow packages\n external: [],\n });\n\n this.logEsbuildMessages(result, 'webhook bundle creation');\n this.logCreateWebhookBundleInfo(\n 'Created webhook bundle',\n `${Date.now() - webhookBundleStart}ms`\n );\n }\n\n /**\n * Creates a package.json file with the specified module type.\n */\n protected async createPackageJson(\n dir: string,\n type: 'commonjs' | 'module'\n ): Promise<void> {\n const packageJson = { type };\n await writeFile(\n join(dir, 'package.json'),\n JSON.stringify(packageJson, null, 2)\n );\n }\n\n /**\n * Creates a .vc-config.json file for Vercel Build Output API functions.\n */\n protected async createVcConfig(\n dir: string,\n config: {\n runtime?: string;\n handler?: string;\n launcherType?: string;\n architecture?: string;\n shouldAddHelpers?: boolean;\n shouldAddSourcemapSupport?: boolean;\n maxDuration?: number | 'max';\n experimentalTriggers?: Array<{\n type: 'queue/v2beta';\n topic: string;\n consumer: string;\n maxDeliveries?: number;\n retryAfterSeconds?: number;\n initialDelaySeconds?: number;\n }>;\n }\n ): Promise<void> {\n const vcConfig = {\n runtime: config.runtime ?? 'nodejs22.x',\n handler: config.handler ?? 'index.mjs',\n launcherType: config.launcherType ?? 'Nodejs',\n architecture: config.architecture ?? 'arm64',\n shouldAddHelpers: config.shouldAddHelpers ?? true,\n ...(config.maxDuration !== undefined && {\n maxDuration: config.maxDuration,\n }),\n ...(config.shouldAddSourcemapSupport !== undefined && {\n shouldAddSourcemapSupport: config.shouldAddSourcemapSupport,\n }),\n ...(config.experimentalTriggers && {\n experimentalTriggers: config.experimentalTriggers,\n }),\n };\n\n await writeFile(\n join(dir, '.vc-config.json'),\n JSON.stringify(vcConfig, null, 2)\n );\n }\n\n /**\n * Resolves a path relative to the working directory.\n */\n protected resolvePath(path: string): string {\n return resolve(this.config.workingDir, path);\n }\n\n /**\n * Ensures the directory for a file path exists, creating it if necessary.\n */\n protected async ensureDirectory(filePath: string): Promise<void> {\n await mkdir(dirname(filePath), { recursive: true });\n }\n\n private async createSwcGitignore(): Promise<void> {\n try {\n await writeFile(\n join(this.config.workingDir, '.swc', '.gitignore'),\n '*\\n'\n );\n } catch {\n // We're intentionally silently ignoring this error - creating .gitignore isn't critical\n }\n }\n\n /**\n * Whether the manifest should be exposed as a public HTTP route.\n * Controlled by the `WORKFLOW_PUBLIC_MANIFEST` environment variable.\n */\n protected get shouldExposePublicManifest(): boolean {\n return process.env.WORKFLOW_PUBLIC_MANIFEST === '1';\n }\n\n /**\n * Whether diagnostics artifacts should be emitted to Vercel output.\n * This is enabled when the resolved world target is Vercel.\n */\n protected get shouldEmitVercelDiagnostics(): boolean {\n return (\n usesVercelWorld() || this.config.buildTarget === 'vercel-build-output-api'\n );\n }\n\n /**\n * Creates a manifest JSON file containing step/workflow/class metadata\n * and graph data for visualization.\n *\n * @returns The manifest JSON string, or undefined if manifest creation failed.\n */\n protected async createManifest({\n workflowBundlePath,\n manifestDir,\n manifest,\n }: {\n workflowBundlePath: string;\n manifestDir: string;\n manifest: WorkflowManifest;\n }): Promise<string | undefined> {\n const buildStart = Date.now();\n this.logCreateManifestInfo('Creating manifest...');\n\n try {\n const workflowGraphs = await extractWorkflowGraphs(workflowBundlePath);\n\n const steps = this.convertStepsManifest(manifest.steps);\n const workflows = this.convertWorkflowsManifest(\n manifest.workflows,\n workflowGraphs\n );\n const classes = this.convertClassesManifest(manifest.classes);\n\n const output = { version: '1.0.0', steps, workflows, classes };\n const manifestJson = JSON.stringify(output, null, 2);\n\n await mkdir(manifestDir, { recursive: true });\n await writeFile(join(manifestDir, 'manifest.json'), manifestJson);\n if (this.shouldEmitVercelDiagnostics) {\n const diagnosticsManifestPath = this.resolvePath(\n '.vercel/output/diagnostics/workflows-manifest.json'\n );\n await this.ensureDirectory(diagnosticsManifestPath);\n await writeFile(diagnosticsManifestPath, manifestJson);\n }\n\n const stepCount = Object.values(steps).reduce(\n (acc, s) => acc + Object.keys(s).length,\n 0\n );\n const workflowCount = Object.values(workflows).reduce(\n (acc, w) => acc + Object.keys(w).length,\n 0\n );\n const classCount = Object.values(classes).reduce(\n (acc, c) => acc + Object.keys(c).length,\n 0\n );\n\n this.logCreateManifestInfo(\n `Created manifest with ${stepCount} ${pluralize('step', 'steps', stepCount)}, ${workflowCount} ${pluralize('workflow', 'workflows', workflowCount)}, and ${classCount} ${pluralize('class', 'classes', classCount)}`,\n `${Date.now() - buildStart}ms`\n );\n\n return manifestJson;\n } catch (error) {\n console.warn(\n 'Failed to create manifest:',\n error instanceof Error ? error.message : String(error)\n );\n return undefined;\n }\n }\n\n private convertStepsManifest(\n steps: WorkflowManifest['steps']\n ): Record<string, Record<string, { stepId: string }>> {\n const result: Record<string, Record<string, { stepId: string }>> = {};\n if (!steps) return result;\n\n for (const [filePath, entries] of Object.entries(steps)) {\n result[filePath] = {};\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = { stepId: data.stepId };\n }\n }\n return result;\n }\n\n private convertWorkflowsManifest(\n workflows: WorkflowManifest['workflows'],\n graphs: Record<\n string,\n Record<string, { graph: { nodes: any[]; edges: any[] } }>\n >\n ): Record<\n string,\n Record<\n string,\n { workflowId: string; graph: { nodes: any[]; edges: any[] } }\n >\n > {\n const result: Record<\n string,\n Record<\n string,\n { workflowId: string; graph: { nodes: any[]; edges: any[] } }\n >\n > = {};\n if (!workflows) return result;\n\n // Build a normalized lookup for graphs since the graph extractor uses\n // paths from workflowId (e.g. \"./workflows/hello-agent\") while the\n // manifest uses source file paths (e.g. \"workflows/hello-agent.ts\").\n // Normalize by stripping leading \"./\" and file extensions.\n const normalizedGraphs = new Map<\n string,\n Record<string, { graph: { nodes: any[]; edges: any[] } }>\n >();\n for (const [graphPath, graphEntries] of Object.entries(graphs)) {\n const normalized = graphPath\n .replace(/^\\.\\//, '')\n .replace(/\\.[^/.]+$/, '');\n normalizedGraphs.set(normalized, graphEntries);\n }\n\n for (const [filePath, entries] of Object.entries(workflows)) {\n result[filePath] = {};\n // Normalize the manifest file path for lookup\n const normalizedFilePath = filePath\n .replace(/^\\.\\//, '')\n .replace(/\\.[^/.]+$/, '');\n\n const graphEntries =\n graphs[filePath] || normalizedGraphs.get(normalizedFilePath);\n\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = {\n workflowId: data.workflowId,\n graph: graphEntries?.[name]?.graph || { nodes: [], edges: [] },\n };\n }\n }\n return result;\n }\n\n private convertClassesManifest(\n classes: WorkflowManifest['classes']\n ): Record<string, Record<string, { classId: string }>> {\n const result: Record<string, Record<string, { classId: string }>> = {};\n if (!classes) return result;\n\n for (const [filePath, entries] of Object.entries(classes)) {\n result[filePath] = {};\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = { classId: data.classId };\n }\n }\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-builder.js","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,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AM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;oBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,KAAK,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;iBAC/D,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,sBAAsB,CAC5B,OAAoC;QAEpC,MAAM,MAAM,GAAwD,EAAE,CAAC;QACvE,IAAI,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC;QAE5B,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACtB,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;YACrD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { mkdir, readFile, realpath, rename, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join, relative, resolve } from 'node:path';\nimport { promisify } from 'node:util';\nimport { pluralize } from '@workflow/utils';\nimport chalk from 'chalk';\nimport enhancedResolveOriginal from 'enhanced-resolve';\nimport * as esbuild from 'esbuild';\nimport { findUp } from 'find-up';\nimport { glob } from 'tinyglobby';\nimport {\n applySwcTransform,\n type WorkflowManifest,\n} from './apply-swc-transform.js';\nimport { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';\nimport { getEsbuildTsconfigOptions } from './esbuild-tsconfig.js';\nimport { getImportPath } from './module-specifier.js';\nimport { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';\nimport { createPseudoPackagePlugin } from './pseudo-package-esbuild-plugin.js';\nimport { createSwcPlugin } from './swc-esbuild-plugin.js';\nimport type { WorkflowConfig } from './types.js';\nimport { extractWorkflowGraphs } from './workflows-extractor.js';\n\nconst enhancedResolve = promisify(enhancedResolveOriginal);\n\nconst EMIT_SOURCEMAPS_FOR_DEBUGGING =\n process.env.WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING === '1';\n\n/**\n * Normalize an array of file paths by appending the `realpath()` of each entry\n * (to handle symlinks, e.g. pnpm/workspace layouts) and deduplicating.\n */\nasync function withRealpaths(entries: string[]): Promise<string[]> {\n return Array.from(\n new Set(\n (\n await Promise.all(\n entries.map(async (entry) => {\n const resolved = await realpath(entry).catch(() => undefined);\n return resolved ? [entry, resolved] : [entry];\n })\n )\n ).flat()\n )\n );\n}\n\nexport interface DiscoveredEntries {\n discoveredSteps: Set<string>;\n discoveredWorkflows: Set<string>;\n discoveredSerdeFiles: Set<string>;\n}\n\n/**\n * Base class for workflow builders. Provides common build logic for transforming\n * workflow source files into deployable bundles using esbuild and SWC.\n *\n * Subclasses must implement the build() method to define builder-specific logic.\n */\nexport abstract class BaseBuilder {\n protected config: WorkflowConfig;\n\n constructor(config: WorkflowConfig) {\n this.config = config;\n }\n\n protected get transformProjectRoot(): string {\n return this.config.projectRoot || this.config.workingDir;\n }\n\n /**\n * Whether informational BaseBuilder logs should be printed.\n * Subclasses can override this to silence progress logs while keeping warnings/errors.\n */\n protected get shouldLogBaseBuilderInfo(): boolean {\n return true;\n }\n\n protected logBaseBuilderInfo(...args: unknown[]): void {\n if (this.shouldLogBaseBuilderInfo) {\n console.log(...args);\n }\n }\n\n private logCreateWorkflowsBundleInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateWorkflowsBundleLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n private logCreateWebhookBundleInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateWebhookBundleLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n private logCreateManifestInfo(...args: unknown[]): void {\n if (!this.config.suppressCreateManifestLogs) {\n this.logBaseBuilderInfo(...args);\n }\n }\n\n /**\n * When outputting CJS, esbuild replaces `import.meta` with an empty object,\n * making `import.meta.url` (and `import.meta.resolve`) undefined. This method\n * returns banner code and `define` entries that polyfill them using CJS\n * equivalents (`__filename`, `require.resolve`) so user code (e.g. Prisma)\n * that relies on `import.meta.url` works correctly in bundled CJS output.\n */\n private getCjsImportMetaPolyfill(format: string): {\n banner: string;\n define: Record<string, string>;\n } {\n if (format !== 'cjs') return { banner: '', define: {} };\n return {\n banner:\n 'var __import_meta_url = typeof __filename !== \"undefined\" ? require(\"url\").pathToFileURL(__filename).href : undefined;\\n' +\n 'var __import_meta_resolve = typeof require !== \"undefined\" && typeof __filename !== \"undefined\" ' +\n '? (s) => require(\"url\").pathToFileURL(require.resolve(s)).href : undefined;\\n',\n define: {\n 'import.meta.url': '__import_meta_url',\n 'import.meta.resolve': '__import_meta_resolve',\n },\n };\n }\n\n /**\n * When outputting fully-bundled ESM, CJS dependencies that call require()\n * for Node.js builtins (e.g. debug → require('tty')) break because esbuild's\n * CJS-to-ESM __require shim doesn't have access to a real require function.\n * This banner provides one via createRequire so bundled CJS code works in ESM.\n */\n private getEsmRequireBanner(format: string): string {\n if (format !== 'esm') return '';\n return 'import { createRequire as __createRequire } from \"node:module\";\\nvar require = __createRequire(import.meta.url);\\n';\n }\n\n /**\n * Performs the complete build process for workflows.\n * Subclasses must implement this to define their specific build steps.\n */\n abstract build(): Promise<void>;\n\n /**\n * Finds tsconfig.json/jsconfig.json for the project.\n * Used by esbuild to properly resolve module imports during bundling.\n */\n protected async findTsConfigPath(): Promise<string | undefined> {\n const cwd = this.config.workingDir || process.cwd();\n return findUp(['tsconfig.json', 'jsconfig.json'], { cwd });\n }\n\n /**\n * Discovers all source files in the configured directories.\n * Searches for TypeScript and JavaScript files while excluding common build\n * and dependency directories.\n */\n protected async getInputFiles(): Promise<string[]> {\n const ignore = [\n '**/node_modules/**',\n '**/.git/**',\n '**/.next/**',\n '**/.nuxt/**',\n '**/.output/**',\n '**/.vercel/**',\n '**/.workflow-data/**',\n '**/.workflow-vitest/**',\n '**/.well-known/workflow/**',\n '**/.svelte-kit/**',\n '**/.turbo/**',\n '**/.cache/**',\n '**/.yarn/**',\n '**/.pnpm-store/**',\n ];\n\n // Use relative patterns with `cwd` per directory so that `dot: true`\n // applies consistently to both the search pattern *and* the ignore\n // patterns. When absolute patterns are used with tinyglobby, the `**`\n // in ignore patterns does not match dot-prefixed path segments.\n const results = await Promise.all(\n this.config.dirs.map((dir) => {\n const cwd = resolve(this.config.workingDir, dir);\n return glob(['**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'], {\n cwd,\n ignore,\n absolute: true,\n dot: true,\n });\n })\n );\n\n return results.flat();\n }\n\n /**\n * Caches discovered workflow entries by input array reference.\n * Uses WeakMap to allow garbage collection when input arrays are no longer referenced.\n * This cache is invalidated automatically when the inputs array reference changes\n * (e.g., when files are added/removed during watch mode).\n */\n private discoveredEntries: WeakMap<string[], DiscoveredEntries> =\n new WeakMap();\n\n protected async discoverEntries(\n inputs: string[],\n outdir: string,\n tsconfigPath?: string\n ): Promise<DiscoveredEntries> {\n const previousResult = this.discoveredEntries.get(inputs);\n\n if (previousResult) {\n return previousResult;\n }\n const state: DiscoveredEntries = {\n discoveredSteps: new Set(),\n discoveredWorkflows: new Set(),\n discoveredSerdeFiles: new Set(),\n };\n\n const discoverStart = Date.now();\n\n // Resolve the SDK runtime entry point so that the discovery pass\n // traces through it and discovers serde classes (like `Run`) that\n // live inside SDK packages. Without this, files like `run.js` are\n // only discovered when user code happens to import them.\n // This is resolved here (rather than in callers) so that the original\n // `inputs` array reference is preserved for WeakMap caching — callers\n // like createWorkflowsBundle and createStepsBundle can share the same\n // cache entry when they pass the same inputFiles array.\n const resolvedWorkflowRuntime = await enhancedResolve(\n outdir,\n 'workflow/runtime'\n ).catch(() => undefined);\n const entryPoints = resolvedWorkflowRuntime\n ? [...inputs, resolvedWorkflowRuntime]\n : inputs;\n\n const effectiveTsconfigPath =\n tsconfigPath ?? (await this.findTsConfigPath());\n const esbuildTsconfigOptions = await getEsbuildTsconfigOptions(\n effectiveTsconfigPath\n );\n try {\n await esbuild.build({\n treeShaking: true,\n entryPoints,\n plugins: [\n createDiscoverEntriesPlugin(state, this.transformProjectRoot),\n ],\n platform: 'node',\n write: false,\n outdir,\n bundle: true,\n sourcemap: false,\n absWorkingDir: this.config.workingDir,\n logLevel: 'silent',\n ...esbuildTsconfigOptions,\n // External packages that should not be bundled during discovery\n external: this.config.externalPackages || [],\n });\n } catch (_) {}\n\n this.logBaseBuilderInfo(\n `Discovering workflow directives`,\n `${Date.now() - discoverStart}ms`\n );\n\n this.discoveredEntries.set(inputs, state);\n return state;\n }\n\n /**\n * Writes debug information to a JSON file for troubleshooting build issues.\n * Uses atomic write (temp file + rename) to prevent race conditions when\n * multiple builds run concurrently.\n */\n private async writeDebugFile(\n outfile: string,\n debugData: object,\n merge?: boolean\n ): Promise<void> {\n const prefix = this.config.debugFilePrefix || '';\n const targetPath = `${dirname(outfile)}/${prefix}${basename(outfile)}.debug.json`;\n let existing = {};\n\n try {\n if (merge) {\n try {\n const content = await readFile(targetPath, 'utf8');\n existing = JSON.parse(content);\n } catch (e) {\n // File doesn't exist yet or is corrupted - start fresh.\n // Don't log error for ENOENT (file not found) as that's expected on first run.\n if ((e as NodeJS.ErrnoException).code !== 'ENOENT') {\n console.warn('Error reading debug file, starting fresh:', e);\n }\n }\n }\n\n const mergedData = JSON.stringify(\n {\n ...existing,\n ...debugData,\n },\n null,\n 2\n );\n\n // Write atomically: write to temp file, then rename.\n // rename() is atomic on POSIX systems and provides best-effort atomicity on Windows.\n // Prevents race conditions where concurrent builds read partially-written files.\n const tempPath = `${targetPath}.${randomUUID()}.tmp`;\n await writeFile(tempPath, mergedData);\n await rename(tempPath, targetPath);\n } catch (error: unknown) {\n console.warn('Failed to write debug file:', error);\n }\n }\n\n /**\n * Logs and optionally throws on esbuild errors and warnings.\n * @param throwOnError - If true, throws an error when esbuild errors are present\n */\n private logEsbuildMessages(\n result: { errors?: any[]; warnings?: any[] },\n phase: string,\n throwOnError = true,\n options?: {\n suppressWarnings?: boolean;\n }\n ): void {\n if (result.errors && result.errors.length > 0) {\n console.error(`❌ esbuild errors in ${phase}:`);\n const errorMessages: string[] = [];\n for (const error of result.errors) {\n console.error(` ${error.text}`);\n errorMessages.push(error.text);\n if (error.location) {\n const location = ` at ${error.location.file}:${error.location.line}:${error.location.column}`;\n console.error(location);\n errorMessages.push(location);\n }\n }\n\n if (throwOnError) {\n throw new Error(\n `Build failed during ${phase}:\\n${errorMessages.join('\\n')}`\n );\n }\n }\n\n if (\n !options?.suppressWarnings &&\n result.warnings &&\n result.warnings.length > 0\n ) {\n console.warn(`! esbuild warnings in ${phase}:`);\n for (const warning of result.warnings) {\n console.warn(` ${warning.text}`);\n if (warning.location) {\n console.warn(\n ` at ${warning.location.file}:${warning.location.line}:${warning.location.column}`\n );\n }\n }\n }\n }\n\n /**\n * Converts an absolute file path to a normalized relative path for the manifest.\n */\n private getRelativeFilepath(absolutePath: string): string {\n const normalizedFile = absolutePath.replace(/\\\\/g, '/');\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Handle files discovered outside the working directory\n if (relativePath.startsWith('../')) {\n relativePath = relativePath\n .split('/')\n .filter((part) => part !== '..')\n .join('/');\n }\n return relativePath;\n }\n\n /**\n * Creates a bundle for workflow step functions.\n * Steps have full Node.js runtime access and handle side effects, API calls, etc.\n *\n * @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code\n * @returns Build context (for watch mode) and the collected workflow manifest\n */\n protected async createStepsBundle({\n inputFiles,\n format = 'esm',\n outfile,\n externalizeNonSteps,\n rewriteTsExtensions,\n tsconfigPath,\n discoveredEntries,\n }: {\n tsconfigPath?: string;\n inputFiles: string[];\n outfile: string;\n format?: 'cjs' | 'esm';\n externalizeNonSteps?: boolean;\n rewriteTsExtensions?: boolean;\n discoveredEntries?: DiscoveredEntries;\n }): Promise<{\n context: esbuild.BuildContext | undefined;\n manifest: WorkflowManifest;\n }> {\n const stepsBundleStart = Date.now();\n const workflowManifest: WorkflowManifest = {};\n const builtInSteps = 'workflow/internal/builtins';\n\n const resolvedBuiltInSteps = await enhancedResolve(\n dirname(outfile),\n 'workflow/internal/builtins'\n ).catch((err) => {\n throw new Error(\n [\n chalk.red('Failed to resolve built-in steps sources.'),\n `${chalk.yellow.bold('hint:')} run \\`${chalk.cyan.italic('npm install workflow')}\\` to resolve this issue.`,\n '',\n `Caused by: ${chalk.red(String(err))}`,\n ].join('\\n')\n );\n });\n\n // Discovery of workflow/step/serde entries. The SDK runtime entry point\n // (workflow/runtime) is resolved inside discoverEntries() itself so that\n // callers can pass the original inputFiles reference and benefit from\n // WeakMap caching across createWorkflowsBundle / createStepsBundle calls.\n const discovered =\n discoveredEntries ??\n (await this.discoverEntries(inputFiles, dirname(outfile), tsconfigPath));\n const stepFiles = [...discovered.discoveredSteps].sort();\n const workflowFiles = [...discovered.discoveredWorkflows].sort();\n const serdeFiles = [...discovered.discoveredSerdeFiles].sort();\n\n // Include serde files that aren't already step files for cross-context class registration.\n // Classes need to be registered in the step bundle so they can be deserialized\n // when receiving data from workflows and serialized when returning data to workflows.\n const stepFilesSet = new Set(stepFiles);\n const serdeOnlyFiles = serdeFiles.filter((f) => !stepFilesSet.has(f));\n\n // log the step files for debugging\n await this.writeDebugFile(outfile, {\n stepFiles,\n workflowFiles,\n serdeOnlyFiles,\n });\n\n // Helper to create import statement from file path\n // For workspace/node_modules packages, uses the package name so esbuild\n // will resolve through package.json exports with the appropriate conditions\n const createImport = (file: string) => {\n const { importPath, isPackage } = getImportPath(\n file,\n this.config.workingDir\n );\n\n if (isPackage) {\n // Use package name - esbuild will resolve via package.json exports\n return `import '${importPath}';`;\n }\n\n // Local app file - use relative path\n // Normalize both paths to forward slashes before calling relative()\n // This is critical on Windows where relative() can produce unexpected results with mixed path formats\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n const normalizedFile = file.replace(/\\\\/g, '/');\n // Calculate relative path from working directory to the file\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Ensure relative paths start with ./ so esbuild resolves them correctly.\n // Paths like \".output/...\" are not valid relative specifiers and must\n // become \"./.output/...\".\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n };\n\n // Create a virtual entry that imports all files. All step definitions\n // will get registered thanks to the swc transform.\n const stepImports = stepFiles.map(createImport).join('\\n');\n\n // Include serde-only files for class registration side effects\n const serdeImports = serdeOnlyFiles.map(createImport).join('\\n');\n\n const entryContent = `\n // Built in steps\n import '${builtInSteps}';\n // User steps\n ${stepImports}\n // Serde files for cross-context class registration\n ${serdeImports}\n // API entrypoint\n export { stepEntrypoint as POST } from 'workflow/runtime';`;\n\n // Bundle with esbuild and our custom SWC plugin\n const entriesToBundle = externalizeNonSteps\n ? [\n ...stepFiles,\n ...serdeFiles,\n ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),\n ]\n : undefined;\n const normalizedEntriesToBundle = entriesToBundle\n ? await withRealpaths(entriesToBundle)\n : undefined;\n const normalizedSideEffectEntries = await withRealpaths([\n ...stepFiles,\n ...serdeOnlyFiles,\n ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),\n ]);\n const esbuildTsconfigOptions =\n await getEsbuildTsconfigOptions(tsconfigPath);\n const { banner: importMetaBanner, define: importMetaDefine } =\n this.getCjsImportMetaPolyfill(format);\n const esmRequireBanner = this.getEsmRequireBanner(format);\n\n const esbuildCtx = await esbuild.context({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${importMetaBanner}${esmRequireBanner}`,\n },\n stdin: {\n contents: entryContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n format,\n platform: 'node',\n conditions: ['node'],\n target: 'es2022',\n write: true,\n treeShaking: true,\n keepNames: true,\n minify: false,\n jsx: 'preserve',\n logLevel: 'error',\n // Use tsconfig for path alias resolution.\n // For symlinked configs this uses tsconfigRaw to preserve cwd-relative aliases.\n ...esbuildTsconfigOptions,\n define: importMetaDefine,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n // Inline source maps for better stack traces in step execution.\n // Steps execute in Node.js context and inline sourcemaps ensure we get\n // meaningful stack traces with proper file names and line numbers when errors\n // occur in deeply nested function calls across multiple files.\n sourcemap: 'inline',\n plugins: [\n // Handle pseudo-packages like 'server-only' and 'client-only' by providing\n // empty modules. Must run first to intercept these before other resolution.\n createPseudoPackagePlugin(),\n createSwcPlugin({\n mode: 'step',\n entriesToBundle: normalizedEntriesToBundle,\n outdir: outfile ? dirname(outfile) : undefined,\n projectRoot: this.transformProjectRoot,\n workflowManifest,\n rewriteTsExtensions,\n sideEffectEntries: normalizedSideEffectEntries,\n }),\n ],\n // Plugin should catch most things, but this lets users hard override\n // if the plugin misses anything that should be externalized\n external: ['bun', 'bun:*', ...(this.config.externalPackages || [])],\n });\n\n const stepsResult = await esbuildCtx.rebuild();\n\n this.logEsbuildMessages(stepsResult, 'steps bundle creation');\n this.logBaseBuilderInfo(\n 'Created steps bundle',\n `${Date.now() - stepsBundleStart}ms`\n );\n\n // Handle workflow-only files that may have been tree-shaken from the bundle.\n // These files have no steps, so esbuild removes them, but we still need their\n // workflow metadata for the manifest. Transform them separately.\n const workflowOnlyFiles = workflowFiles.filter(\n (f) => !stepFiles.includes(f)\n );\n await Promise.all(\n workflowOnlyFiles.map(async (workflowFile) => {\n try {\n const source = await readFile(workflowFile, 'utf8');\n const relativeFilepath = this.getRelativeFilepath(workflowFile);\n const { workflowManifest: fileManifest } = await applySwcTransform(\n relativeFilepath,\n source,\n 'workflow',\n workflowFile,\n this.transformProjectRoot\n );\n if (fileManifest.workflows) {\n workflowManifest.workflows = Object.assign(\n workflowManifest.workflows || {},\n fileManifest.workflows\n );\n }\n if (fileManifest.classes) {\n workflowManifest.classes = Object.assign(\n workflowManifest.classes || {},\n fileManifest.classes\n );\n }\n } catch (error) {\n // Log warning but continue - don't fail build for workflow-only file issues\n console.warn(\n `Warning: Failed to extract workflow metadata from ${workflowFile}:`,\n error instanceof Error ? error.message : String(error)\n );\n }\n })\n );\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n\n if (this.config.watch) {\n return { context: esbuildCtx, manifest: workflowManifest };\n }\n await esbuildCtx.dispose();\n return { context: undefined, manifest: workflowManifest };\n }\n\n /**\n * Creates a bundle for workflow orchestration functions.\n * Workflows run in a sandboxed VM and coordinate step execution.\n *\n * @param bundleFinalOutput - If false, skips the final bundling step (used by Next.js)\n */\n protected async createWorkflowsBundle({\n inputFiles,\n format = 'esm',\n outfile,\n bundleFinalOutput = true,\n keepInterimBundleContext = this.config.watch,\n tsconfigPath,\n discoveredEntries,\n }: {\n tsconfigPath?: string;\n inputFiles: string[];\n outfile: string;\n format?: 'cjs' | 'esm';\n bundleFinalOutput?: boolean;\n keepInterimBundleContext?: boolean;\n discoveredEntries?: DiscoveredEntries;\n }): Promise<{\n manifest: WorkflowManifest;\n interimBundleCtx?: esbuild.BuildContext;\n bundleFinal?: (interimBundleResult: string) => Promise<void>;\n }> {\n const discovered =\n discoveredEntries ??\n (await this.discoverEntries(inputFiles, dirname(outfile), tsconfigPath));\n const workflowFiles = [...discovered.discoveredWorkflows].sort();\n const serdeFiles = [...discovered.discoveredSerdeFiles].sort();\n\n // Include serde files that aren't already workflow files for cross-context class registration.\n // Classes need to be registered in the workflow bundle so they can be deserialized\n // when receiving data from steps or when serializing data to send to steps.\n const workflowFilesSet = new Set(workflowFiles);\n const serdeOnlyFiles = serdeFiles.filter((f) => !workflowFilesSet.has(f));\n\n // log the workflow files for debugging\n await this.writeDebugFile(outfile, { workflowFiles, serdeOnlyFiles });\n\n // Helper to create import statement from file path\n // For packages, uses the package name so esbuild will resolve through\n // package.json exports with conditions: ['workflow']\n const createImport = (file: string) => {\n const { importPath, isPackage } = getImportPath(\n file,\n this.config.workingDir\n );\n\n if (isPackage) {\n // Use package name - esbuild will resolve via package.json exports\n // and apply the 'workflow' condition\n return `import '${importPath}';`;\n }\n\n // Local app file - use relative path\n // Normalize both paths to forward slashes before calling relative()\n // This is critical on Windows where relative() can produce unexpected results with mixed path formats\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n const normalizedFile = file.replace(/\\\\/g, '/');\n // Calculate relative path from working directory to the file\n let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(\n /\\\\/g,\n '/'\n );\n // Ensure relative paths start with ./ so esbuild resolves them correctly.\n // Paths like \".output/...\" are not valid relative specifiers and must\n // become \"./.output/...\".\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n };\n\n // Create a virtual entry that imports all workflow files\n // The SWC plugin in workflow mode emits `globalThis.__private_workflows.set(workflowId, fn)`\n // calls directly, so we just need to import the files (Map is initialized via banner)\n const workflowImports = workflowFiles.map(createImport).join('\\n');\n\n // Include serde-only files for class registration side effects\n const serdeImports = serdeOnlyFiles.map(createImport).join('\\n');\n\n const imports = serdeImports\n ? `${workflowImports}\\n// Serde files for cross-context class registration\\n${serdeImports}`\n : workflowImports;\n\n const bundleStartTime = Date.now();\n const workflowManifest: WorkflowManifest = {};\n const esbuildTsconfigOptions =\n await getEsbuildTsconfigOptions(tsconfigPath);\n const normalizedWorkflowSideEffectEntries = await withRealpaths([\n ...workflowFiles,\n ...serdeOnlyFiles,\n ]);\n\n // Bundle with esbuild and our custom SWC plugin in workflow mode.\n // this bundle will be run inside a vm isolate\n const interimBundleCtx = await esbuild.context({\n stdin: {\n contents: imports,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n bundle: true,\n absWorkingDir: this.config.workingDir,\n format: 'cjs', // Runs inside the VM which expects cjs\n platform: 'neutral', // The platform is neither node nor browser\n mainFields: ['module', 'main'], // To support npm style imports\n conditions: ['workflow'], // Allow packages to export 'workflow' compliant versions\n target: 'es2022',\n write: false,\n treeShaking: true,\n keepNames: true,\n minify: false,\n // Initialize the workflow registry at the very top of the bundle\n // This must be in banner (not the virtual entry) because esbuild's bundling\n // can reorder code, and the .set() calls need the Map to exist first\n banner: {\n js: 'globalThis.__private_workflows = new Map();',\n },\n // Inline source maps for better stack traces in workflow VM execution.\n // This intermediate bundle is executed via runInContext() in a VM, so we need\n // inline source maps to get meaningful stack traces instead of \"evalmachine.<anonymous>\".\n sourcemap: 'inline',\n // Use tsconfig for path alias resolution.\n // For symlinked configs this uses tsconfigRaw to preserve cwd-relative aliases.\n ...esbuildTsconfigOptions,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n plugins: [\n // Handle pseudo-packages like 'server-only' and 'client-only' by providing\n // empty modules. Must run first to intercept these before other resolution.\n createPseudoPackagePlugin(),\n createSwcPlugin({\n mode: 'workflow',\n projectRoot: this.transformProjectRoot,\n workflowManifest,\n sideEffectEntries: normalizedWorkflowSideEffectEntries,\n }),\n // This plugin must run after the swc plugin to ensure dead code elimination\n // happens first, preventing false positives on Node.js imports in unused code paths\n createNodeModuleErrorPlugin(),\n ],\n // NOTE: We intentionally do NOT use the external option here for workflow bundles.\n // When packages are marked external with format: 'cjs', esbuild generates require() calls.\n // However, the workflow VM (vm.runInContext) does not have require() defined - it only\n // provides module.exports and exports. External packages would fail at runtime with:\n // ReferenceError: require is not defined\n // Instead, we bundle everything and rely on:\n // - createPseudoPackagePlugin() to handle server-only/client-only with empty modules\n // - createNodeModuleErrorPlugin() to catch Node.js builtin imports at build time\n });\n let shouldDisposeInterimBundleCtx = !keepInterimBundleContext;\n try {\n const interimBundle = await interimBundleCtx.rebuild();\n\n this.logEsbuildMessages(\n interimBundle,\n 'intermediate workflow bundle',\n true,\n {\n suppressWarnings: this.config.suppressCreateWorkflowsBundleWarnings,\n }\n );\n this.logCreateWorkflowsBundleInfo(\n 'Created intermediate workflow bundle',\n `${Date.now() - bundleStartTime}ms`\n );\n\n if (this.config.workflowManifestPath) {\n const resolvedPath = resolve(\n process.cwd(),\n this.config.workflowManifestPath\n );\n let prefix = '';\n\n if (resolvedPath.endsWith('.cjs')) {\n prefix = 'module.exports = ';\n } else if (\n resolvedPath.endsWith('.js') ||\n resolvedPath.endsWith('.mjs')\n ) {\n prefix = 'export default ';\n }\n\n await mkdir(dirname(resolvedPath), { recursive: true });\n await writeFile(\n resolvedPath,\n prefix + JSON.stringify(workflowManifest, null, 2)\n );\n }\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n\n if (\n !interimBundle.outputFiles ||\n interimBundle.outputFiles.length === 0\n ) {\n throw new Error('No output files generated from esbuild');\n }\n\n // Serde compliance warnings: check if workflow bundle has Node.js imports\n // alongside serde-registered classes (these will fail at runtime in the sandbox)\n if (\n workflowManifest.classes &&\n Object.keys(workflowManifest.classes).length > 0\n ) {\n const { analyzeSerdeCompliance } = await import('./serde-checker.js');\n const bundleText = interimBundle.outputFiles[0].text;\n const serdeResult = analyzeSerdeCompliance({\n sourceCode: '',\n workflowCode: bundleText,\n manifest: workflowManifest,\n });\n // De-dupe warnings: group identical issues across classes\n const issuesToClasses = new Map<string, Set<string>>();\n for (const cls of serdeResult.classes) {\n if (!cls.compliant) {\n for (const issue of cls.issues) {\n let affectedClasses = issuesToClasses.get(issue);\n if (!affectedClasses) {\n affectedClasses = new Set<string>();\n issuesToClasses.set(issue, affectedClasses);\n }\n affectedClasses.add(cls.className);\n }\n }\n }\n for (const [issue, affectedClasses] of issuesToClasses) {\n const classNames = [...affectedClasses];\n const classLabel =\n classNames.length === 1\n ? `class \"${classNames[0]}\"`\n : `classes ${classNames.map((name) => `\"${name}\"`).join(', ')}`;\n console.warn(\n chalk.yellow(`⚠ Serde warning for ${classLabel}: `) + issue\n );\n }\n }\n\n const bundleFinal = async (interimBundle: string) => {\n const workflowBundleCode = interimBundle;\n\n const workflowFunctionCode = `// biome-ignore-all lint: generated file\n/* eslint-disable */\nimport { workflowEntrypoint } from 'workflow/runtime';\n\nconst workflowCode = \\`${workflowBundleCode.replace(/[\\\\`$]/g, '\\\\$&')}\\`;\n\nexport const POST = workflowEntrypoint(workflowCode);`;\n\n // we skip the final bundling step for Next.js so it can bundle itself\n if (!bundleFinalOutput) {\n if (!outfile) {\n throw new Error(`Invariant: missing outfile for workflow bundle`);\n }\n // Ensure the output directory exists\n const outputDir = dirname(outfile);\n await mkdir(outputDir, { recursive: true });\n\n // Atomic write: write to temp file then rename to prevent\n // file watchers from reading partial file during write\n const tempPath = `${outfile}.${randomUUID()}.tmp`;\n await writeFile(tempPath, workflowFunctionCode);\n await rename(tempPath, outfile);\n return;\n }\n\n const bundleStartTime = Date.now();\n\n // Now bundle this so we can resolve the @workflow/core dependency\n // we could remove this if we do nft tracing or similar instead\n const finalEsmRequireBanner = this.getEsmRequireBanner(format);\n const finalWorkflowResult = await esbuild.build({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${finalEsmRequireBanner}`,\n },\n stdin: {\n contents: workflowFunctionCode,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile,\n // Source maps for the final workflow bundle wrapper (not important since this code\n // doesn't run in the VM - only the intermediate bundle sourcemap is relevant)\n sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n format,\n platform: 'node',\n target: 'es2022',\n write: true,\n keepNames: true,\n minify: false,\n external: ['@aws-sdk/credential-provider-web-identity'],\n });\n\n this.logEsbuildMessages(\n finalWorkflowResult,\n 'final workflow bundle',\n true,\n {\n suppressWarnings: this.config.suppressCreateWorkflowsBundleWarnings,\n }\n );\n this.logCreateWorkflowsBundleInfo(\n 'Created final workflow bundle',\n `${Date.now() - bundleStartTime}ms`\n );\n };\n await bundleFinal(interimBundle.outputFiles[0].text);\n\n if (keepInterimBundleContext) {\n shouldDisposeInterimBundleCtx = false;\n return {\n manifest: workflowManifest,\n interimBundleCtx,\n bundleFinal,\n };\n }\n return { manifest: workflowManifest };\n } catch (error) {\n shouldDisposeInterimBundleCtx = true;\n throw error;\n } finally {\n if (shouldDisposeInterimBundleCtx) {\n try {\n await interimBundleCtx.dispose();\n } catch (disposeError) {\n console.warn(\n 'Warning: Failed to dispose workflow bundle context',\n disposeError\n );\n }\n }\n }\n }\n\n /**\n * Creates a client library bundle for workflow execution.\n * The client library allows importing and calling workflows from application code.\n * Only generated if clientBundlePath is specified in config.\n */\n protected async createClientLibrary(): Promise<void> {\n if (!this.config.clientBundlePath) {\n // Silently exit since no client bundle was requested\n return;\n }\n\n this.logBaseBuilderInfo(\n 'Generating a client library at',\n this.config.clientBundlePath\n );\n this.logBaseBuilderInfo(\n 'NOTE: The recommended way to use workflow with a framework like NextJS is using the loader/plugin with webpack/turbobpack/rollup'\n );\n\n // Ensure we have the directory for the client bundle\n const outputDir = dirname(this.config.clientBundlePath);\n await mkdir(outputDir, { recursive: true });\n\n const inputFiles = await this.getInputFiles();\n\n // Discover serde files from the input files' dependency tree for cross-context class registration.\n // Classes need to be registered in the client bundle so they can be serialized\n // when passing data to workflows via start() and deserialized when receiving workflow results.\n const { discoveredSerdeFiles } = await this.discoverEntries(\n inputFiles,\n outputDir\n );\n\n // Identify serde files that aren't in the inputFiles (deduplicated)\n const inputFilesNormalized = new Set(\n inputFiles.map((f) => f.replace(/\\\\/g, '/'))\n );\n const serdeOnlyFiles = [...discoveredSerdeFiles].filter(\n (f) => !inputFilesNormalized.has(f)\n );\n\n // Re-exports for input files (user's workflow/step definitions).\n // These must use valid relative specifiers because some frameworks pass\n // generated files like \".output/server/index.mjs\" as input files.\n const reexports = inputFiles\n .map((file) => {\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, file).replace(\n /\\\\/g,\n '/'\n );\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `export * from '${relativePath}';`;\n })\n .join('\\n');\n\n // Side-effect imports for serde files not in inputFiles (for class registration)\n const serdeImports = serdeOnlyFiles\n .map((file) => {\n const normalizedWorkingDir = this.config.workingDir.replace(/\\\\/g, '/');\n let relativePath = relative(normalizedWorkingDir, file).replace(\n /\\\\/g,\n '/'\n );\n if (!relativePath.startsWith('./') && !relativePath.startsWith('../')) {\n relativePath = `./${relativePath}`;\n }\n return `import '${relativePath}';`;\n })\n .join('\\n');\n\n // Combine: serde imports (for registration side effects) + re-exports\n const entryContent = serdeImports\n ? `// Serde files for cross-context class registration\\n${serdeImports}\\n${reexports}`\n : reexports;\n\n // Bundle with esbuild and our custom SWC plugin\n const normalizedClientSideEffectEntries = await withRealpaths([\n ...inputFiles,\n ...serdeOnlyFiles,\n ]);\n const clientResult = await esbuild.build({\n banner: {\n js: '// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n',\n },\n stdin: {\n contents: entryContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'virtual-entry.js',\n loader: 'js',\n },\n outfile: this.config.clientBundlePath,\n bundle: true,\n format: 'esm',\n platform: 'node',\n jsx: 'preserve',\n target: 'es2022',\n write: true,\n treeShaking: true,\n external: ['@workflow/core'],\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n plugins: [\n createSwcPlugin({\n mode: 'step',\n projectRoot: this.transformProjectRoot,\n sideEffectEntries: normalizedClientSideEffectEntries,\n }),\n ],\n });\n\n this.logEsbuildMessages(clientResult, 'client library bundle');\n\n // Create .gitignore in .swc directory\n await this.createSwcGitignore();\n }\n\n /**\n * Creates a webhook handler bundle for resuming workflows via HTTP callbacks.\n *\n * @param bundle - If true, bundles dependencies (needed for Build Output API)\n */\n protected async createWebhookBundle({\n outfile,\n bundle = false,\n }: {\n outfile: string;\n bundle?: boolean;\n }): Promise<void> {\n this.logCreateWebhookBundleInfo('Creating webhook route');\n await mkdir(dirname(outfile), { recursive: true });\n\n // Create a static route that calls resumeWebhook\n // This route works for both Next.js and Vercel Build Output API\n const routeContent = `import { resumeWebhook } from 'workflow/api';\n\nasync function handler(request) {\n const url = new URL(request.url);\n // Extract token from pathname: /.well-known/workflow/v1/webhook/{token}\n const pathParts = url.pathname.split('/');\n const token = decodeURIComponent(pathParts[pathParts.length - 1]);\n\n if (!token) {\n return new Response('Missing token', { status: 400 });\n }\n\n try {\n const response = await resumeWebhook(token, request);\n return response;\n } catch (error) {\n // TODO: differentiate between invalid token and other errors\n console.error('Error during resumeWebhook', error);\n return new Response(null, { status: 404 });\n }\n}\n\nexport const GET = handler;\nexport const POST = handler;\nexport const PUT = handler;\nexport const PATCH = handler;\nexport const DELETE = handler;\nexport const HEAD = handler;\nexport const OPTIONS = handler;`;\n\n if (!bundle) {\n // For Next.js, just write the unbundled file\n await writeFile(outfile, routeContent);\n return;\n }\n\n // For Build Output API, bundle with esbuild to resolve imports\n\n const webhookEsmRequireBanner = this.getEsmRequireBanner('esm');\n const webhookBundleStart = Date.now();\n const result = await esbuild.build({\n banner: {\n js: `// biome-ignore-all lint: generated file\\n/* eslint-disable */\\n${webhookEsmRequireBanner}`,\n },\n stdin: {\n contents: routeContent,\n resolveDir: this.config.workingDir,\n sourcefile: 'webhook-route.js',\n loader: 'js',\n },\n outfile,\n absWorkingDir: this.config.workingDir,\n bundle: true,\n jsx: 'preserve',\n format: 'esm',\n platform: 'node',\n conditions: ['import', 'module', 'node', 'default'],\n target: 'es2022',\n write: true,\n treeShaking: true,\n keepNames: true,\n minify: false,\n resolveExtensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n ],\n sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,\n mainFields: ['module', 'main'],\n // Don't externalize anything - bundle everything including workflow packages\n external: [],\n });\n\n this.logEsbuildMessages(result, 'webhook bundle creation');\n this.logCreateWebhookBundleInfo(\n 'Created webhook bundle',\n `${Date.now() - webhookBundleStart}ms`\n );\n }\n\n /**\n * Creates a package.json file with the specified module type.\n */\n protected async createPackageJson(\n dir: string,\n type: 'commonjs' | 'module'\n ): Promise<void> {\n const packageJson = { type };\n await writeFile(\n join(dir, 'package.json'),\n JSON.stringify(packageJson, null, 2)\n );\n }\n\n /**\n * Creates a .vc-config.json file for Vercel Build Output API functions.\n */\n protected async createVcConfig(\n dir: string,\n config: {\n runtime?: string;\n handler?: string;\n launcherType?: string;\n architecture?: string;\n shouldAddHelpers?: boolean;\n shouldAddSourcemapSupport?: boolean;\n maxDuration?: number | 'max';\n experimentalTriggers?: Array<{\n type: 'queue/v2beta';\n topic: string;\n consumer: string;\n maxDeliveries?: number;\n retryAfterSeconds?: number;\n initialDelaySeconds?: number;\n }>;\n }\n ): Promise<void> {\n const vcConfig = {\n runtime: config.runtime ?? 'nodejs22.x',\n handler: config.handler ?? 'index.mjs',\n launcherType: config.launcherType ?? 'Nodejs',\n architecture: config.architecture ?? 'arm64',\n shouldAddHelpers: config.shouldAddHelpers ?? true,\n ...(config.maxDuration !== undefined && {\n maxDuration: config.maxDuration,\n }),\n ...(config.shouldAddSourcemapSupport !== undefined && {\n shouldAddSourcemapSupport: config.shouldAddSourcemapSupport,\n }),\n ...(config.experimentalTriggers && {\n experimentalTriggers: config.experimentalTriggers,\n }),\n };\n\n await writeFile(\n join(dir, '.vc-config.json'),\n JSON.stringify(vcConfig, null, 2)\n );\n }\n\n /**\n * Resolves a path relative to the working directory.\n */\n protected resolvePath(path: string): string {\n return resolve(this.config.workingDir, path);\n }\n\n /**\n * Ensures the directory for a file path exists, creating it if necessary.\n */\n protected async ensureDirectory(filePath: string): Promise<void> {\n await mkdir(dirname(filePath), { recursive: true });\n }\n\n private async createSwcGitignore(): Promise<void> {\n try {\n await writeFile(\n join(this.config.workingDir, '.swc', '.gitignore'),\n '*\\n'\n );\n } catch {\n // We're intentionally silently ignoring this error - creating .gitignore isn't critical\n }\n }\n\n /**\n * Whether the manifest should be exposed as a public HTTP route.\n * Controlled by the `WORKFLOW_PUBLIC_MANIFEST` environment variable.\n */\n protected get shouldExposePublicManifest(): boolean {\n return process.env.WORKFLOW_PUBLIC_MANIFEST === '1';\n }\n\n /**\n * Resolves the workflow manifest diagnostics path, when this builder should\n * emit one.\n */\n protected getDiagnosticsManifestPath(): string | undefined {\n if (this.config.diagnosticsDir) {\n return resolve(\n this.config.workingDir,\n this.config.diagnosticsDir,\n 'workflows-manifest.json'\n );\n }\n\n if (this.config.buildTarget === 'vercel-build-output-api') {\n return this.resolvePath(\n '.vercel/output/diagnostics/workflows-manifest.json'\n );\n }\n }\n\n /**\n * Creates a manifest JSON file containing step/workflow/class metadata\n * and graph data for visualization.\n *\n * @returns The manifest JSON string, or undefined if manifest creation failed.\n */\n protected async createManifest({\n workflowBundlePath,\n manifestDir,\n manifest,\n }: {\n workflowBundlePath: string;\n manifestDir: string;\n manifest: WorkflowManifest;\n }): Promise<string | undefined> {\n const buildStart = Date.now();\n this.logCreateManifestInfo('Creating manifest...');\n\n try {\n const workflowGraphs = await extractWorkflowGraphs(workflowBundlePath);\n\n const steps = this.convertStepsManifest(manifest.steps);\n const workflows = this.convertWorkflowsManifest(\n manifest.workflows,\n workflowGraphs\n );\n const classes = this.convertClassesManifest(manifest.classes);\n\n const output = { version: '1.0.0', steps, workflows, classes };\n const manifestJson = JSON.stringify(output, null, 2);\n\n await mkdir(manifestDir, { recursive: true });\n await writeFile(join(manifestDir, 'manifest.json'), manifestJson);\n\n const diagnosticsManifestPath = this.getDiagnosticsManifestPath();\n if (diagnosticsManifestPath) {\n await this.ensureDirectory(diagnosticsManifestPath);\n await writeFile(diagnosticsManifestPath, manifestJson);\n }\n\n const stepCount = Object.values(steps).reduce(\n (acc, s) => acc + Object.keys(s).length,\n 0\n );\n const workflowCount = Object.values(workflows).reduce(\n (acc, w) => acc + Object.keys(w).length,\n 0\n );\n const classCount = Object.values(classes).reduce(\n (acc, c) => acc + Object.keys(c).length,\n 0\n );\n\n this.logCreateManifestInfo(\n `Created manifest with ${stepCount} ${pluralize('step', 'steps', stepCount)}, ${workflowCount} ${pluralize('workflow', 'workflows', workflowCount)}, and ${classCount} ${pluralize('class', 'classes', classCount)}`,\n `${Date.now() - buildStart}ms`\n );\n\n return manifestJson;\n } catch (error) {\n console.warn(\n 'Failed to create manifest:',\n error instanceof Error ? error.message : String(error)\n );\n return undefined;\n }\n }\n\n private convertStepsManifest(\n steps: WorkflowManifest['steps']\n ): Record<string, Record<string, { stepId: string }>> {\n const result: Record<string, Record<string, { stepId: string }>> = {};\n if (!steps) return result;\n\n for (const [filePath, entries] of Object.entries(steps)) {\n result[filePath] = {};\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = { stepId: data.stepId };\n }\n }\n return result;\n }\n\n private convertWorkflowsManifest(\n workflows: WorkflowManifest['workflows'],\n graphs: Record<\n string,\n Record<string, { graph: { nodes: any[]; edges: any[] } }>\n >\n ): Record<\n string,\n Record<\n string,\n { workflowId: string; graph: { nodes: any[]; edges: any[] } }\n >\n > {\n const result: Record<\n string,\n Record<\n string,\n { workflowId: string; graph: { nodes: any[]; edges: any[] } }\n >\n > = {};\n if (!workflows) return result;\n\n // Build a normalized lookup for graphs since the graph extractor uses\n // paths from workflowId (e.g. \"./workflows/hello-agent\") while the\n // manifest uses source file paths (e.g. \"workflows/hello-agent.ts\").\n // Normalize by stripping leading \"./\" and file extensions.\n const normalizedGraphs = new Map<\n string,\n Record<string, { graph: { nodes: any[]; edges: any[] } }>\n >();\n for (const [graphPath, graphEntries] of Object.entries(graphs)) {\n const normalized = graphPath\n .replace(/^\\.\\//, '')\n .replace(/\\.[^/.]+$/, '');\n normalizedGraphs.set(normalized, graphEntries);\n }\n\n for (const [filePath, entries] of Object.entries(workflows)) {\n result[filePath] = {};\n // Normalize the manifest file path for lookup\n const normalizedFilePath = filePath\n .replace(/^\\.\\//, '')\n .replace(/\\.[^/.]+$/, '');\n\n const graphEntries =\n graphs[filePath] || normalizedGraphs.get(normalizedFilePath);\n\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = {\n workflowId: data.workflowId,\n graph: graphEntries?.[name]?.graph || { nodes: [], edges: [] },\n };\n }\n }\n return result;\n }\n\n private convertClassesManifest(\n classes: WorkflowManifest['classes']\n ): Record<string, Record<string, { classId: string }>> {\n const result: Record<string, Record<string, { classId: string }>> = {};\n if (!classes) return result;\n\n for (const [filePath, entries] of Object.entries(classes)) {\n result[filePath] = {};\n for (const [name, data] of Object.entries(entries)) {\n result[filePath][name] = { classId: data.classId };\n }\n }\n return result;\n }\n}\n"]}
|
|
@@ -14,6 +14,9 @@ class TestBuilder extends BaseBuilder {
|
|
|
14
14
|
getInputFiles() {
|
|
15
15
|
return super.getInputFiles();
|
|
16
16
|
}
|
|
17
|
+
getDiagnosticsManifestPath() {
|
|
18
|
+
return super.getDiagnosticsManifestPath();
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
// Resolve symlinks in tmpdir to avoid macOS /var -> /private/var issues
|
|
19
22
|
const realTmpdir = realpathSync(tmpdir());
|
|
@@ -31,7 +34,7 @@ function writeFile(dir, relativePath, content = '') {
|
|
|
31
34
|
writeFileSync(fullPath, content, 'utf-8');
|
|
32
35
|
return fullPath;
|
|
33
36
|
}
|
|
34
|
-
function createBuilder(workingDir, dirs) {
|
|
37
|
+
function createBuilder(workingDir, dirs, configOverrides = {}) {
|
|
35
38
|
const config = {
|
|
36
39
|
buildTarget: 'standalone',
|
|
37
40
|
workingDir,
|
|
@@ -39,6 +42,7 @@ function createBuilder(workingDir, dirs) {
|
|
|
39
42
|
stepsBundlePath: join(workingDir, 'steps.js'),
|
|
40
43
|
workflowsBundlePath: join(workingDir, 'workflows.js'),
|
|
41
44
|
webhookBundlePath: join(workingDir, 'webhook.js'),
|
|
45
|
+
...configOverrides,
|
|
42
46
|
};
|
|
43
47
|
return new TestBuilder(config);
|
|
44
48
|
}
|
|
@@ -118,4 +122,47 @@ describe('getInputFiles', () => {
|
|
|
118
122
|
expect(files).toContain(normalize(join(srcDir, '.api/config.cjs')));
|
|
119
123
|
});
|
|
120
124
|
});
|
|
125
|
+
describe('getDiagnosticsManifestPath', () => {
|
|
126
|
+
let testRoot;
|
|
127
|
+
beforeEach(() => {
|
|
128
|
+
testRoot = mkdtempSync(join(realTmpdir, 'diagnostics-path-'));
|
|
129
|
+
});
|
|
130
|
+
afterEach(() => {
|
|
131
|
+
rmSync(testRoot, { recursive: true, force: true });
|
|
132
|
+
});
|
|
133
|
+
it('uses an explicit diagnosticsDir when configured', () => {
|
|
134
|
+
const builder = createBuilder(testRoot, ['src'], {
|
|
135
|
+
diagnosticsDir: '.next/diagnostics',
|
|
136
|
+
});
|
|
137
|
+
expect(builder.getDiagnosticsManifestPath()).toBe(join(testRoot, '.next/diagnostics/workflows-manifest.json'));
|
|
138
|
+
});
|
|
139
|
+
it('does not emit Vercel diagnostics for non-Vercel builder targets', () => {
|
|
140
|
+
const previousTargetWorld = process.env.WORKFLOW_TARGET_WORLD;
|
|
141
|
+
process.env.WORKFLOW_TARGET_WORLD = 'vercel';
|
|
142
|
+
try {
|
|
143
|
+
const builder = createBuilder(testRoot, ['src']);
|
|
144
|
+
expect(builder.getDiagnosticsManifestPath()).toBeUndefined();
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
if (previousTargetWorld === undefined) {
|
|
148
|
+
delete process.env.WORKFLOW_TARGET_WORLD;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
process.env.WORKFLOW_TARGET_WORLD = previousTargetWorld;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
it('falls back to Vercel output diagnostics for the Vercel builder', () => {
|
|
156
|
+
const config = {
|
|
157
|
+
buildTarget: 'vercel-build-output-api',
|
|
158
|
+
workingDir: testRoot,
|
|
159
|
+
dirs: ['src'],
|
|
160
|
+
stepsBundlePath: join(testRoot, 'steps.js'),
|
|
161
|
+
workflowsBundlePath: join(testRoot, 'workflows.js'),
|
|
162
|
+
webhookBundlePath: join(testRoot, 'webhook.js'),
|
|
163
|
+
};
|
|
164
|
+
const builder = new TestBuilder(config);
|
|
165
|
+
expect(builder.getDiagnosticsManifestPath()).toBe(join(testRoot, '.vercel/output/diagnostics/workflows-manifest.json'));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
121
168
|
//# sourceMappingURL=get-input-files.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-input-files.test.js","sourceRoot":"","sources":["../src/get-input-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;GAEG;AACH,MAAM,WAAY,SAAQ,WAAW;IACnC,KAAK,CAAC,KAAK;QACT,QAAQ;IACV,CAAC;IAED,mBAAmB;IACZ,aAAa;QAClB,OAAO,KAAK,CAAC,aA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AC,CAAC;QAE7D,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACnE,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdirSync,\n mkdtempSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { afterEach, beforeEach, describe, expect, it } from 'vitest';\nimport { BaseBuilder } from './base-builder.js';\nimport type { StandaloneConfig } from './types.js';\n\n/**\n * Minimal subclass to expose the protected `getInputFiles()` for testing.\n */\nclass TestBuilder extends BaseBuilder {\n async build(): Promise<void> {\n // no-op\n }\n\n // Expose for tests\n public getInputFiles(): Promise<string[]> {\n return super.getInputFiles();\n }\n}\n\n// Resolve symlinks in tmpdir to avoid macOS /var -> /private/var issues\nconst realTmpdir = realpathSync(tmpdir());\n\n/**\n * Normalize a path to forward slashes for cross-platform comparison.\n * tinyglobby always returns forward-slash paths, even on Windows,\n * while Node's `path.join()` uses backslashes on Windows.\n */\nfunction normalize(p: string): string {\n return p.replace(/\\\\/g, '/');\n}\n\nfunction writeFile(dir: string, relativePath: string, content = ''): string {\n const fullPath = join(dir, relativePath);\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, content, 'utf-8');\n return fullPath;\n}\n\nfunction createBuilder(workingDir: string, dirs: string[]): TestBuilder {\n const config: StandaloneConfig = {\n buildTarget: 'standalone',\n workingDir,\n dirs,\n stepsBundlePath: join(workingDir, 'steps.js'),\n workflowsBundlePath: join(workingDir, 'workflows.js'),\n webhookBundlePath: join(workingDir, 'webhook.js'),\n };\n return new TestBuilder(config);\n}\n\ndescribe('getInputFiles', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'get-input-files-'));\n });\n\n afterEach(() => {\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n it('discovers files inside dot-prefixed directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.hidden/step.ts', \"'use step';\");\n writeFile(srcDir, '.config/workflow.ts', \"'use workflow';\");\n writeFile(srcDir, 'regular/step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.hidden/step.ts')));\n expect(files).toContain(normalize(join(srcDir, '.config/workflow.ts')));\n expect(files).toContain(normalize(join(srcDir, 'regular/step.ts')));\n });\n\n it('discovers dot-prefixed files', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.hidden-step.ts', \"'use step';\");\n writeFile(srcDir, 'visible-step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.hidden-step.ts')));\n expect(files).toContain(normalize(join(srcDir, 'visible-step.ts')));\n });\n\n it('still excludes explicitly ignored dot-directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.git/hooks/pre-commit.ts');\n writeFile(srcDir, '.next/server/page.ts');\n writeFile(srcDir, '.nuxt/workflow/steps.mjs');\n writeFile(srcDir, '.vercel/output/step.ts');\n writeFile(srcDir, '.svelte-kit/output/step.ts');\n writeFile(srcDir, '.workflow-data/state.ts');\n writeFile(srcDir, '.workflow-vitest/workflows.mjs');\n writeFile(srcDir, '.well-known/workflow/route.ts');\n writeFile(srcDir, '.turbo/cache/build.ts');\n writeFile(srcDir, '.cache/babel/plugin.js');\n writeFile(srcDir, '.yarn/releases/yarn.cjs');\n writeFile(srcDir, '.pnpm-store/v3/files.ts');\n writeFile(srcDir, 'node_modules/pkg/index.ts');\n // This one should still be found\n writeFile(srcDir, '.custom/step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).not.toContain(\n normalize(join(srcDir, '.git/hooks/pre-commit.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.next/server/page.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.nuxt/workflow/steps.mjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.vercel/output/step.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.svelte-kit/output/step.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.workflow-data/state.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.workflow-vitest/workflows.mjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.well-known/workflow/route.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.turbo/cache/build.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.cache/babel/plugin.js'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.yarn/releases/yarn.cjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.pnpm-store/v3/files.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, 'node_modules/pkg/index.ts'))\n );\n expect(files).toContain(normalize(join(srcDir, '.custom/step.ts')));\n });\n\n it('discovers files with various supported extensions in dot-directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.api/route.tsx');\n writeFile(srcDir, '.api/handler.mts');\n writeFile(srcDir, '.api/utils.js');\n writeFile(srcDir, '.api/config.cjs');\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.api/route.tsx')));\n expect(files).toContain(normalize(join(srcDir, '.api/handler.mts')));\n expect(files).toContain(normalize(join(srcDir, '.api/utils.js')));\n expect(files).toContain(normalize(join(srcDir, '.api/config.cjs')));\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"get-input-files.test.js","sourceRoot":"","sources":["../src/get-input-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;GAEG;AACH,MAAM,WAAY,SAAQ,WAAW;IACnC,KAAK,CAAC,KAAK;QACT,QAAQ;IACV,CAAC;IAED,mBAAmB;IACZ,aAAa;QAClB,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;IAC/B,CAAC;IAEM,0BAA0B;QAC/B,OAAO,KAAK,CAAC,0BAA0B,EAAE,CAAC;IAC5C,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAE1C;;;;GAIG;AACH,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,YAAoB,EAAE,OAAO,GAAG,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,G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QAC/D,CAAC;gBAAS,CAAC;YACT,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;gBACtC,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,qBAAqB,GAAG,mBAAmB,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,MAAM,GAA4B;YACtC,WAAW,EAAE,yBAAyB;YACtC,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,CAAC,KAAK,CAAC;YACb,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;YAC3C,mBAAmB,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC;YACnD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC;SAChD,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;QAExC,MAAM,CAAC,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC,IAAI,CAC/C,IAAI,CAAC,QAAQ,EAAE,oDAAoD,CAAC,CACrE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdirSync,\n mkdtempSync,\n realpathSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { afterEach, beforeEach, describe, expect, it } from 'vitest';\nimport { BaseBuilder } from './base-builder.js';\nimport type { StandaloneConfig, VercelBuildOutputConfig } from './types.js';\n\n/**\n * Minimal subclass to expose the protected `getInputFiles()` for testing.\n */\nclass TestBuilder extends BaseBuilder {\n async build(): Promise<void> {\n // no-op\n }\n\n // Expose for tests\n public getInputFiles(): Promise<string[]> {\n return super.getInputFiles();\n }\n\n public getDiagnosticsManifestPath(): string | undefined {\n return super.getDiagnosticsManifestPath();\n }\n}\n\n// Resolve symlinks in tmpdir to avoid macOS /var -> /private/var issues\nconst realTmpdir = realpathSync(tmpdir());\n\n/**\n * Normalize a path to forward slashes for cross-platform comparison.\n * tinyglobby always returns forward-slash paths, even on Windows,\n * while Node's `path.join()` uses backslashes on Windows.\n */\nfunction normalize(p: string): string {\n return p.replace(/\\\\/g, '/');\n}\n\nfunction writeFile(dir: string, relativePath: string, content = ''): string {\n const fullPath = join(dir, relativePath);\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, content, 'utf-8');\n return fullPath;\n}\n\nfunction createBuilder(\n workingDir: string,\n dirs: string[],\n configOverrides: Partial<StandaloneConfig> = {}\n): TestBuilder {\n const config: StandaloneConfig = {\n buildTarget: 'standalone',\n workingDir,\n dirs,\n stepsBundlePath: join(workingDir, 'steps.js'),\n workflowsBundlePath: join(workingDir, 'workflows.js'),\n webhookBundlePath: join(workingDir, 'webhook.js'),\n ...configOverrides,\n };\n return new TestBuilder(config);\n}\n\ndescribe('getInputFiles', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'get-input-files-'));\n });\n\n afterEach(() => {\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n it('discovers files inside dot-prefixed directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.hidden/step.ts', \"'use step';\");\n writeFile(srcDir, '.config/workflow.ts', \"'use workflow';\");\n writeFile(srcDir, 'regular/step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.hidden/step.ts')));\n expect(files).toContain(normalize(join(srcDir, '.config/workflow.ts')));\n expect(files).toContain(normalize(join(srcDir, 'regular/step.ts')));\n });\n\n it('discovers dot-prefixed files', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.hidden-step.ts', \"'use step';\");\n writeFile(srcDir, 'visible-step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.hidden-step.ts')));\n expect(files).toContain(normalize(join(srcDir, 'visible-step.ts')));\n });\n\n it('still excludes explicitly ignored dot-directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.git/hooks/pre-commit.ts');\n writeFile(srcDir, '.next/server/page.ts');\n writeFile(srcDir, '.nuxt/workflow/steps.mjs');\n writeFile(srcDir, '.vercel/output/step.ts');\n writeFile(srcDir, '.svelte-kit/output/step.ts');\n writeFile(srcDir, '.workflow-data/state.ts');\n writeFile(srcDir, '.workflow-vitest/workflows.mjs');\n writeFile(srcDir, '.well-known/workflow/route.ts');\n writeFile(srcDir, '.turbo/cache/build.ts');\n writeFile(srcDir, '.cache/babel/plugin.js');\n writeFile(srcDir, '.yarn/releases/yarn.cjs');\n writeFile(srcDir, '.pnpm-store/v3/files.ts');\n writeFile(srcDir, 'node_modules/pkg/index.ts');\n // This one should still be found\n writeFile(srcDir, '.custom/step.ts', \"'use step';\");\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).not.toContain(\n normalize(join(srcDir, '.git/hooks/pre-commit.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.next/server/page.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.nuxt/workflow/steps.mjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.vercel/output/step.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.svelte-kit/output/step.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.workflow-data/state.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.workflow-vitest/workflows.mjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.well-known/workflow/route.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.turbo/cache/build.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.cache/babel/plugin.js'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.yarn/releases/yarn.cjs'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, '.pnpm-store/v3/files.ts'))\n );\n expect(files).not.toContain(\n normalize(join(srcDir, 'node_modules/pkg/index.ts'))\n );\n expect(files).toContain(normalize(join(srcDir, '.custom/step.ts')));\n });\n\n it('discovers files with various supported extensions in dot-directories', async () => {\n const srcDir = join(testRoot, 'src');\n writeFile(srcDir, '.api/route.tsx');\n writeFile(srcDir, '.api/handler.mts');\n writeFile(srcDir, '.api/utils.js');\n writeFile(srcDir, '.api/config.cjs');\n\n const builder = createBuilder(testRoot, ['src']);\n const files = (await builder.getInputFiles()).map(normalize);\n\n expect(files).toContain(normalize(join(srcDir, '.api/route.tsx')));\n expect(files).toContain(normalize(join(srcDir, '.api/handler.mts')));\n expect(files).toContain(normalize(join(srcDir, '.api/utils.js')));\n expect(files).toContain(normalize(join(srcDir, '.api/config.cjs')));\n });\n});\n\ndescribe('getDiagnosticsManifestPath', () => {\n let testRoot: string;\n\n beforeEach(() => {\n testRoot = mkdtempSync(join(realTmpdir, 'diagnostics-path-'));\n });\n\n afterEach(() => {\n rmSync(testRoot, { recursive: true, force: true });\n });\n\n it('uses an explicit diagnosticsDir when configured', () => {\n const builder = createBuilder(testRoot, ['src'], {\n diagnosticsDir: '.next/diagnostics',\n });\n\n expect(builder.getDiagnosticsManifestPath()).toBe(\n join(testRoot, '.next/diagnostics/workflows-manifest.json')\n );\n });\n\n it('does not emit Vercel diagnostics for non-Vercel builder targets', () => {\n const previousTargetWorld = process.env.WORKFLOW_TARGET_WORLD;\n process.env.WORKFLOW_TARGET_WORLD = 'vercel';\n try {\n const builder = createBuilder(testRoot, ['src']);\n\n expect(builder.getDiagnosticsManifestPath()).toBeUndefined();\n } finally {\n if (previousTargetWorld === undefined) {\n delete process.env.WORKFLOW_TARGET_WORLD;\n } else {\n process.env.WORKFLOW_TARGET_WORLD = previousTargetWorld;\n }\n }\n });\n\n it('falls back to Vercel output diagnostics for the Vercel builder', () => {\n const config: VercelBuildOutputConfig = {\n buildTarget: 'vercel-build-output-api',\n workingDir: testRoot,\n dirs: ['src'],\n stepsBundlePath: join(testRoot, 'steps.js'),\n workflowsBundlePath: join(testRoot, 'workflows.js'),\n webhookBundlePath: join(testRoot, 'webhook.js'),\n };\n const builder = new TestBuilder(config);\n\n expect(builder.getDiagnosticsManifestPath()).toBe(\n join(testRoot, '.vercel/output/diagnostics/workflows-manifest.json')\n );\n });\n});\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from 'esbuild';
|
|
2
2
|
import { type WorkflowManifest } from './apply-swc-transform.js';
|
|
3
3
|
export interface SwcPluginOptions {
|
|
4
|
-
mode: 'step' | 'workflow'
|
|
4
|
+
mode: 'step' | 'workflow';
|
|
5
5
|
entriesToBundle?: string[];
|
|
6
6
|
outdir?: string;
|
|
7
7
|
projectRoot?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swc-esbuild-plugin.d.ts","sourceRoot":"","sources":["../src/swc-esbuild-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAOlC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"swc-esbuild-plugin.d.ts","sourceRoot":"","sources":["../src/swc-esbuild-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAOlC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,eAAe,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AC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACzD,OAAO,CAAC,KAAK,CACX,4BAA4B,IAAI,CAAC,IAAI,GAAG,EACxC,YAAY,CACb,CAAC;oBACF,OAAO;wBACL,MAAM,EAAE;4BACN;gCACE,IAAI,EAAE,yBAAyB,YAAY,EAAE;gCAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;6BAClD;yBACF;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative } from 'node:path';\nimport { promisify } from 'node:util';\nimport enhancedResolveOrig from 'enhanced-resolve';\nimport type { Plugin } from 'esbuild';\nimport {\n applySwcTransform,\n type WorkflowManifest,\n} from './apply-swc-transform.js';\nimport {\n jsTsRegex,\n parentHasChild,\n} from './discover-entries-esbuild-plugin.js';\nimport { resolveWorkflowAliasRelativePath } from './workflow-alias.js';\n\nexport interface SwcPluginOptions {\n mode: 'step' | 'workflow' | 'client';\n entriesToBundle?: string[];\n outdir?: string;\n projectRoot?: string;\n workflowManifest?: WorkflowManifest;\n /**\n * Rewrite TypeScript extensions (.ts, .tsx, .mts, .cts) to their JS\n * equivalents (.js, .mjs, .cjs) in externalized import paths.\n *\n * Enable this when the output bundle is consumed directly by Node's native\n * ESM loader (e.g. vitest), which cannot resolve .ts extensions.\n *\n * Leave disabled (default) when a downstream bundler (webpack, Vite, etc.)\n * handles resolution — those tools resolve .ts natively and rewriting\n * breaks them because the .js file doesn't exist on disk.\n */\n rewriteTsExtensions?: boolean;\n /**\n * Absolute file paths of discovered workflow/step/serde entries whose\n * imports must be treated as side-effectful.\n *\n * The SWC compiler transform injects registration calls (workflow IDs,\n * step IDs, class serialization, etc.) into these files. Without this\n * override, esbuild honours `\"sideEffects\": false` from the package's\n * `package.json` and silently drops bare imports of these modules.\n */\n sideEffectEntries?: string[];\n}\n\nconst NODE_RESOLVE_OPTIONS = {\n dependencyType: 'commonjs',\n modules: ['node_modules'],\n exportsFields: ['exports'],\n importsFields: ['imports'],\n conditionNames: ['node', 'require'],\n descriptionFiles: ['package.json'],\n extensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.cjs',\n '.mjs',\n '.js',\n '.jsx',\n '.json',\n '.node',\n ],\n enforceExtensions: false,\n symlinks: true,\n mainFields: ['main'],\n mainFiles: ['index'],\n roots: [],\n fullySpecified: false,\n preferRelative: false,\n preferAbsolute: false,\n restrictions: [],\n};\n\nconst NODE_ESM_RESOLVE_OPTIONS = {\n ...NODE_RESOLVE_OPTIONS,\n dependencyType: 'esm',\n conditionNames: ['node', 'import'],\n};\n\nexport function createSwcPlugin(options: SwcPluginOptions): Plugin {\n return {\n name: 'swc-workflow-plugin',\n setup(build) {\n // everything is external unless explicitly configured\n // to be bundled\n const cjsResolver = promisify(\n enhancedResolveOrig.create(NODE_RESOLVE_OPTIONS)\n );\n const esmResolver = promisify(\n enhancedResolveOrig.create(NODE_ESM_RESOLVE_OPTIONS)\n );\n\n const enhancedResolve = async (context: string, path: string) => {\n try {\n return await esmResolver(context, path);\n } catch (_) {\n return cjsResolver(context, path);\n }\n };\n\n // Pre-compute the normalized side-effect entries set for O(1) lookups.\n const normalizedSideEffectEntries = new Set(\n options.sideEffectEntries?.map((e) => e.replace(/\\\\/g, '/'))\n );\n\n build.onResolve({ filter: /.*/ }, async (args) => {\n if (args.pluginData?.skipSwcPlugin) return null;\n\n if (\n !options.entriesToBundle &&\n normalizedSideEffectEntries.size === 0\n ) {\n return null;\n }\n\n // When only sideEffectEntries is set (no entriesToBundle), we only\n // need to override sideEffects for top-level bare imports — typically\n // from the virtual entry. Skip resolution for transitive imports\n // (dynamic imports, requires, etc.) to avoid unnecessary overhead.\n if (!options.entriesToBundle && args.kind !== 'import-statement') {\n return null;\n }\n\n try {\n const specifier = args.path;\n const specifierIsPath =\n specifier.startsWith('.') || specifier.startsWith('/');\n\n let resolvedPath: string | false | undefined;\n // Determines whether the external path should be relativized\n // (project-local file) or kept as a bare specifier (npm package).\n let shouldMakeRelative = specifierIsPath;\n\n if (specifierIsPath) {\n resolvedPath = await enhancedResolve(args.resolveDir, specifier);\n } else {\n // Resolve from project root so nested deps aren't externalized\n resolvedPath = await enhancedResolve(\n build.initialOptions.absWorkingDir || process.cwd(),\n specifier\n ).catch(() => undefined); // swallow so esbuild fallback below can try\n\n // Fall back to esbuild for aliases/tsconfig paths,\n // but only accept project-local results\n if (!resolvedPath) {\n const esbuildResult = await build.resolve(specifier, {\n resolveDir: args.resolveDir,\n kind: args.kind,\n pluginData: { skipSwcPlugin: true },\n });\n const didResolve =\n !!esbuildResult.path && !esbuildResult.errors.length;\n const isProjectLocalFile =\n didResolve &&\n !esbuildResult.external &&\n !esbuildResult.path\n .replace(/\\\\/g, '/')\n .includes('/node_modules/');\n if (isProjectLocalFile) {\n resolvedPath = esbuildResult.path;\n shouldMakeRelative = true;\n }\n }\n }\n\n if (!resolvedPath) return null;\n\n // Normalize to forward slashes for cross-platform comparison\n const normalizedResolvedPath = resolvedPath.replace(/\\\\/g, '/');\n\n // Check if this module is a discovered entry whose SWC-transformed\n // code contains side effects (workflow/step/class registration).\n // Override the package.json \"sideEffects\": false so esbuild does not\n // drop bare imports of these modules.\n const hasSideEffects = normalizedSideEffectEntries.has(\n normalizedResolvedPath\n );\n\n if (options.entriesToBundle) {\n let shouldBundle = false;\n for (const entryToBundle of options.entriesToBundle) {\n const normalizedEntry = entryToBundle.replace(/\\\\/g, '/');\n\n if (normalizedResolvedPath === normalizedEntry) {\n shouldBundle = true;\n break;\n }\n\n // if the current entry imports a child that needs\n // to be bundled then it needs to also be bundled so\n // that the child can have our transform applied\n if (parentHasChild(normalizedResolvedPath, normalizedEntry)) {\n shouldBundle = true;\n break;\n }\n }\n\n if (shouldBundle) {\n // Let esbuild bundle this entry, but override sideEffects if needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n }\n\n let externalPath: string;\n if (shouldMakeRelative) {\n // When the resolved file lives inside node_modules, let\n // esbuild bundle it rather than externalizing with a deeply\n // nested relative path. Downstream bundlers (Rollup/Vite)\n // can't rewrite opaque `__require()` calls in CJS shims, so\n // relative paths computed for `outdir` break once the output\n // is rebundled to a different directory.\n if (normalizedResolvedPath.includes('/node_modules/')) {\n return null; // let esbuild bundle it\n }\n\n externalPath = relative(\n options.outdir || process.cwd(),\n resolvedPath\n ).replace(/\\\\/g, '/');\n\n if (options.rewriteTsExtensions) {\n // Rewrite TypeScript extensions to their JS equivalents so the\n // externalized import is loadable by Node's native ESM loader.\n externalPath = externalPath\n .replace(/\\.tsx?$/, '.js')\n .replace(/\\.mts$/, '.mjs')\n .replace(/\\.cts$/, '.cjs');\n }\n } else {\n externalPath = specifier;\n }\n\n return {\n external: true,\n path: externalPath,\n sideEffects: hasSideEffects || undefined,\n };\n }\n\n // No entriesToBundle — only override sideEffects when needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n } catch (_) {}\n return null;\n });\n\n // Handle TypeScript and JavaScript files\n build.onLoad({ filter: jsTsRegex }, async (args) => {\n // Determine if this is a TypeScript file\n try {\n // Determine the loader based on the output\n let loader: 'js' | 'jsx' | 'tsx' = 'js';\n if (args.path.endsWith('.jsx')) {\n loader = 'jsx';\n } else if (args.path.endsWith('.tsx')) {\n loader = 'tsx';\n }\n const source = await readFile(args.path, 'utf8');\n const normalizedSource = source\n .replace(/require\\(\\s*(['\"])server-only\\1\\s*\\)/g, 'void 0')\n .replace(/require\\(\\s*(['\"])client-only\\1\\s*\\)/g, 'void 0');\n\n // Calculate relative path for SWC plugin\n // The filename parameter is used to generate workflowId/stepId, so it must be relative\n const workingDir =\n build.initialOptions.absWorkingDir || process.cwd();\n const projectRoot = options.projectRoot || workingDir;\n // Normalize paths: convert backslashes to forward slashes and remove trailing slashes\n const normalizedWorkingDir = workingDir\n .replace(/\\\\/g, '/')\n .replace(/\\/$/, '');\n const normalizedPath = args.path.replace(/\\\\/g, '/');\n\n // Windows fix: Always do case-insensitive path comparison as the PRIMARY logic\n // to work around node:path.relative() not recognizing paths with different drive\n // letter casing (e.g., D: vs d:) as being in the same tree\n const lowerWd = normalizedWorkingDir.toLowerCase();\n const lowerPath = normalizedPath.toLowerCase();\n\n let relativeFilepath: string;\n if (lowerPath.startsWith(lowerWd + '/')) {\n // File is under working directory - manually calculate relative path\n // This ensures we get a relative path even with drive letter casing issues\n relativeFilepath = normalizedPath.substring(\n normalizedWorkingDir.length + 1\n );\n } else if (lowerPath === lowerWd) {\n // File IS the working directory\n relativeFilepath = '.';\n } else {\n // File is outside working directory - use relative() and strip ../ prefixes if needed\n relativeFilepath = relative(\n normalizedWorkingDir,\n normalizedPath\n ).replace(/\\\\/g, '/');\n\n // Handle files discovered outside the working directory\n // These come back as ../path/to/file, but we want just path/to/file\n if (relativeFilepath.startsWith('../')) {\n const aliasedRelativePath =\n await resolveWorkflowAliasRelativePath(args.path, workingDir);\n if (aliasedRelativePath) {\n relativeFilepath = aliasedRelativePath;\n } else {\n relativeFilepath = relativeFilepath\n .split('/')\n .filter((part) => part !== '..')\n .join('/');\n }\n }\n }\n\n // Final safety check - ensure we never pass an absolute path to SWC\n if (\n relativeFilepath.includes(':') ||\n relativeFilepath.startsWith('/')\n ) {\n // This should never happen, but if it does, use just the filename as last resort\n console.error(\n `[ERROR] relativeFilepath is still absolute: ${relativeFilepath}`\n );\n relativeFilepath = normalizedPath.split('/').pop() || 'unknown.ts';\n }\n\n const { code: transformedCode, workflowManifest } =\n await applySwcTransform(\n relativeFilepath,\n normalizedSource,\n options.mode,\n args.path, // Pass absolute path for module specifier resolution\n projectRoot\n );\n\n if (!options.workflowManifest) {\n options.workflowManifest = {};\n }\n\n options.workflowManifest.workflows = Object.assign(\n options.workflowManifest.workflows || {},\n workflowManifest.workflows\n );\n options.workflowManifest.steps = Object.assign(\n options.workflowManifest.steps || {},\n workflowManifest.steps\n );\n options.workflowManifest.classes = Object.assign(\n options.workflowManifest.classes || {},\n workflowManifest.classes\n );\n\n return {\n contents: transformedCode,\n loader,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n console.error(\n `❌ SWC transform error in ${args.path}:`,\n errorMessage\n );\n return {\n errors: [\n {\n text: `SWC transform failed: ${errorMessage}`,\n location: { file: args.path, line: 0, column: 0 },\n },\n ],\n };\n }\n });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"swc-esbuild-plugin.js","sourceRoot":"","sources":["../src/swc-esbuild-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAgCvE,MAAM,oBAAoB,GAAG;IAC3B,cAAc,EAAE,UAAU;IAC1B,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,aAAa,EAAE,CAAC,SAAS,CAAC;IAC1B,aAAa,EAAE,CAAC,SAAS,CAAC;IAC1B,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;IACnC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AAO,CACzB,CAAC;oBAEF,OAAO;wBACL,QAAQ,EAAE,eAAe;wBACzB,MAAM;qBACP,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACzD,OAAO,CAAC,KAAK,CACX,4BAA4B,IAAI,CAAC,IAAI,GAAG,EACxC,YAAY,CACb,CAAC;oBACF,OAAO;wBACL,MAAM,EAAE;4BACN;gCACE,IAAI,EAAE,yBAAyB,YAAY,EAAE;gCAC7C,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;6BAClD;yBACF;qBACF,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative } from 'node:path';\nimport { promisify } from 'node:util';\nimport enhancedResolveOrig from 'enhanced-resolve';\nimport type { Plugin } from 'esbuild';\nimport {\n applySwcTransform,\n type WorkflowManifest,\n} from './apply-swc-transform.js';\nimport {\n jsTsRegex,\n parentHasChild,\n} from './discover-entries-esbuild-plugin.js';\nimport { resolveWorkflowAliasRelativePath } from './workflow-alias.js';\n\nexport interface SwcPluginOptions {\n mode: 'step' | 'workflow';\n entriesToBundle?: string[];\n outdir?: string;\n projectRoot?: string;\n workflowManifest?: WorkflowManifest;\n /**\n * Rewrite TypeScript extensions (.ts, .tsx, .mts, .cts) to their JS\n * equivalents (.js, .mjs, .cjs) in externalized import paths.\n *\n * Enable this when the output bundle is consumed directly by Node's native\n * ESM loader (e.g. vitest), which cannot resolve .ts extensions.\n *\n * Leave disabled (default) when a downstream bundler (webpack, Vite, etc.)\n * handles resolution — those tools resolve .ts natively and rewriting\n * breaks them because the .js file doesn't exist on disk.\n */\n rewriteTsExtensions?: boolean;\n /**\n * Absolute file paths of discovered workflow/step/serde entries whose\n * imports must be treated as side-effectful.\n *\n * The SWC compiler transform injects registration calls (workflow IDs,\n * step IDs, class serialization, etc.) into these files. Without this\n * override, esbuild honours `\"sideEffects\": false` from the package's\n * `package.json` and silently drops bare imports of these modules.\n */\n sideEffectEntries?: string[];\n}\n\nconst NODE_RESOLVE_OPTIONS = {\n dependencyType: 'commonjs',\n modules: ['node_modules'],\n exportsFields: ['exports'],\n importsFields: ['imports'],\n conditionNames: ['node', 'require'],\n descriptionFiles: ['package.json'],\n extensions: [\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.cjs',\n '.mjs',\n '.js',\n '.jsx',\n '.json',\n '.node',\n ],\n enforceExtensions: false,\n symlinks: true,\n mainFields: ['main'],\n mainFiles: ['index'],\n roots: [],\n fullySpecified: false,\n preferRelative: false,\n preferAbsolute: false,\n restrictions: [],\n};\n\nconst NODE_ESM_RESOLVE_OPTIONS = {\n ...NODE_RESOLVE_OPTIONS,\n dependencyType: 'esm',\n conditionNames: ['node', 'import'],\n};\n\nexport function createSwcPlugin(options: SwcPluginOptions): Plugin {\n return {\n name: 'swc-workflow-plugin',\n setup(build) {\n // everything is external unless explicitly configured\n // to be bundled\n const cjsResolver = promisify(\n enhancedResolveOrig.create(NODE_RESOLVE_OPTIONS)\n );\n const esmResolver = promisify(\n enhancedResolveOrig.create(NODE_ESM_RESOLVE_OPTIONS)\n );\n\n const enhancedResolve = async (context: string, path: string) => {\n try {\n return await esmResolver(context, path);\n } catch (_) {\n return cjsResolver(context, path);\n }\n };\n\n // Pre-compute the normalized side-effect entries set for O(1) lookups.\n const normalizedSideEffectEntries = new Set(\n options.sideEffectEntries?.map((e) => e.replace(/\\\\/g, '/'))\n );\n\n build.onResolve({ filter: /.*/ }, async (args) => {\n if (args.pluginData?.skipSwcPlugin) return null;\n\n if (\n !options.entriesToBundle &&\n normalizedSideEffectEntries.size === 0\n ) {\n return null;\n }\n\n // When only sideEffectEntries is set (no entriesToBundle), we only\n // need to override sideEffects for top-level bare imports — typically\n // from the virtual entry. Skip resolution for transitive imports\n // (dynamic imports, requires, etc.) to avoid unnecessary overhead.\n if (!options.entriesToBundle && args.kind !== 'import-statement') {\n return null;\n }\n\n try {\n const specifier = args.path;\n const specifierIsPath =\n specifier.startsWith('.') || specifier.startsWith('/');\n\n let resolvedPath: string | false | undefined;\n // Determines whether the external path should be relativized\n // (project-local file) or kept as a bare specifier (npm package).\n let shouldMakeRelative = specifierIsPath;\n\n if (specifierIsPath) {\n resolvedPath = await enhancedResolve(args.resolveDir, specifier);\n } else {\n // Resolve from project root so nested deps aren't externalized\n resolvedPath = await enhancedResolve(\n build.initialOptions.absWorkingDir || process.cwd(),\n specifier\n ).catch(() => undefined); // swallow so esbuild fallback below can try\n\n // Fall back to esbuild for aliases/tsconfig paths,\n // but only accept project-local results\n if (!resolvedPath) {\n const esbuildResult = await build.resolve(specifier, {\n resolveDir: args.resolveDir,\n kind: args.kind,\n pluginData: { skipSwcPlugin: true },\n });\n const didResolve =\n !!esbuildResult.path && !esbuildResult.errors.length;\n const isProjectLocalFile =\n didResolve &&\n !esbuildResult.external &&\n !esbuildResult.path\n .replace(/\\\\/g, '/')\n .includes('/node_modules/');\n if (isProjectLocalFile) {\n resolvedPath = esbuildResult.path;\n shouldMakeRelative = true;\n }\n }\n }\n\n if (!resolvedPath) return null;\n\n // Normalize to forward slashes for cross-platform comparison\n const normalizedResolvedPath = resolvedPath.replace(/\\\\/g, '/');\n\n // Check if this module is a discovered entry whose SWC-transformed\n // code contains side effects (workflow/step/class registration).\n // Override the package.json \"sideEffects\": false so esbuild does not\n // drop bare imports of these modules.\n const hasSideEffects = normalizedSideEffectEntries.has(\n normalizedResolvedPath\n );\n\n if (options.entriesToBundle) {\n let shouldBundle = false;\n for (const entryToBundle of options.entriesToBundle) {\n const normalizedEntry = entryToBundle.replace(/\\\\/g, '/');\n\n if (normalizedResolvedPath === normalizedEntry) {\n shouldBundle = true;\n break;\n }\n\n // if the current entry imports a child that needs\n // to be bundled then it needs to also be bundled so\n // that the child can have our transform applied\n if (parentHasChild(normalizedResolvedPath, normalizedEntry)) {\n shouldBundle = true;\n break;\n }\n }\n\n if (shouldBundle) {\n // Let esbuild bundle this entry, but override sideEffects if needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n }\n\n let externalPath: string;\n if (shouldMakeRelative) {\n // When the resolved file lives inside node_modules, let\n // esbuild bundle it rather than externalizing with a deeply\n // nested relative path. Downstream bundlers (Rollup/Vite)\n // can't rewrite opaque `__require()` calls in CJS shims, so\n // relative paths computed for `outdir` break once the output\n // is rebundled to a different directory.\n if (normalizedResolvedPath.includes('/node_modules/')) {\n return null; // let esbuild bundle it\n }\n\n externalPath = relative(\n options.outdir || process.cwd(),\n resolvedPath\n ).replace(/\\\\/g, '/');\n\n if (options.rewriteTsExtensions) {\n // Rewrite TypeScript extensions to their JS equivalents so the\n // externalized import is loadable by Node's native ESM loader.\n externalPath = externalPath\n .replace(/\\.tsx?$/, '.js')\n .replace(/\\.mts$/, '.mjs')\n .replace(/\\.cts$/, '.cjs');\n }\n } else {\n externalPath = specifier;\n }\n\n return {\n external: true,\n path: externalPath,\n sideEffects: hasSideEffects || undefined,\n };\n }\n\n // No entriesToBundle — only override sideEffects when needed.\n // We must return the resolved `path` alongside `sideEffects` because\n // returning only `{ sideEffects: true }` without a path causes esbuild\n // to fall through to its own resolver, which re-reads the package.json\n // and applies `\"sideEffects\": false` from there.\n return hasSideEffects\n ? { path: resolvedPath, sideEffects: true }\n : null;\n } catch (_) {}\n return null;\n });\n\n // Handle TypeScript and JavaScript files\n build.onLoad({ filter: jsTsRegex }, async (args) => {\n // Determine if this is a TypeScript file\n try {\n // Determine the loader based on the output\n let loader: 'js' | 'jsx' | 'tsx' = 'js';\n if (args.path.endsWith('.jsx')) {\n loader = 'jsx';\n } else if (args.path.endsWith('.tsx')) {\n loader = 'tsx';\n }\n const source = await readFile(args.path, 'utf8');\n const normalizedSource = source\n .replace(/require\\(\\s*(['\"])server-only\\1\\s*\\)/g, 'void 0')\n .replace(/require\\(\\s*(['\"])client-only\\1\\s*\\)/g, 'void 0');\n\n // Calculate relative path for SWC plugin\n // The filename parameter is used to generate workflowId/stepId, so it must be relative\n const workingDir =\n build.initialOptions.absWorkingDir || process.cwd();\n const projectRoot = options.projectRoot || workingDir;\n // Normalize paths: convert backslashes to forward slashes and remove trailing slashes\n const normalizedWorkingDir = workingDir\n .replace(/\\\\/g, '/')\n .replace(/\\/$/, '');\n const normalizedPath = args.path.replace(/\\\\/g, '/');\n\n // Windows fix: Always do case-insensitive path comparison as the PRIMARY logic\n // to work around node:path.relative() not recognizing paths with different drive\n // letter casing (e.g., D: vs d:) as being in the same tree\n const lowerWd = normalizedWorkingDir.toLowerCase();\n const lowerPath = normalizedPath.toLowerCase();\n\n let relativeFilepath: string;\n if (lowerPath.startsWith(lowerWd + '/')) {\n // File is under working directory - manually calculate relative path\n // This ensures we get a relative path even with drive letter casing issues\n relativeFilepath = normalizedPath.substring(\n normalizedWorkingDir.length + 1\n );\n } else if (lowerPath === lowerWd) {\n // File IS the working directory\n relativeFilepath = '.';\n } else {\n // File is outside working directory - use relative() and strip ../ prefixes if needed\n relativeFilepath = relative(\n normalizedWorkingDir,\n normalizedPath\n ).replace(/\\\\/g, '/');\n\n // Handle files discovered outside the working directory\n // These come back as ../path/to/file, but we want just path/to/file\n if (relativeFilepath.startsWith('../')) {\n const aliasedRelativePath =\n await resolveWorkflowAliasRelativePath(args.path, workingDir);\n if (aliasedRelativePath) {\n relativeFilepath = aliasedRelativePath;\n } else {\n relativeFilepath = relativeFilepath\n .split('/')\n .filter((part) => part !== '..')\n .join('/');\n }\n }\n }\n\n // Final safety check - ensure we never pass an absolute path to SWC\n if (\n relativeFilepath.includes(':') ||\n relativeFilepath.startsWith('/')\n ) {\n // This should never happen, but if it does, use just the filename as last resort\n console.error(\n `[ERROR] relativeFilepath is still absolute: ${relativeFilepath}`\n );\n relativeFilepath = normalizedPath.split('/').pop() || 'unknown.ts';\n }\n\n const { code: transformedCode, workflowManifest } =\n await applySwcTransform(\n relativeFilepath,\n normalizedSource,\n options.mode,\n args.path, // Pass absolute path for module specifier resolution\n projectRoot\n );\n\n if (!options.workflowManifest) {\n options.workflowManifest = {};\n }\n\n options.workflowManifest.workflows = Object.assign(\n options.workflowManifest.workflows || {},\n workflowManifest.workflows\n );\n options.workflowManifest.steps = Object.assign(\n options.workflowManifest.steps || {},\n workflowManifest.steps\n );\n options.workflowManifest.classes = Object.assign(\n options.workflowManifest.classes || {},\n workflowManifest.classes\n );\n\n return {\n contents: transformedCode,\n loader,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n console.error(\n `❌ SWC transform error in ${args.path}:`,\n errorMessage\n );\n return {\n errors: [\n {\n text: `SWC transform failed: ${errorMessage}`,\n location: { file: args.path, line: 0, column: 0 },\n },\n ],\n };\n }\n });\n },\n };\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ interface BaseWorkflowConfig {
|
|
|
16
16
|
externalPackages?: string[];
|
|
17
17
|
workflowManifestPath?: string;
|
|
18
18
|
debugFilePrefix?: string;
|
|
19
|
+
diagnosticsDir?: string;
|
|
20
|
+
distDir?: string;
|
|
19
21
|
suppressCreateWorkflowsBundleLogs?: boolean;
|
|
20
22
|
suppressCreateWorkflowsBundleWarnings?: boolean;
|
|
21
23
|
suppressCreateWebhookBundleLogs?: boolean;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,0FAOpB,CAAC;A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C;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,kBAAkB;IACpD,WAAW,EAAE,MAAM,CAAC;IAEpB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,uBAAuB,GACvB,UAAU,GACV,UAAU,GACV,eAAe,GACf,WAAW,CAAC;AAEhB,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,IAAI,WAAW,CAEvB"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,YAAY;IACZ,yBAAyB;IACzB,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;CACC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,YAAY;IACZ,yBAAyB;IACzB,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;CACC,CAAC;AAgIX,MAAM,UAAU,kBAAkB,CAChC,MAA0B;IAE1B,OAAO,CAAC,CAAC,MAAM,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAqB,CAAC,CAAC;AACvE,CAAC","sourcesContent":["export const validBuildTargets = [\n 'standalone',\n 'vercel-build-output-api',\n 'next',\n 'nest',\n 'sveltekit',\n 'astro',\n] as const;\nexport type BuildTarget = (typeof validBuildTargets)[number];\n\n/**\n * Common configuration options shared across all builder types.\n */\ninterface BaseWorkflowConfig {\n watch?: boolean;\n dirs: string[];\n workingDir: string;\n /**\n * Project root used for package and workspace module-specifier resolution\n * during SWC transforms. Defaults to `workingDir`.\n */\n projectRoot?: string;\n\n // Optionally generate a client library for workflow execution. The preferred\n // method of using workflow is to use a loader within a framework (like\n // NextJS) that resolves client bindings on the fly.\n clientBundlePath?: string;\n\n externalPackages?: string[];\n\n workflowManifestPath?: string;\n\n // Optional prefix for debug files (e.g., \"_\" for Astro to ignore them)\n debugFilePrefix?: string;\n\n // Optional directory where diagnostics artifacts should be written.\n // The workflow manifest is written to workflows-manifest.json inside this dir.\n diagnosticsDir?: string;\n\n // Optional framework output directory, used by builders that mirror framework\n // artifact locations.\n distDir?: string;\n\n // Suppress informational logs emitted by createWorkflowsBundle()\n // (e.g. intermediate/final workflow bundle timing logs).\n suppressCreateWorkflowsBundleLogs?: boolean;\n\n // Suppress esbuild warnings emitted by createWorkflowsBundle().\n suppressCreateWorkflowsBundleWarnings?: boolean;\n\n // Suppress informational logs emitted by createWebhookBundle().\n suppressCreateWebhookBundleLogs?: boolean;\n\n // Suppress informational logs emitted by createManifest().\n suppressCreateManifestLogs?: boolean;\n\n // Node.js runtime version for Vercel Functions (e.g., \"nodejs22.x\", \"nodejs24.x\")\n runtime?: string;\n}\n\n/**\n * Configuration for standalone (CLI-based) builds.\n */\nexport interface StandaloneConfig extends BaseWorkflowConfig {\n buildTarget: 'standalone';\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Configuration for Vercel Build Output API builds.\n */\nexport interface VercelBuildOutputConfig extends BaseWorkflowConfig {\n buildTarget: 'vercel-build-output-api';\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Configuration for Next.js builds.\n */\nexport interface NextConfig extends BaseWorkflowConfig {\n buildTarget: 'next';\n // Next.js builder computes paths dynamically, so these are not used\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Configuration for SvelteKit builds.\n */\nexport interface SvelteKitConfig extends BaseWorkflowConfig {\n buildTarget: 'sveltekit';\n // SvelteKit builder computes paths dynamically, so these are not used\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Configuration for Astro builds.\n */\nexport interface AstroConfig extends BaseWorkflowConfig {\n buildTarget: 'astro';\n // Astro builder computes paths dynamically, so these are not used\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Configuration for NestJS builds.\n */\nexport interface NestConfig extends BaseWorkflowConfig {\n buildTarget: 'nest';\n // NestJS builder computes paths dynamically, so these are not used\n stepsBundlePath: string;\n workflowsBundlePath: string;\n webhookBundlePath: string;\n}\n\n/**\n * Discriminated union of all builder configuration types.\n */\nexport type WorkflowConfig =\n | StandaloneConfig\n | VercelBuildOutputConfig\n | NextConfig\n | NestConfig\n | SvelteKitConfig\n | AstroConfig;\n\nexport function isValidBuildTarget(\n target: string | undefined\n): target is BuildTarget {\n return !!target && validBuildTargets.includes(target as BuildTarget);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/builders",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.3",
|
|
4
4
|
"description": "Shared builder infrastructure for Workflow SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"find-up": "7.0.0",
|
|
41
41
|
"json5": "2.2.3",
|
|
42
42
|
"tinyglobby": "0.2.15",
|
|
43
|
-
"@workflow/core": "5.0.0-beta.
|
|
43
|
+
"@workflow/core": "5.0.0-beta.3",
|
|
44
44
|
"@workflow/errors": "5.0.0-beta.1",
|
|
45
45
|
"@workflow/utils": "5.0.0-beta.1",
|
|
46
|
-
"@workflow/swc-plugin": "5.0.0-beta.
|
|
46
|
+
"@workflow/swc-plugin": "5.0.0-beta.3"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc",
|