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

Exclude Set instance methods from polyfills #67230

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/babel-preset-default/polyfill-exclusions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,25 @@ module.exports = [
// This is an IE-only feature which we don't use, and don't want to polyfill.
// @see https://github.com/WordPress/gutenberg/pull/49234
'web.immediate',
// Remove Set feature polyfills.
//
// The Babel/core-js integration has a severe limitation, in that any Set
// objects (e.g. `new Set()`) are assumed to need all instance methods, and
// get them all polyfilled. There is no validation as to whether those
// methods are actually in use.
//
// This limitation causes a number of packages to unnecessarily get a
// dependency on `wp-polyfill`, which in most cases gets loaded as part of
// the critical path and can thus have an impact on performance.
//
// There is no good solution to this, and the one we've opted for here is
// to disable polyfilling these features entirely. Developers will need to
// take care not to use them in scenarios where the code may be running in
// older browsers without native support for them.
//
// These need to be specified as both `es.` and `esnext.` due to the way
// internal dependencies are set up in Babel / core-js.
//
// @see https://github.com/WordPress/gutenberg/pull/67230
/^es(next)?\.set\./,
];
Loading