fix(preset-env): Include iterator helpers polyfills without shippedProposals #11012
+0
−0
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.
Iterator helper methods are now part of the ECMAScript 2025 specification and should be included in polyfills by default, without requiring the
shippedProposals
option to be enabled.Problem
Previously, code using iterator helpers like
x.find()
would not include the necessary polyfills unlessshippedProposals: true
was explicitly set in the preset-env configuration:This behavior was inconsistent with Babel's preset-env, which updated their database to include iterator helpers by default (see babel/babel-polyfills#223).
Solution
Modified the polyfill injection logic in
crates/swc_ecma_preset_env/src/corejs3/usage.rs
to allow iterator helper modules (esnext.iterator.*
andesnext.async-iterator.*
) even whenshippedProposals
is disabled.The fix adds a special case for iterator helpers:
Result
Now iterator helper usage automatically includes the necessary polyfills:
This works with the standard configuration without requiring
shippedProposals: true
:Testing
shippedProposals
Fixes #11010
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.