@@ -7,7 +7,7 @@ import enhancedResolveOriginal from 'enhanced-resolve';
77import * as esbuild from 'esbuild' ;
88import { findUp } from 'find-up' ;
99import { glob } from 'tinyglobby' ;
10- import type { GraphManifest , WorkflowManifest } from './apply-swc-transform.js' ;
10+ import type { WorkflowManifest } from './apply-swc-transform.js' ;
1111import { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js' ;
1212import { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js' ;
1313import { createSwcPlugin } from './swc-esbuild-plugin.js' ;
@@ -849,100 +849,41 @@ export const OPTIONS = handler;`;
849849 }
850850
851851 /**
852- * Creates a graph manifest JSON file by running the SWC plugin in 'graph' mode .
852+ * Creates a graph manifest JSON file by extracting from the bundled workflow file .
853853 * The manifest contains React Flow-compatible graph data for visualizing workflows.
854854 */
855855 protected async createGraphManifest ( {
856- inputFiles ,
856+ workflowBundlePath ,
857857 outfile,
858- tsBaseUrl,
859- tsPaths,
860- workflowManifest,
861858 } : {
862- inputFiles : string [ ] ;
859+ workflowBundlePath : string ;
863860 outfile : string ;
864- tsBaseUrl ?: string ;
865- tsPaths ?: Record < string , string [ ] > ;
866- workflowManifest ?: WorkflowManifest ;
867861 } ) : Promise < void > {
868862 const graphBuildStart = Date . now ( ) ;
869863 console . log ( 'Creating workflow graph manifest...' ) ;
870864
871- const { discoveredWorkflows : workflowFiles } = await this . discoverEntries (
872- inputFiles ,
873- dirname ( outfile )
874- ) ;
875-
876- if ( workflowFiles . length === 0 ) {
877- console . log ( 'No workflow files found, skipping graph generation' ) ;
878- return ;
879- }
880-
881- // Use provided manifest or fall back to last built manifest
882- const manifest = workflowManifest || this . lastWorkflowManifest ;
883-
884- // Import applySwcTransform dynamically
885- const { applySwcTransform } = await import ( './apply-swc-transform.js' ) ;
886-
887- // Aggregate all graph data from all workflow files
888- const combinedGraphManifest : GraphManifest = {
889- version : '1.0.0' ,
890- workflows : { } ,
891- } ;
892-
893- for ( const workflowFile of workflowFiles ) {
894- try {
895- const source = await readFile ( workflowFile , 'utf-8' ) ;
896- const normalizedWorkingDir = this . config . workingDir . replace ( / \\ / g, '/' ) ;
897- const normalizedFile = workflowFile . replace ( / \\ / g, '/' ) ;
898- let relativePath = relative (
899- normalizedWorkingDir ,
900- normalizedFile
901- ) . replace ( / \\ / g, '/' ) ;
902- if ( ! relativePath . startsWith ( '.' ) ) {
903- relativePath = `./${ relativePath } ` ;
904- }
865+ try {
866+ // Import the graph extractor
867+ const { extractGraphFromBundle } = await import ( './graph-extractor.js' ) ;
905868
906- const { graphManifest } = await applySwcTransform (
907- relativePath ,
908- source ,
909- 'graph' ,
910- {
911- paths : tsPaths ,
912- baseUrl : tsBaseUrl ,
913- } ,
914- manifest
915- ) ;
869+ // Extract graph from the bundled workflow file
870+ const graphManifest = await extractGraphFromBundle ( workflowBundlePath ) ;
916871
917- if ( graphManifest && graphManifest . workflows ) {
918- // Merge the workflows from this file into the combined manifest
919- Object . assign (
920- combinedGraphManifest . workflows ,
921- graphManifest . workflows
922- ) ;
872+ // Write the graph manifest
873+ await this . ensureDirectory ( outfile ) ;
874+ await writeFile ( outfile , JSON . stringify ( graphManifest , null , 2 ) ) ;
923875
924- // Preserve debug info from the first workflow file (for debugging)
925- if ( graphManifest . debugInfo && ! combinedGraphManifest . debugInfo ) {
926- combinedGraphManifest . debugInfo = graphManifest . debugInfo ;
927- }
928- }
929- } catch ( error ) {
930- console . warn (
931- `Failed to extract graph from ${ workflowFile } :` ,
932- error instanceof Error ? error . message : String ( error )
933- ) ;
934- }
876+ console . log (
877+ `Created graph manifest with $ {
878+ Object . keys ( graphManifest . workflows ) . length
879+ } workflow(s)` ,
880+ ` ${ Date . now ( ) - graphBuildStart } ms`
881+ ) ;
882+ } catch ( error ) {
883+ console . warn (
884+ 'Failed to extract graph from bundle:' ,
885+ error instanceof Error ? error . message : String ( error )
886+ ) ;
935887 }
936-
937- // Write the combined graph manifest
938- await this . ensureDirectory ( outfile ) ;
939- await writeFile ( outfile , JSON . stringify ( combinedGraphManifest , null , 2 ) ) ;
940-
941- console . log (
942- `Created graph manifest with ${
943- Object . keys ( combinedGraphManifest . workflows ) . length
944- } workflow(s)`,
945- `${ Date . now ( ) - graphBuildStart } ms`
946- ) ;
947888 }
948889}
0 commit comments