Skip to content

Commit 1c3cea4

Browse files
authored
Exclude Set instance methods from polyfills (#67230)
* Exclude Set instance methods from polyfills * Switch to regexp exclusions
1 parent 0ff919f commit 1c3cea4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/babel-preset-default/polyfill-exclusions.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,25 @@ module.exports = [
77
// This is an IE-only feature which we don't use, and don't want to polyfill.
88
// @see https://github.com/WordPress/gutenberg/pull/49234
99
'web.immediate',
10+
// Remove Set feature polyfills.
11+
//
12+
// The Babel/core-js integration has a severe limitation, in that any Set
13+
// objects (e.g. `new Set()`) are assumed to need all instance methods, and
14+
// get them all polyfilled. There is no validation as to whether those
15+
// methods are actually in use.
16+
//
17+
// This limitation causes a number of packages to unnecessarily get a
18+
// dependency on `wp-polyfill`, which in most cases gets loaded as part of
19+
// the critical path and can thus have an impact on performance.
20+
//
21+
// There is no good solution to this, and the one we've opted for here is
22+
// to disable polyfilling these features entirely. Developers will need to
23+
// take care not to use them in scenarios where the code may be running in
24+
// older browsers without native support for them.
25+
//
26+
// These need to be specified as both `es.` and `esnext.` due to the way
27+
// internal dependencies are set up in Babel / core-js.
28+
//
29+
// @see https://github.com/WordPress/gutenberg/pull/67230
30+
/^es(next)?\.set\./,
1031
];

0 commit comments

Comments
 (0)