-
Notifications
You must be signed in to change notification settings - Fork 8
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
Node.js support #6
Comments
I'd love to see this and be more than happy to accept a PR. Before getting too far along though, the one thing I would like to see is the implementation keep the number of dependencies minimized. Ideally we could have separate browser/node interfaces and specify them using the |
Yes, was thinking along the same lines. My fallback for if you didn't like the idea of universal |
Hey @mikolalysenko, I forked resl a few weeks ago with the intention of doing the above, but found it to be not as straightforward as I would have liked - I felt like I was retrofitting functionality for which resl was not initially designed. I also wanted tests and there were a few other features I wanted so decided to implement a very similar library which doesn't share code but is heavily inspired by resl also has features not supported in getres i.e. support for |
I've started using https://github.com/stackgl/headless-gl so it would be great if I could use this with Node.js too. There are two hurdles as far as I can tell:
XMLHttpRequest
support.text
andbinary
loaders will work fine, but currently loadingimage
/video
/audio
data requires DOM support.Can fairly easily tackle 1. by using a
XMLHttpRequest
polyfill for Node.js. Alternatively could move to using something likeSuperagent
which works across environments (although understand that this might be undesirable as it would add ~5kb to gzipped code weight). Did look at usingfetch
API with ponyfill / polyfill for Node.js (e.g. https://github.com/qubyte/fetch-ponyfill / https://github.com/matthew-andrews/isomorphic-fetch) but currently this doesn't support progress events so seemed undesirable.Support for
image
loader could be achieved by (conditionally for Node.js) using native Node.js image decoders forpng
,jpeg
andgif
etc. Not sure aboutvideo
andaudio
but I guess in theory the same applies.I made a fork to look into this (and also add some unit tests) but wanted to float the idea before I went ahead and tried this out. If done properly adding Node.js support wouldn't change the behaviour of, or add any weight to, the browser code. What are your thoughts on this @mikolalysenko?
The text was updated successfully, but these errors were encountered: