Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add CommonJS require() support for class serialization detection in SWC plugin#1144

Open
TooTallNate wants to merge 1 commit intomainfrom
02-20-add_commonjs_require_support_for_class_serialization_detection_in_swc_plugin
Open

Add CommonJS require() support for class serialization detection in SWC plugin#1144
TooTallNate wants to merge 1 commit intomainfrom
02-20-add_commonjs_require_support_for_class_serialization_detection_in_swc_plugin

Conversation

@TooTallNate
Copy link
Member

The SWC compiler plugin now detects classes with custom serialization methods (WORKFLOW_SERIALIZE / WORKFLOW_DESERIALIZE) when symbols are obtained via CommonJS require() calls, in addition to the existing ESM import and Symbol.for() patterns.

This handles code that has been pre-compiled from ESM to CommonJS by tools like TypeScript (tsc), esbuild, or tsup, which transform:

import { WORKFLOW_SERIALIZE } from "@workflow/serde"

into either:

const serde_1 = require("@workflow/serde")    // namespace require
const { WORKFLOW_SERIALIZE } = require(...)    // destructured require

Both patterns are now recognized during the identifier collection phase, and classes using them are properly registered with registerSerializationClass().

…WC plugin

The SWC compiler plugin now detects classes with custom serialization methods (`WORKFLOW_SERIALIZE` / `WORKFLOW_DESERIALIZE`) when symbols are obtained via CommonJS `require()` calls, in addition to the existing ESM import and `Symbol.for()` patterns.

This handles code that has been pre-compiled from ESM to CommonJS by tools like TypeScript (tsc), esbuild, or tsup, which transform:

```ts
import { WORKFLOW_SERIALIZE } from "@workflow/serde"
```

into either:

```ts
const serde_1 = require("@workflow/serde")    // namespace require
const { WORKFLOW_SERIALIZE } = require(...)    // destructured require
```

Both patterns are now recognized during the identifier collection phase, and classes using them are properly registered with registerSerializationClass().
@changeset-bot
Copy link

changeset-bot bot commented Feb 20, 2026

🦋 Changeset detected

Latest commit: 3648e46

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@workflow/swc-plugin Patch
@workflow/astro Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/nest Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
workflow Patch
@workflow/vite Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/core Patch
@workflow/web-shared Patch

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

@vercel
Copy link
Contributor

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Feb 20, 2026 10:49pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Feb 20, 2026 10:49pm
example-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-astro-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-express-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-fastify-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-hono-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-nitro-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-nuxt-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workbench-vite-workflow Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Feb 20, 2026 10:49pm
workflow-nest Ready Ready Preview, Comment Feb 20, 2026 10:49pm
workflow-swc-playground Ready Ready Preview, Comment Feb 20, 2026 10:49pm

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
❌ ▲ Vercel Production 522 1 49 572
✅ 💻 Local Development 556 0 68 624
✅ 📦 Local Production 556 0 68 624
✅ 🐘 Local Postgres 556 0 68 624
✅ 🪟 Windows 49 0 3 52
❌ 🌍 Community Worlds 111 45 9 165
✅ 📋 Other 135 0 21 156
Total 2485 46 286 2817

❌ Failed Tests

▲ Vercel Production (1 failed)

example (1 failed):

  • hookWorkflow
🌍 Community Worlds (45 failed)

turso (45 failed):

  • addTenWorkflow
  • addTenWorkflow
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • hookWorkflow
  • webhookWorkflow
  • sleepingWorkflow
  • parallelSleepWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling retry behavior workflow completes despite transient 5xx on step_completed
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • instanceMethodStepWorkflow - instance methods with "use step" directive
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument
  • cancelRun - cancelling a running workflow
  • cancelRun via CLI - cancelling a running workflow
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router

Details by Category

