@@ -26,6 +26,7 @@ const EMIT_SOURCEMAPS_FOR_DEBUGGING =
2626 */
2727export abstract class BaseBuilder {
2828 protected config : WorkflowConfig ;
29+ protected lastWorkflowManifest ?: WorkflowManifest ;
2930
3031 constructor ( config : WorkflowConfig ) {
3132 this . config = config ;
@@ -253,6 +254,7 @@ export abstract class BaseBuilder {
253254 * Steps have full Node.js runtime access and handle side effects, API calls, etc.
254255 *
255256 * @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code
257+ * @returns Build context (for watch mode) and the collected workflow manifest
256258 */
257259 protected async createStepsBundle ( {
258260 inputFiles,
@@ -268,7 +270,10 @@ export abstract class BaseBuilder {
268270 outfile : string ;
269271 format ?: 'cjs' | 'esm' ;
270272 externalizeNonSteps ?: boolean ;
271- } ) : Promise < esbuild . BuildContext | undefined > {
273+ } ) : Promise < {
274+ context : esbuild . BuildContext | undefined ;
275+ manifest : WorkflowManifest ;
276+ } > {
272277 // These need to handle watching for dev to scan for
273278 // new entries and changes to existing ones
274279 const { discoveredSteps : stepFiles } = await this . discoverEntries (
@@ -389,10 +394,14 @@ export abstract class BaseBuilder {
389394 // Create .gitignore in .swc directory
390395 await this . createSwcGitignore ( ) ;
391396
397+ // Store the manifest for later use (e.g., graph generation in watch mode)
398+ this . lastWorkflowManifest = workflowManifest ;
399+
392400 if ( this . config . watch ) {
393- return esbuildCtx ;
401+ return { context : esbuildCtx , manifest : workflowManifest } ;
394402 }
395403 await esbuildCtx . dispose ( ) ;
404+ return { context : undefined , manifest : workflowManifest } ;
396405 }
397406
398407 /**
@@ -848,11 +857,13 @@ export const OPTIONS = handler;`;
848857 outfile,
849858 tsBaseUrl,
850859 tsPaths,
860+ workflowManifest,
851861 } : {
852862 inputFiles : string [ ] ;
853863 outfile : string ;
854864 tsBaseUrl ?: string ;
855865 tsPaths ?: Record < string , string [ ] > ;
866+ workflowManifest ?: WorkflowManifest ;
856867 } ) : Promise < void > {
857868 const graphBuildStart = Date . now ( ) ;
858869 console . log ( 'Creating workflow graph manifest...' ) ;
@@ -867,6 +878,9 @@ export const OPTIONS = handler;`;
867878 return ;
868879 }
869880
881+ // Use provided manifest or fall back to last built manifest
882+ const manifest = workflowManifest || this . lastWorkflowManifest ;
883+
870884 // Import applySwcTransform dynamically
871885 const { applySwcTransform } = await import ( './apply-swc-transform.js' ) ;
872886
@@ -896,7 +910,8 @@ export const OPTIONS = handler;`;
896910 {
897911 paths : tsPaths ,
898912 baseUrl : tsBaseUrl ,
899- }
913+ } ,
914+ manifest
900915 ) ;
901916
902917 if ( graphManifest && graphManifest . workflows ) {
@@ -905,6 +920,11 @@ export const OPTIONS = handler;`;
905920 combinedGraphManifest . workflows ,
906921 graphManifest . workflows
907922 ) ;
923+
924+ // Preserve debug info from the first workflow file (for debugging)
925+ if ( graphManifest . debugInfo && ! combinedGraphManifest . debugInfo ) {
926+ combinedGraphManifest . debugInfo = graphManifest . debugInfo ;
927+ }
908928 }
909929 } catch ( error ) {
910930 console . warn (
0 commit comments