Skip to content

Node.js support #6

@willbamford

Description

@willbamford

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:

  1. No XMLHttpRequest support.
  2. text and binary loaders will work fine, but currently loading image / 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 like Superagent which works across environments (although understand that this might be undesirable as it would add ~5kb to gzipped code weight). Did look at using fetch 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 for png, jpeg and gif etc. Not sure about video and audio 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions