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: 40ab768

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 25, 2025 8:26am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 25, 2025 8:26am
example-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-astro-workflow Error Error Nov 25, 2025 8:26am
workbench-express-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-fastify-workflow Error Error Nov 25, 2025 8:26am
workbench-hono-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-nitro-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workbench-vite-workflow Ready Ready Preview Comment Nov 25, 2025 8:26am
workflow-docs Ready Ready Preview Comment Nov 25, 2025 8:26am

Copy link
Member Author

TooTallNate commented Nov 18, 2025

Copy link
Member Author

TooTallNate commented Nov 25, 2025

Merge activity

  • Nov 25, 8:20 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 25, 8:22 AM UTC: Graphite couldn't merge this PR because it had merge conflicts.
  • Nov 25, 8:25 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 25, 8:25 AM UTC: @TooTallNate merged this pull request with Graphite.

@TooTallNate TooTallNate changed the base branch from swc-closure-scope-var-in-steps to graphite-base/360 November 25, 2025 08:21
@TooTallNate TooTallNate changed the base branch from graphite-base/360 to main November 25, 2025 08:21
@TooTallNate TooTallNate force-pushed the factory-with-step-method branch from 7e5fe40 to 40ab768 Compare November 25, 2025 08:24
@TooTallNate TooTallNate merged commit 8b470f0 into main Nov 25, 2025
42 of 54 checks passed
@TooTallNate TooTallNate deleted the factory-with-step-method branch November 25, 2025 08:25
adriandlam pushed a commit that referenced this pull request Nov 25, 2025
…tion (#360)

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:
```javascript
const myFactory = () => ({
  myStep: async () => {
    'use step';
    await fs.mkdir('test');
  },
});
```

2. 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.
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.

3 participants