RE: conventions for prollyfills

> [polyfills end up shipping the same base-polyfills multiple times].
> [we should have a way to reuse code in this case]

I agree on the principle. I faced similar considerations at some point, wondering how multiple polyfills could reuse the same base infrastructure without harming performance or usability.

I think the only reasonable option is to use a module system. This allows to refer to any polyfilled module, and since there are "module packers" available, it enables people to create a single js file tailored for their real usage, possibly combining multiple polyfills.



That being said, the more I think about it, the more I believe the global namespace is a bad place to live in, even if they are simply cases where you need to be there. 



I would be tempted to wait until ES6 is finalized before making any recommendation, but I'm pretty sure someone will comes up with an ES6-module polyfill and maybe we should settle on that one. In the mean time, I would probably advise the use of AMD/RequireJS or something alike.

Maybe we should recommend building modules for every polyfill from now on to favor code reuse across polyfills. 		 	   		  

Received on Wednesday, 25 September 2013 16:55:53 UTC