YuzuJS/setImmediate

module.exports instead of global polyfill?

dy opened this issue · 5 comments

dy commented

Hi!
I've tried to use this module by the CommonJS convention, like that:

var setImmediate = require('setimmediate');
setImmediate(function () {});

And found out that this code doesn't work.

Is there a specific reason you keep to exposing setImmediate to the global scope instead of exporting a module?

It's quite uncomfortable to use that as a polyfill as a module, because there's a special service for polyfills, polyfill.io, which ensures the environment and in that a user can avoid importing polyfills as dependencies.

Besides, user can always compile module standalone with browserify -s, so it is not necessary to force him into using global-scope setImmediate.

Dupe of #16.

dy commented

Well, it's actually a case when I use ES6 modules instead of commonJS:

import setImmediate from 'setimmediate'

I don't want to know commonJS format anymore, but babel forces compilation of ES6 modules into commonJS (by default). How I'm supposed to deal with it then?

import 'setimmediate'

dy commented

Right)

this is fantastic. We should add this to readme.

For the record, I'm using typescript and this works flawlessly.