Skip to content

Commit

Permalink
Exclude Set instance methods from polyfills (WordPress#67230)
Browse files Browse the repository at this point in the history
* Exclude Set instance methods from polyfills

* Switch to regexp exclusions
  • Loading branch information
sgomes authored and im3dabasia committed Dec 4, 2024
1 parent 8f6820a commit 4271d44
Showing 1 changed file with 21 additions and 0 deletions.
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\./,
];

0 comments on commit 4271d44

Please sign in to comment.