-
Notifications
You must be signed in to change notification settings - Fork 116
Fix default export workflow function transformation in workflow mode #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed a bug where default export workflow functions with names (e.g., `export default async function testWorkflow()`) would fail at runtime with `ReferenceError: $$default is not defined`. The SWC plugin now correctly keeps the default export as-is and simply adds the workflowId assignment after it, since the function name is available as a binding in the module scope. Fixes #367.
🦋 Changeset detectedLatest commit: dfa4112 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| @@ -0,0 +1,8 @@ | |||
| // Test anonymous default export workflow | |||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//defaultWorkflow"}}}}*/; | |||
| const defaultWorkflow = async function() { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const defaultWorkflow = async function() { | |
| const __default = async function() { |
| defaultWorkflow.workflowId = "workflow//input.js//defaultWorkflow"; | ||
| export default defaultWorkflow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| defaultWorkflow.workflowId = "workflow//input.js//defaultWorkflow"; | |
| export default defaultWorkflow; | |
| defaultWorkflow.workflowId = "workflow//input.js//__default"; | |
| export default __default; |
| @@ -1,5 +1,5 @@ | |||
| // Test workflow functions in client mode | |||
| /**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"defaultWorkflow":{"workflowId":"workflow//input.js//defaultWorkflow"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/; | |||
| /**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"default":{"workflowId":"workflow//input.js//defaultWorkflow"},"internalWorkflow":{"workflowId":"workflow//input.js//internalWorkflow"},"myWorkflow":{"workflowId":"workflow//input.js//myWorkflow"}}}}*/; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a bug no? the function here is called defaultWorkflow
| export default async function defaultWorkflow() { | ||
| return await process(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting case of exporting a named default workflow
Fixed a bug where default export workflow functions with names (e.g.,
export default async function testWorkflow()) would fail at runtime withReferenceError: $$default is not defined. The SWC plugin now correctly keeps the default export as-is and simply adds the workflowId assignment after it, since the function name is available as a binding in the module scope.Also adds support for anonymous and arrow function default exports, which previously were not being transformed at all.
Fixes #367.