sindresorhus/ponyfill

This repository is bad advice - it goes completely against standards.

garygreen opened this issue · 1 comments

Ponyfills should absolutely NOT be encouraged to be used when referring to standard features built into browsers approved by Ecma.

This is the whole reason we have standards - it's because you should be able to rely on an designed and approved API, cross browsers. Whether that be Object.assign() or Promise, or IntersectionObserver - to suggest using an individual, specialised npm script for every standard features is simply poor advice.

The issue you raise that a polyfill could essentially broken, or have missing features/deviate from the specification - well that's an implementation issue and nothing to do with the fact that it's a ponyfill, or yolyfill, or whatever phrase you want to coin it. If it's not following the standards, then it doesn't matter whether it monkey patched or exported a module, it's still broken.

But the biggest problem with suggesting to use ponyfills rather than patch for missing specifications is that third party dependencies will end up using their own npm "ponyfill" version, each slightly different. One might use npm i object-assign-polyfill or npm i assign-object-polyfill or any other variation. Some might even just copy-and-paste a polyfill and re-use it in their own app. Now you have a bundle full of imitation, non-monkey patched versions of standard web functionality.

I realise this repository is over 3 years old with minimal number of stars, so I do hope people who read this have come to the same conclusion; take this repository with a grain of salt and continue to patch & embrace standards.

Thanks for your input. However, it's clear that we fundamentally disagree.

Polyfills are often broken. Standards often change before being completed. Standards often have bugs. So do polyfills. Overriding globals, which polyfills do, doesn't just affect your code, but all the other code in your dependency tree, which can cause total havoc of hard to debug issues. The main benefit of ponyfills is that they are localized to your own code. They don't affect any other code. When a standard is stable and shipping in browsers, you are of course recommended to use the standard feature instead. But from my long experience with using both polyfills and ponyfills, ponyfills are much safer and in my opinion a better solution.