I've been thinking about creating something that would let me create a polyfill that only contains things that need to be polyfilled. There's two sites to the coin:
1. Only polyfill language features for certain browsers (already done)
2. Only polyfill language features that I used (e.g. my code has Map, but not WeakMap)
I'd love to investigate this but I thought I'd check to see if it's already been done. My dream solution would be something like:
- I define "IE11+" or whatever as my browser support
- When I build, the static analysis of my code works out which features I've used, then grabs those from core-js and builds a polyfill (or list of polyfills).
- A script is created that uses webpack's require.ensure to conditionally load the polyfills from the browser if required - I haven't really thought this part through yet.