sebpiq / WAAClock

A comprehensive event scheduling tool for Web Audio API.
MIT License
244 stars 32 forks source link

Fix missing process variable #24

Closed domchristie closed 2 years ago

domchristie commented 3 years ago

I'm currently using WAAClock on a Svelte project using Vite. Vite performs some clever CommonJS resolution, but throws when trying to access process.nextTick. After a bit of research, it appears that process can be required~, which is what this PR does!

(I think this is what browserify adds to the built file, but given that Vite appears to be using the source files, this needs to be manually included.)~

Edit: this PR replaces process.nextTick with setTimeout as discussed below.

sebpiq commented 2 years ago

Hello @domchristie ! Thanks for the pull request, and sorry for the very slow answer ! Instead of adding a new dependency, I think it would be way simpler to replace

process.nextTick(function() { self._tick() })

WIth

process.setTimeout(function() { self._tick() }, 0)

Would you mind modifying your pull request to do this instead (no need for a require call either then ;) ) ?

domchristie commented 2 years ago

or just

setTimeout(function() { self._tick() }, 0)

?

sebpiq commented 2 years ago

uuuh yes ... sorry, I was not thinking straight :sweat_smile:

domchristie commented 2 years ago

@sebpiq no problem! I've amended the commit, so I think this should be good to go :)

sebpiq commented 2 years ago

@domchristie merged ! Thanks again :)