Skip to content

Commit 0757912

Browse files
committed
.
1 parent 7f25b9d commit 0757912

File tree

8 files changed

+0
-69
lines changed

8 files changed

+0
-69
lines changed

packages/swc-plugin-workflow/transform/src/lib.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,13 +2292,6 @@ impl StepTransform {
22922292
ModuleItem::Stmt(Stmt::Decl(Decl::Var(var_decl))) => {
22932293
// Check if all variables in this declaration are unused
22942294
var_decl.decls.iter().all(|declarator| {
2295-
// Don't remove if the initializer contains functions (which might have directives)
2296-
if let Some(init) = &declarator.init {
2297-
if self.contains_function_expr(init) {
2298-
return false;
2299-
}
2300-
}
2301-
23022295
match &declarator.name {
23032296
Pat::Ident(binding) => {
23042297
let name = binding.id.sym.to_string();
@@ -2393,20 +2386,6 @@ impl StepTransform {
23932386
}
23942387
}
23952388

2396-
// Helper to check if an expression contains a function expression or object with methods
2397-
fn contains_function_expr(&self, expr: &Expr) -> bool {
2398-
match expr {
2399-
Expr::Fn(_) | Expr::Arrow(_) => true,
2400-
Expr::Object(obj_lit) => {
2401-
// Check if object contains any method properties
2402-
obj_lit.props.iter().any(
2403-
|prop| matches!(prop, PropOrSpread::Prop(p) if matches!(&**p, Prop::Method(_))),
2404-
)
2405-
}
2406-
_ => false,
2407-
}
2408-
}
2409-
24102389
// Helper to check if all bindings in an array pattern are unused
24112390
fn all_bindings_unused(
24122391
&self,

packages/swc-plugin-workflow/transform/tests/errors/non-async-functions/output-client.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ export const syncWorkflow = ()=>{
99
'use workflow';
1010
return 'test';
1111
};
12-
// Error: sync method with use step
13-
const obj = {
14-
syncMethod () {
15-
'use step';
16-
return true;
17-
}
18-
};
1912
// These are ok
2013
export async function validStep() {
2114
return 42;

packages/swc-plugin-workflow/transform/tests/errors/non-async-functions/output-workflow.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ export const syncWorkflow = ()=>{
99
'use workflow';
1010
return 'test';
1111
};
12-
// Error: sync method with use step
13-
const obj = {
14-
syncMethod () {
15-
'use step';
16-
return true;
17-
}
18-
};
1912
// These are ok
2013
export var validStep = globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//validStep");
2114
export const validWorkflow = async ()=>{

packages/swc-plugin-workflow/transform/tests/fixture/module-level-step/output-client.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/**__internal_workflows{"steps":{"input.js":{"step":{"stepId":"step//input.js//step"},"stepArrow":{"stepId":"step//input.js//stepArrow"}}}}*/;
2-
const localArrow = async (input)=>{
3-
return input.bar;
4-
};
52
export async function step(input) {
63
return input.foo;
74
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/**__internal_workflows{"steps":{"input.js":{"step":{"stepId":"step//input.js//step"},"stepArrow":{"stepId":"step//input.js//stepArrow"}}}}*/;
22
'use step';
3-
const localArrow = async (input)=>{
4-
return input.bar;
5-
};
63
export var step = globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//step");
74
export const stepArrow = globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//stepArrow");

packages/swc-plugin-workflow/transform/tests/fixture/module-level-workflow/output-client.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"workflow":{"workflowId":"workflow//input.js//workflow"}}}}*/;
2-
const localArrow = async (input)=>{
3-
return input.bar;
4-
};
52
export async function workflow(input) {
63
return input.foo;
74
}

packages/swc-plugin-workflow/transform/tests/fixture/module-level-workflow/output-workflow.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
/**__internal_workflows{"workflows":{"input.js":{"arrowWorkflow":{"workflowId":"workflow//input.js//arrowWorkflow"},"workflow":{"workflowId":"workflow//input.js//workflow"}}}}*/;
2-
const localArrow = async (input)=>{
3-
return input.bar;
4-
};
52
export async function workflow(input) {
63
return input.foo;
74
}

packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-client.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
11
/**__internal_workflows{"workflows":{"input.js":{"wflow":{"workflowId":"workflow//input.js//wflow"}}},"steps":{"input.js":{"_anonymousStep0":{"stepId":"step//input.js//_anonymousStep0"},"_anonymousStep1":{"stepId":"step//input.js//_anonymousStep1"},"f":{"stepId":"step//input.js//f"},"fn":{"stepId":"step//input.js//fn"}}}}*/;
2-
const arrowWrapperReturnArrowFunctionVar = (a, b, c)=>{
3-
const fn = async ()=>{
4-
return a + b + c;
5-
};
6-
return fn;
7-
};
8-
const arrowWrapperReturnNamedFunction = (a, b, c)=>{
9-
return async function f() {
10-
return a + b + c;
11-
};
12-
};
13-
const arrowWrapperReturnArrowFunction = (a, b, c)=>{
14-
return async ()=>{
15-
return a + b + c;
16-
};
17-
};
18-
const arrowWrapperReturnNamedFunctionVar = (a, b, c)=>{
19-
async function fn() {
20-
return a + b + c;
21-
}
22-
return fn;
23-
};
242
export async function wflow() {
253
throw new Error("You attempted to execute workflow wflow function directly. To start a workflow, use start(wflow) from workflow/api");
264
}

0 commit comments

Comments
 (0)