Enable custom class serialization transformations for "client" mode#860
Conversation
🦋 Changeset detectedLatest commit: 1a72c70 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests💻 Local Development (2 failed)astro-stable (2 failed):
🌍 Community Worlds (161 failed)mongodb (40 failed):
redis (40 failed):
starter (41 failed):
turso (40 failed):
Details by Category✅ ▲ Vercel Production
❌ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
2eb0768 to
ebe0f20
Compare
08e6829 to
4498ca1
Compare
There was a problem hiding this comment.
Pull request overview
This PR enables custom class serialization transformations for "client" mode in the SWC plugin. Previously, class serialization was only handled in workflow and step modes. This change ensures that classes with custom serialization methods can be properly serialized when passed from client code to workflow functions via start(workflow) calls.
Changes:
- Added import generation for
registerSerializationClassin client mode when classes need serialization - Added registration call generation for classes in client mode (both Module and Script cases)
- Updated test fixtures to reflect the new client mode behavior with serialization imports and registration calls
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/swc-plugin-workflow/transform/src/lib.rs | Added logic to generate serialization imports and registration calls for client mode in both Module and Script cases |
| packages/swc-plugin-workflow/transform/tests/fixture/static-method-step/output-client.js | Added expected import and registration call for MyService class |
| packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization/output-client.js | Added expected import and registration call for Point class |
| packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-local-const/output-client.js | Added expected import and registration calls for Circle, Rectangle, and Triangle classes |
| packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-imported/output-client.js | Added expected import and registration calls for Color and Vector classes |
| packages/swc-plugin-workflow/transform/tests/errors/instance-methods/output-client.js | Added expected import and registration call for TestClass |
| .changeset/modern-clubs-own.md | Added changeset documenting this patch change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ijjk
left a comment
There was a problem hiding this comment.
Seems good but the deduplication callout from copilot does seem good as well
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
Address code review feedback from Copilot and ijjk: - Extract duplicated class serialization registration logic into create_class_serialization_registration() helper method - Reduces code duplication across workflow mode, client mode (Module), and client mode (Script) cases - Add consistent comment explaining why client mode needs registration - Update spec.md to document custom serialization in client mode

Enable class serialization in client mode to support passing class instances to workflow functions.
What changed?
registerSerializationClassfrom "workflow/internal/class-serialization"How to test?
WORKFLOW_SERIALIZEandWORKFLOW_DESERIALIZEsymbols)Why make this change?
Previously, class serialization was only enabled in workflow mode, which meant that classes couldn't be properly serialized when passed from client code to workflow functions. This change ensures that classes with custom serialization methods work correctly when used as arguments to
start(workflow)calls from client code.