❌ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 47 0 5
❌ example 46 1 5
✅ express 47 0 5
✅ fastify 47 0 5
✅ hono 47 0 5
✅ nextjs-turbopack 50 0 2
✅ nextjs-webpack 50 0 2
✅ nitro 47 0 5
✅ nuxt 47 0 5
✅ sveltekit 47 0 5
✅ vite 47 0 5
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 45 0 7
✅ express-stable 45 0 7
✅ fastify-stable 45 0 7
✅ hono-stable 45 0 7
✅ nextjs-turbopack-canary 49 0 3
✅ nextjs-turbopack-stable 49 0 3
✅ nextjs-webpack-canary 49 0 3
✅ nextjs-webpack-stable 49 0 3
✅ nitro-stable 45 0 7
✅ nuxt-stable 45 0 7
✅ sveltekit-stable 45 0 7
✅ vite-stable 45 0 7
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 45 0 7
✅ express-stable 45 0 7
✅ fastify-stable 45 0 7
✅ hono-stable 45 0 7
✅ nextjs-turbopack-canary 49 0 3
✅ nextjs-turbopack-stable 49 0 3
✅ nextjs-webpack-canary 49 0 3
✅ nextjs-webpack-stable 49 0 3
✅ nitro-stable 45 0 7
✅ nuxt-stable 45 0 7
✅ sveltekit-stable 45 0 7
✅ vite-stable 45 0 7
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 45 0 7
✅ express-stable 45 0 7
✅ fastify-stable 45 0 7
✅ hono-stable 45 0 7
✅ nextjs-turbopack-canary 49 0 3
✅ nextjs-turbopack-stable 49 0 3
✅ nextjs-webpack-canary 49 0 3
✅ nextjs-webpack-stable 49 0 3
✅ nitro-stable 45 0 7
✅ nuxt-stable 45 0 7
✅ sveltekit-stable 45 0 7
✅ vite-stable 45 0 7
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 49 0 3
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 0
✅ mongodb 49 0 3
✅ redis-dev 3 0 0
✅ redis 49 0 3
✅ turso-dev 3 0 0
❌ turso 4 45 3
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 45 0 7
✅ e2e-local-postgres-nest-stable 45 0 7
✅ e2e-local-prod-nest-stable 45 0 7

📋 View full workflow run


Some E2E test jobs failed:

  • Vercel Prod: failure
  • Local Dev: success
  • Local Prod: success
  • Local Postgres: success
  • Windows: success

Check the workflow run for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Express 0.031s (-7.7% 🟢) 1.004s (~) 0.973s 10 1.00x
💻 Local Nitro 0.033s (-2.1%) 1.006s (~) 0.973s 10 1.06x
💻 Local Next.js (Turbopack) 0.044s 1.005s 0.961s 10 1.42x
🌐 Redis Next.js (Turbopack) 0.048s 1.005s 0.957s 10 1.54x
🌐 MongoDB Next.js (Turbopack) 0.095s 1.007s 0.913s 10 3.06x
🐘 Postgres Express 0.118s (+19.6% 🔺) 1.009s (~) 0.891s 10 3.80x
🐘 Postgres Nitro 0.226s (-46.9% 🟢) 1.014s (~) 0.788s 10 7.29x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 0.628s (-8.0% 🟢) 1.896s (-12.5% 🟢) 1.268s 10 1.00x
▲ Vercel Nitro 0.681s (+18.8% 🔺) 2.111s (+24.5% 🔺) 1.430s 10 1.08x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Nitro

