How can I import some specific modules of babel-polyfill rather than import all ? It seems too huge size for me to import all of it and I just use few of the features of it.
What I want is like following:
import "babel-polyfill/symbol";
Under the hood, the babel-polyfill
uses a project called core-js (with some customisations of course). It exposes a CommonJS API, so assuming you are transpiling to CommonJS (default behaviour when using preset-es2015), you could simply use that instead:
// This pollutes the global namespace. May conflict with
// any real Symbol implementations in the future
import "core-js/es6/symbol";
// Namespace-safe Symbol import
import symbol from "core-js/es6/symbol";
It's important with this approach that you use a bundler of some sort (Browserify, Webpack, etc), because core-js is made up of a lot of smaller modules and may cause a lot of unnecessary HTTP requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With