You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add discovered serializable classes in all context modes (#874)
This PR ensures that all classes with custom serialization are automatically included in all bundle contexts (step, workflow, client) to ensure proper serialization/deserialization when crossing execution boundaries:
- Classes defined in any context can now be properly serialized when passing data between:
- Client → Workflow (when starting workflows)
- Workflow → Step (when calling steps)
- Step → Workflow (when returning step results)
- Workflow → Client (when returning workflow results)
- The build system now automatically discovers all files containing serializable classes and includes them in each bundle, regardless of where the class is originally defined.
- No manual configuration is required - cross-registration happens automatically during the build process.
Copy file name to clipboardExpand all lines: packages/swc-plugin-workflow/spec.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -537,6 +537,26 @@ Files containing classes with custom serialization are automatically discovered
537
537
538
538
This allows serialization classes to be defined in separate files (such as Next.js API routes or utility modules) and still be registered in the serialization system when the application is built.
539
539
540
+
### Cross-Context Class Registration
541
+
542
+
Classes with custom serialization are automatically included in **all bundle contexts** (step, workflow, client) to ensure they can be properly serialized and deserialized when crossing execution boundaries:
543
+
544
+
| Boundary | Serializer | Deserializer | Example |
| Client → Workflow | Client mode | Workflow mode | Passing a `Point` instance to `start(workflow)`|
547
+
| Workflow → Step | Workflow mode | Step mode | Passing a `Point` instance as step argument |
548
+
| Step → Workflow | Step mode | Workflow mode | Returning a `Point` instance from a step |
549
+
| Workflow → Client | Workflow mode | Client mode | Returning a `Point` instance from a workflow |
550
+
551
+
The build system automatically discovers all files containing serializable classes and includes them in each bundle, regardless of where the class is originally defined. This ensures the class registry has all necessary classes for any serialization boundary the data may cross.
552
+
553
+
For example, if a class `Point` is defined in `models/point.ts` and only used in step code:
554
+
- The **step bundle** includes `Point` because the step file imports it
555
+
- The **workflow bundle** also includes `Point` so it can deserialize step return values
556
+
- The **client bundle** also includes `Point` so it can deserialize workflow return values
557
+
558
+
This cross-registration happens automatically during the build process - no manual configuration is required.
0 commit comments