workflow with 1 step

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 1.101s 2.005s 0.904s 10 1.00x
💻 Local Express 1.103s (~) 2.005s (~) 0.902s 10 1.00x
🌐 Redis Next.js (Turbopack) 1.105s 2.006s 0.901s 10 1.00x
💻 Local Nitro 1.110s (~) 2.006s (~) 0.896s 10 1.01x
🌐 MongoDB Next.js (Turbopack) 1.318s 2.008s 0.690s 10 1.20x
🐘 Postgres Express 2.446s (-1.2%) 3.014s (~) 0.568s 10 2.22x
🐘 Postgres Nitro 2.459s (+20.5% 🔺) 3.013s (+19.9% 🔺) 0.555s 10 2.23x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 1.971s (-4.6%) 3.035s (-11.3% 🟢) 1.064s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.057s (~) 3.319s (~) 1.262s 10 1.04x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 10 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 10.718s 11.022s 0.304s 3 1.00x
💻 Local Next.js (Turbopack) 10.739s 11.023s 0.284s 3 1.00x
💻 Local Express 10.815s (~) 11.022s (~) 0.207s 3 1.01x
💻 Local Nitro 10.853s (~) 11.023s (~) 0.171s 3 1.01x
🌐 MongoDB Next.js (Turbopack) 12.210s 13.022s 0.812s 3 1.14x
🐘 Postgres Nitro 20.341s (+34.1% 🔺) 21.059s (+31.2% 🔺) 0.718s 2 1.90x
🐘 Postgres Express 20.358s (~) 21.058s (~) 0.700s 2 1.90x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 15.623s (~) 16.884s (-1.4%) 1.261s 2 1.00x
▲ Vercel Next.js (Turbopack) 15.805s (-1.4%) 16.849s (-4.2%) 1.044s 2 1.01x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 25 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 26.969s 27.051s 0.081s 3 1.00x
💻 Local Next.js (Turbopack) 27.172s 28.051s 0.879s 3 1.01x
💻 Local Express 27.432s (~) 28.049s (~) 0.617s 3 1.02x
💻 Local Nitro 27.639s (~) 28.054s (~) 0.416s 3 1.02x
🌐 MongoDB Next.js (Turbopack) 30.566s 31.043s 0.477s 2 1.13x
🐘 Postgres Nitro 49.617s (+22.5% 🔺) 50.122s (+23.4% 🔺) 0.505s 2 1.84x
🐘 Postgres Express 50.364s (~) 51.126s (~) 0.761s 2 1.87x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 39.014s (+0.5%) 40.272s (~) 1.258s 2 1.00x
▲ Vercel Next.js (Turbopack) 41.381s (+2.3%) 42.665s (+2.2%) 1.284s 2 1.06x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

