chrisdickinson / raf

requestAnimationFrame polyfill library
MIT License
742 stars 54 forks source link

Add polyfill.js for convenience #31

Closed DylanPiercey closed 8 years ago

DylanPiercey commented 8 years ago

This makes importing the module easier if you only want the polyfill. Especially in es6 modules.

import raf from 'raf'
raf.polyfill()

vs

import 'raf/polyfill'
CMTegner commented 8 years ago

Great suggestion! I'm worried about require('raf/polyfill') being too similar to require('raf').polyfill, so perhaps we should change the name to raf/register or similar. Thoughts?

DylanPiercey commented 8 years ago

@CMTegner I had thought of doing raf/register however decided against it because it is typically used for registering preprocessors. I'm not totally against it but I think raf/polyfill makes more sense.

ljharb commented 8 years ago

I don't think we have to worry about that similarity. Those two are very different.

chrisdickinson commented 8 years ago

I'm +1 on require('raf/polyfill') / import 'raf/polyfill' — we can recommend that folks start using that in the future in order to reduce the ambiguity of require('raf').polyfill().

DylanPiercey commented 8 years ago

@CMTegner @chrisdickinson I updated the readme in the pr to mention that require('raf/polyfill') is the same as require('raf').polyfill(). Does that look better?

CMTegner commented 8 years ago

Looks good 👍

CMTegner commented 8 years ago

Published in 3.3.0. Thanks!