-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
43fcd5c
Fix default export workflow function transformation in workflow mode
TooTallNate 35bdf63
.
TooTallNate 0ce10dc
.
TooTallNate aa3b006
.
TooTallNate c829a4b
Merge branch 'main' of github.com:vercel/workflow into fix/gh-367
TooTallNate 1785b4d
.
TooTallNate 69f2826
Apply Vade suggestion
TooTallNate 3243a7b
.
TooTallNate 56bd0c8
Add test fixture for naming conflict
TooTallNate dfa4112
defaultWorkflow -> __default
TooTallNate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@workflow/swc-plugin": patch | ||
| --- | ||
|
|
||
| Fix default export workflow function transformation in workflow mode |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/swc-plugin-workflow/transform/tests/fixture/anonymous-default-workflow/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test anonymous default export workflow | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } | ||
|
|
7 changes: 7 additions & 0 deletions
7
...s/swc-plugin-workflow/transform/tests/fixture/anonymous-default-workflow/output-client.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test anonymous default export workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async function() { | ||
| throw new Error("You attempted to execute workflow __default function directly. To start a workflow, use start(__default) from workflow/api"); | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
7 changes: 7 additions & 0 deletions
7
...ges/swc-plugin-workflow/transform/tests/fixture/anonymous-default-workflow/output-step.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test anonymous default export workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } |
8 changes: 8 additions & 0 deletions
8
...swc-plugin-workflow/transform/tests/fixture/anonymous-default-workflow/output-workflow.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Test anonymous default export workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async function() { | ||
| const result = await someStep(); | ||
| return result; | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
7 changes: 7 additions & 0 deletions
7
packages/swc-plugin-workflow/transform/tests/fixture/default-arrow-workflow/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test default export arrow workflow | ||
| export default async (data) => { | ||
| 'use workflow'; | ||
| const processed = await processData(data); | ||
| return processed; | ||
| }; | ||
|
|
7 changes: 7 additions & 0 deletions
7
packages/swc-plugin-workflow/transform/tests/fixture/default-arrow-workflow/output-client.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test default export arrow workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async (data)=>{ | ||
| throw new Error("You attempted to execute workflow __default function directly. To start a workflow, use start(__default) from workflow/api"); | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
7 changes: 7 additions & 0 deletions
7
packages/swc-plugin-workflow/transform/tests/fixture/default-arrow-workflow/output-step.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test default export arrow workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| export default (async (data)=>{ | ||
| 'use workflow'; | ||
| const processed = await processData(data); | ||
| return processed; | ||
| }); |
8 changes: 8 additions & 0 deletions
8
...ges/swc-plugin-workflow/transform/tests/fixture/default-arrow-workflow/output-workflow.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Test default export arrow workflow | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async (data)=>{ | ||
| const processed = await processData(data); | ||
| return processed; | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
13 changes: 13 additions & 0 deletions
13
packages/swc-plugin-workflow/transform/tests/fixture/default-workflow-collision/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Existing variable named __default | ||
| const __default = "existing variable"; | ||
|
|
||
| // Use it to avoid unused variable | ||
| console.log(__default); | ||
|
|
||
| // Anonymous default export should get unique name (__default$1) | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } | ||
|
|
10 changes: 10 additions & 0 deletions
10
...s/swc-plugin-workflow/transform/tests/fixture/default-workflow-collision/output-client.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Existing variable named __default | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default$1"}}}}*/; | ||
| const __default = "existing variable"; | ||
| // Use it to avoid unused variable | ||
| console.log(__default); | ||
| const __default$1 = async function() { | ||
| throw new Error("You attempted to execute workflow __default$1 function directly. To start a workflow, use start(__default$1) from workflow/api"); | ||
| }; | ||
| __default$1.workflowId = "workflow//input.js//__default$1"; | ||
| export default __default$1; |
11 changes: 11 additions & 0 deletions
11
...ges/swc-plugin-workflow/transform/tests/fixture/default-workflow-collision/output-step.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Existing variable named __default | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default$1"}}}}*/; | ||
| const __default = "existing variable"; | ||
| // Use it to avoid unused variable | ||
| console.log(__default); | ||
| // Anonymous default export should get unique name (__default$1) | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } |
11 changes: 11 additions & 0 deletions
11
...swc-plugin-workflow/transform/tests/fixture/default-workflow-collision/output-workflow.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Existing variable named __default | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default$1"}}}}*/; | ||
| const __default = "existing variable"; | ||
| // Use it to avoid unused variable | ||
| console.log(__default); | ||
| const __default$1 = async function() { | ||
| const result = await someStep(); | ||
| return result; | ||
| }; | ||
| __default$1.workflowId = "workflow//input.js//__default$1"; | ||
| export default __default$1; |
5 changes: 5 additions & 0 deletions
5
packages/swc-plugin-workflow/transform/tests/fixture/expr-fn-default-workflow/input.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } |
6 changes: 6 additions & 0 deletions
6
...ges/swc-plugin-workflow/transform/tests/fixture/expr-fn-default-workflow/output-client.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async function() { | ||
| throw new Error("You attempted to execute workflow __default function directly. To start a workflow, use start(__default) from workflow/api"); | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
6 changes: 6 additions & 0 deletions
6
packages/swc-plugin-workflow/transform/tests/fixture/expr-fn-default-workflow/output-step.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| export default async function() { | ||
| 'use workflow'; | ||
| const result = await someStep(); | ||
| return result; | ||
| } |
7 changes: 7 additions & 0 deletions
7
...s/swc-plugin-workflow/transform/tests/fixture/expr-fn-default-workflow/output-workflow.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /**__internal_workflows{"workflows":{"input.js":{"default":{"workflowId":"workflow//input.js//__default"}}}}*/; | ||
| const __default = async function() { | ||
| const result = await someStep(); | ||
| return result; | ||
| }; | ||
| __default.workflowId = "workflow//input.js//__default"; | ||
| export default __default; |
2 changes: 1 addition & 1 deletion
2
...ges/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-client.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/swc-plugin-workflow/transform/tests/fixture/workflow-client-property/output-step.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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