workflow with 50 sequential steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 54.364s 55.099s 0.735s 2 1.00x
💻 Local Next.js (Turbopack) 56.453s 57.101s 0.648s 2 1.04x
💻 Local Express 57.004s (~) 57.098s (-1.7%) 0.095s 2 1.05x
💻 Local Nitro 57.367s (~) 58.100s (~) 0.733s 2 1.06x
🌐 MongoDB Next.js (Turbopack) 61.269s 62.087s 0.818s 2 1.13x
🐘 Postgres Nitro 76.002s (-6.9% 🟢) 76.667s (-6.7% 🟢) 0.665s 2 1.40x
🐘 Postgres Express 100.264s (~) 101.234s (~) 0.970s 1 1.84x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 79.127s (-16.7% 🟢) 79.644s (-17.6% 🟢) 0.517s 2 1.00x
▲ Vercel Next.js (Turbopack) 83.029s (-11.7% 🟢) 84.469s (-11.5% 🟢) 1.440s 2 1.05x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.248s 2.006s 0.759s 15 1.00x
💻 Local Express 1.403s (~) 2.004s (~) 0.601s 15 1.12x
💻 Local Next.js (Turbopack) 1.406s 2.005s 0.599s 15 1.13x
💻 Local Nitro 1.408s (+1.6%) 2.006s (~) 0.598s 15 1.13x
🌐 MongoDB Next.js (Turbopack) 2.147s 3.008s 0.862s 10 1.72x
🐘 Postgres Nitro 2.263s (+5.6% 🔺) 2.740s (-6.4% 🟢) 0.478s 11 1.81x
🐘 Postgres Express 2.295s (+0.8%) 3.014s (~) 0.718s 10 1.84x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.129s (-3.5%) 3.198s (-12.8% 🟢) 1.070s 10 1.00x
▲ Vercel Next.js (Turbopack) 2.483s (-14.8% 🟢) 3.738s (-16.2% 🟢) 1.255s 9 1.17x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 2.436s 2.826s 0.390s 11 1.00x
💻 Local Express 2.500s (-1.5%) 3.007s (~) 0.507s 10 1.03x
🌐 Redis Next.js (Turbopack) 2.510s 3.008s 0.498s 10 1.03x
💻 Local Nitro 2.655s (+8.8% 🔺) 3.008s (~) 0.353s 10 1.09x
🌐 MongoDB Next.js (Turbopack) 4.740s 5.179s 0.439s 6 1.95x
🐘 Postgres Express 8.002s (-6.6% 🟢) 8.528s (-8.2% 🟢) 0.527s 4 3.28x
🐘 Postgres Nitro 9.712s (-14.1% 🟢) 10.364s (-11.5% 🟢) 0.652s 3 3.99x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 3.410s (+35.0% 🔺) 4.348s (+14.0% 🔺) 0.937s 7 1.00x
▲ Vercel Next.js (Turbopack) 3.529s (+35.1% 🔺) 5.044s (+31.7% 🔺) 1.515s 6 1.03x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.all with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 4.072s 5.011s 0.939s 6 1.00x
💻 Local Next.js (Turbopack) 5.897s 6.414s 0.517s 5 1.45x
💻 Local Express 6.897s (-6.3% 🟢) 7.017s (-12.5% 🟢) 0.121s 5 1.69x
💻 Local Nitro 7.643s (+13.9% 🔺) 8.020s (+14.3% 🔺) 0.377s 4 1.88x
🌐 MongoDB Next.js (Turbopack) 9.901s 10.351s 0.450s 3 2.43x
🐘 Postgres Nitro 44.577s (-6.6% 🟢) 45.127s (-6.2% 🟢) 0.550s 1 10.95x
🐘 Postgres Express 46.455s (-6.9% 🟢) 47.124s (-6.0% 🟢) 0.669s 1 11.41x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 3.462s (-2.7%) 4.286s (-9.3% 🟢) 0.824s 8 1.00x
▲ Vercel Next.js (Turbopack) 3.518s (+1.5%) 4.673s (+3.3%) 1.155s 7 1.02x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Promise.race with 10 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 1.254s 2.006s 0.751s 15 1.00x
💻 Local Express 1.398s (-2.0%) 2.004s (~) 0.606s 15 1.11x
💻 Local Next.js (Turbopack) 1.401s 2.005s 0.604s 15 1.12x
💻 Local Nitro 1.430s (+1.4%) 2.004s (~) 0.574s 15 1.14x
🐘 Postgres Nitro 1.986s (-6.6% 🟢) 2.741s (+2.2%) 0.755s 11 1.58x
🌐 MongoDB Next.js (Turbopack) 2.134s 3.009s 0.874s 10 1.70x
🐘 Postgres Express 2.177s (-1.8%) 2.741s (+5.6% 🔺) 0.565s 11 1.74x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.071s (-9.4% 🟢) 3.491s (-3.7%) 1.420s 9 1.00x
▲ Vercel Nitro 3.592s (+38.4% 🔺) 4.591s (+18.8% 🔺) 1.000s 7 1.73x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Nitro

Promise.race with 25 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 2.482s 3.008s 0.526s 10 1.00x
💻 Local Next.js (Turbopack) 2.512s 3.007s 0.496s 10 1.01x
💻 Local Express 2.623s (-2.5%) 3.008s (~) 0.385s 10 1.06x
💻 Local Nitro 2.693s (+3.0%) 3.007s (~) 0.313s 10 1.09x
🌐 MongoDB Next.js (Turbopack) 4.805s 5.177s 0.372s 6 1.94x
🐘 Postgres Nitro 10.237s (-3.2%) 10.696s (-5.9% 🟢) 0.458s 3 4.12x
🐘 Postgres Express 12.565s (+3.3%) 13.043s (+5.4% 🔺) 0.478s 3 5.06x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Next.js (Turbopack) 2.364s (-7.5% 🟢) 3.951s (+5.7% 🔺) 1.587s 8 1.00x
▲ Vercel Nitro 2.513s (+10.3% 🔺) 3.377s (-4.9%) 0.864s 9 1.06x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Next.js (Turbopack) | Nitro

