Skip to content
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

Classes with iterators are not tree-shaken #3561

Closed
devongovett opened this issue Dec 23, 2023 · 1 comment
Closed

Classes with iterators are not tree-shaken #3561

devongovett opened this issue Dec 23, 2023 · 1 comment

Comments

@devongovett
Copy link

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.

@evanw
Copy link
Owner

evanw commented Dec 23, 2023

Thanks for pointing this out. That’s obviously not great, and should be safe to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants