Question: How can I find out what new features are or are not polyfill-able?
Context: This is a follow-up to this Slack thread (internal only).
We recently changed how we apply polyfills. Previously, we manually imported the polyfills we needed in app/assets/javascripts/commonts/polyfills.js
. This made it pretty easy to determine if a new ES feature that isn't implemented in all browsers (for example, Array.from
) is available for use - just check this file to see if we're importing a polyfill for the feature.
Now, we let Babel's preset-env
automatically polyfill features that it detects we are using. This change was implemented in !19629 (diffs).
However, it's no longer clear to me which features Babel will polyfill. Diving into our babel.config.js
, I see this preset-env
configuration option:
corejs: { version: 3, proposals: true }
According to the docs:
This will enable polyfilling of every proposal supported by
core-js
.
If I'm reading this right, this means we'll support all proposals, even early stage proposals (e.g. stage 0 and pre-stage 0). Is this correct/intended? For example, I could now technically start using Reflect
metadata?
This is a little different than @mikegreiling's comment in Slack (internal only):
our documented policy is to stick to proposals at only Stage-3 and higher.
which I think makes good sense.