Promise.race with 50 concurrent steps

💻 Local Development

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
🌐 Redis 🥇 Next.js (Turbopack) 4.038s 4.726s 0.688s 7 1.00x
💻 Local Next.js (Turbopack) 6.631s 7.217s 0.586s 5 1.64x
💻 Local Express 7.478s (-3.3%) 8.017s (~) 0.539s 4 1.85x
💻 Local Nitro 8.062s (+8.7% 🔺) 8.774s (+9.4% 🔺) 0.712s 4 2.00x
🌐 MongoDB Next.js (Turbopack) 9.955s 10.685s 0.731s 3 2.47x
🐘 Postgres Express 52.393s (+4.4%) 53.133s (+3.9%) 0.740s 1 12.97x
🐘 Postgres Nitro 52.548s (+9.4% 🔺) 53.105s (+10.3% 🔺) 0.557s 1 13.01x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - -

▲ Production (Vercel)

World Framework Workflow Time Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 2.818s (~) 3.489s (-13.6% 🟢) 0.671s 9 1.00x
▲ Vercel Next.js (Turbopack) 4.399s (+24.9% 🔺) 6.430s (+41.8% 🔺) 2.031s 6 1.56x
▲ Vercel Express ⚠️ missing - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Stream Benchmarks (includes TTFB metrics)
workflow with stream

💻 Local Development

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
💻 Local 🥇 Next.js (Turbopack) 0.148s 1.001s 0.010s 1.015s 0.867s 10 1.00x
🌐 Redis Next.js (Turbopack) 0.157s 1.000s 0.002s 1.007s 0.850s 10 1.06x
💻 Local Express 0.171s (-2.4%) 1.002s (~) 0.011s (~) 1.015s (~) 0.844s 10 1.15x
💻 Local Nitro 0.173s (-3.1%) 1.003s (~) 0.011s (+12.7% 🔺) 1.017s (~) 0.844s 10 1.17x
🌐 MongoDB Next.js (Turbopack) 0.504s 0.944s 0.001s 1.009s 0.505s 10 3.39x
🐘 Postgres Nitro 1.347s (+17.1% 🔺) 1.692s (-10.8% 🟢) 0.001s (~) 2.012s (~) 0.665s 10 9.07x
🐘 Postgres Express 2.377s (+1.0%) 2.665s (-0.9%) 0.001s (-7.1% 🟢) 3.014s (~) 0.637s 10 16.01x
🐘 Postgres Next.js (Turbopack) ⚠️ missing - - - - -

▲ Production (Vercel)

World Framework Workflow Time TTFB Slurp Wall Time Overhead Samples vs Fastest
▲ Vercel 🥇 Nitro 1.458s (-30.7% 🟢) 2.160s (-21.5% 🟢) 0.154s (-13.0% 🟢) 2.689s (-22.9% 🟢) 1.231s 10 1.00x
▲ Vercel Next.js (Turbopack) 1.631s (-5.4% 🟢) 2.160s (-9.4% 🟢) 0.216s (+54.6% 🔺) 32.850s (+964.7% 🔺) 31.220s 10 1.12x
▲ Vercel Express ⚠️ missing - - - - -

🔍 Observability: Nitro | Next.js (Turbopack)

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World 🥇 Fastest Framework Wins
💻 Local Next.js (Turbopack) 9/12
🐘 Postgres Nitro 8/12
▲ Vercel Nitro 9/12
Fastest World by Framework

Winner determined by most benchmark wins

Framework 🥇 Fastest World Wins
Express 💻 Local 12/12
Next.js (Turbopack) 🌐 Redis 6/12
Nitro 💻 Local 9/12
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TooTallNate TooTallNate marked this pull request as ready for review February 20, 2026 22:47
Copilot AI review requested due to automatic review settings February 20, 2026 22:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the @workflow/swc-plugin transform to detect custom class serialization methods when the WORKFLOW_SERIALIZE / WORKFLOW_DESERIALIZE symbols are accessed via CommonJS require() patterns, aligning behavior with codebases that have been transpiled from ESM to CJS.

