Answer the question
In order to leave comments, you need to log in
Is it possible to make a js library that would include polyfills depending on browserslist?
Suppose I want to write a JS library that implements some functionality. For some browsers (ie11), you need to include several polyfills (CustomEvent, Element.closest and several custom implementations) to work.
Question. Is it possible to somehow organize the assembly of the js-bundle, depending on the current supported browsers, registered somewhere in browserslist.rc, so that polyfills that are not needed do not get into the bundle?
I know that babel can do this with core-js , but how do I set it up with my polyfills?
Answer the question
In order to leave comments, you need to log in
Write it in the README, something like:
## Requirements
- CustomEvent
- Element.closest
You can import polyfills:
```javascript
import 'your-library-name/polyfills';
```
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question