Is there a way to "tree shake" babel-polyfill, such that only the features I use are polyfilled?
That is, if I never use String.padStart
in my code, it's polyfill should not be included.
Is there a way to "tree shake" babel-polyfill, such that only the features I use are polyfilled?
That is, if I never use String.padStart
in my code, it's polyfill should not be included.
I was able to do it using CoreJS 3 (beta) core-js@3.0.0-beta.3
.
Babel polyfill also uses core-js
so I think you can use below method:
npm install --save core-js@3.0.0-beta.3
Then in your JS code you can import your desired polyfills as below (ES syntax):
import "core-js/features/array/includes";
import "core-js/features/string/starts-with";
So far it's working great for me!