Changes:

  • Track CommonJS require() bindings during identifier collection (namespace const x = require(...) and destructured const { ... } = require(...)) and recognize x.WORKFLOW_SERIALIZE / x.WORKFLOW_DESERIALIZE as serialization symbols.
  • Add fixture coverage for both namespace-require and destructured-require inputs across workflow/step/client outputs.
  • Update the plugin spec and add a changeset entry documenting the new behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/swc-plugin-workflow/transform/src/lib.rs Adds require-binding tracking and member-expression symbol recognition for serialization detection.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-namespace/input.js New fixture input for namespace require() pattern.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-namespace/output-workflow.js Expected workflow-mode output for namespace require() fixture.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-namespace/output-step.js Expected step-mode output for namespace require() fixture.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-namespace/output-client.js Expected client-mode output for namespace require() fixture.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-destructured/input.js New fixture input for destructured require() pattern.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-destructured/output-workflow.js Expected workflow-mode output for destructured require() fixture.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-destructured/output-step.js Expected step-mode output for destructured require() fixture.
packages/swc-plugin-workflow/transform/tests/fixture/custom-serialization-require-destructured/output-client.js Expected client-mode output for destructured require() fixture.
packages/swc-plugin-workflow/spec.md Documents supported CommonJS require() symbol patterns.
.changeset/social-forks-tease.md Declares a patch release for the new detection behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2500 to +2507
/// Check if an expression is a `require(...)` call.
/// Returns true for any `require('...')` or `require("...")` call expression.
fn is_require_call(&self, expr: &Expr) -> bool {
if let Expr::Call(call) = expr {
if let Callee::Expr(callee) = &call.callee {
if let Expr::Ident(ident) = &**callee {
return ident.sym.as_str() == "require" && !call.args.is_empty();
}
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_require_call docstring says it returns true for require('...') / require("..."), but the implementation returns true for any require(...) call as long as it has at least one argument (including non-string / dynamic requires). Either tighten the implementation to check call.args.len() == 1 and the first arg is a string literal, or update the docstring to match the broader behavior (and consider whether dynamic requires should be tracked here).

Copilot uses AI. Check for mistakes.
Comment on lines 1329 to +1356
Decl::Var(var_decl) => {
for declarator in &var_decl.decls {
self.collect_idents_from_pat(&declarator.name);
// Track const declarations that assign Symbol.for('workflow-serialize') or Symbol.for('workflow-deserialize')
if let Pat::Ident(ident) = &declarator.name {
if let Some(init) = &declarator.init {
if let Some(symbol_name) = self.extract_symbol_for_name(init) {
if let Some(init) = &declarator.init {
// Track const declarations that assign Symbol.for('workflow-serialize') or Symbol.for('workflow-deserialize')
if let Pat::Ident(ident) = &declarator.name {
if let Some(symbol_name) =
self.extract_symbol_for_name(init)
{
if symbol_name == "workflow-serialize"
|| symbol_name == "workflow-deserialize"
{
self.serialization_symbol_identifiers
.insert(ident.id.sym.to_string(), symbol_name);
}
}
// Track CommonJS namespace require: const serde_1 = require("...")
if self.is_require_call(init) {
self.require_namespace_identifiers
.insert(ident.id.sym.to_string());
}
}
// Track CommonJS destructured require:
// const { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } = require("...")
if let Pat::Object(obj_pat) = &declarator.name {
if self.is_require_call(init) {
for prop in &obj_pat.props {
match prop {
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CommonJS require tracking logic (namespace + destructured patterns) is duplicated for Decl::Var and for ModuleDecl::ExportDecl(Decl::Var) in collect_declared_identifiers. Consider extracting a small helper that inspects a VarDeclarator (pattern + init) and updates serialization_symbol_identifiers / require_namespace_identifiers once, to reduce the chance these two branches drift over time.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants