Files
vercel__workflow/.changeset/private-member-dce.md
Nathan Rajlich 66585fd467 feat(swc): dead code eliminate unreferenced private class members in workflow mode (#1671)
* feat(swc): dead code eliminate unreferenced private class members in workflow mode

After stripping 'use step' methods from a class body in workflow mode,
eliminate private members (both JS native #field/#method and TypeScript
private field/private method) that are no longer referenced by any
remaining public member.

The algorithm is iterative: references are seeded from public members,
then expanded through surviving private members until a fixed point,
enabling cascading elimination (e.g. a private field only referenced by
a private method that is itself unreferenced).

* test(swc): add fixture for JS native private member DCE (#field, #method)

* fix(swc): address review feedback on private member DCE

- Namespace JS native private names with # prefix to avoid collisions
  with TS private members of the same name
- Track TS private member accesses on non-this receivers (e.g. a.x in
  static methods) by maintaining a set of known TS-private names
- Use visit_children_with for full traversal including computed member
  expressions
- Extract retain logic into shared retain_referenced_private_members()
  helper used by both visit_mut_class_decl and visit_mut_class_expr
2026-04-09 12:27:06 -07:00

130 B

@workflow/swc-plugin
@workflow/swc-plugin
patch

Eliminate unreferenced private class members in workflow mode after "use step" stripping