Skip to content

Classes with iterators are not tree-shaken #3561

Closed
@devongovett

Description

When a class includes an iterator method using Symbol.iterator, it is no longer tree-shaken when unused.

(() => {
  class Test {
    *[Symbol.iterator]() {
      // do nothing
    }
  }
})()

Example

If you change this to *foo (still a generator function), or a non-generator with a static identifier as a name, it is tree-shaken. I believe this should be safe to tree shake with Symbol.iterator as well. SWC's minifier does so.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions