-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setImmediate #40
Add setImmediate #40
Conversation
setTimeout, setInterval, setImmediate and their clear counterparts are globals in Node. Because set/clearImmediate are not available in all browsers, adding them here.
Can you take a look at it, please? |
This pull request is still unanswered. @substack ? |
ping @substack |
@jscissr What's the status of |
@zertosh there has been discussion for years but nobody except for IE and node care. I'm a bit split on whether insert-module-globals should detect this case, since people can always add their own polyfills and node 0.8 didn't have setImmediate either, it showed up in 0.10. |
@substack In that case, it should be left for users to polyfill then. @jscissr Alternatively, you use browserify's var b = browserify({
/* more options */
insertGlobalVars: {
setImmediate: function () {
return 'require("timers").setImmediate';
},
clearImmediate: function () {
return 'require("timers").clearImmediate';
}
}
}); |
I don't need this PR for myself anymore @zertosh. When I opened the PR I experimented with using express in a Chrome App using browserify, and express uses the setImmediate global (which is not available in Chrome). There were other problems so I didn't use express in the end, but there are surely other packages that use it. Both node and io.js support it, however they don't document it (node, io.js). I didn't find any deprecations, it's simply an undocumented feature. So do you think that instead of this PR, the packages that use the globals shouldn't use them? Or should the people who use these packages with browserify add the snippet in the above comment? |
There are legitimate uses for
Yeah, the snippet is straight forward enough to drop in if you need it. |
I didn't mean whether I should use
I would prefer 3. because it's the easiest. I thought the idea of browserify is to have a node environment in browsers, and I don't see why |
I feel +1 on this since I have seen multiple node modules that would work fine in browserify if Same reason related: avajs/ava#24 |
Actually, it is a bit of a tricky issue. 😕 It would not be a good thing to add non-standard stuff to browserify.
https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate EDIT: But it does seem pretty standard in Node going forward, so maybe that is enough reason to merge this PR. |
👍 Should be merged. Not doing so means users will have to manually add a polyfill if some deep sub-dependency makes use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should definitely be merged; specifically I want to note that it doesn't shim anything - ie, it doesn't install setImmediate
in the global browser environment - it just provides a replacement for code written in a node style that expects it to work.
yes, agreed ( |
setTimeout
,setInterval
,setImmediate
and theirclear
counterparts are globals in Node.set/clearImmediate
are not available in all browsers, so I added them here.