Skip to content

Conversation

@TooTallNate
Copy link
Member

@TooTallNate TooTallNate commented Nov 18, 2025

Added support for transforming step functions that are returned from factory functions.

What changed?

Enhanced the SWC plugin to detect and transform step functions that are defined within object literals returned by factory functions. The transformation now properly identifies arrow functions with object literal bodies and processes their step functions accordingly.

Added test fixtures to verify the functionality:

  • Created test cases for a factory function that returns an object with a step method
  • Added corresponding output files for client, step, and workflow modes

How to test?

  1. Create a factory function that returns an object with methods marked as steps:
const myFactory = () => ({
  myStep: async () => {
    'use step';
    await fs.mkdir('test');
  },
});
  1. Verify that the step function is properly transformed and registered when used in a workflow.

Why make this change?

This enhancement supports a common pattern where developers create factory functions that return objects containing step methods. Without this change, step functions defined in this pattern weren't being properly transformed, which limited the flexibility of the workflow system.

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: 411677b

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

This PR includes changesets to release 10 packages
Name Type
@workflow/swc-plugin Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/sveltekit Patch
workflow Patch
@workflow/world-testing Patch
@workflow/nuxt Patch
@workflow/ai 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 Nov 18, 2025

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

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 20, 2025 8:10am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 20, 2025 8:10am
example-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-express-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-hono-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-nitro-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workbench-vite-workflow Ready Ready Preview Comment Nov 20, 2025 8:10am
workflow-docs Ready Ready Preview Comment Nov 20, 2025 8:10am

Copy link
Member Author

TooTallNate commented Nov 18, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

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