

Create Native Node.js modules falling back to Emscripten ones - nfriedly
http://insertafter.com/en/blog/native-node-module.html?

======
matthewbauer
Very useful article! I usually don't see projects aiming for both Node and
browser support. But, as a module consumer, that is almost certainly what I
would prefer. That is, ideally Javascript can run in the browser or in Node
without any refactoring.

Emscripten has a lot of legacy code in shell.js that tries to detect the
'require' hook and assumes you're in Node if it's available. That usually
isn't what you want in browserify. How did you deal with that?

It would be especially useful if we could use the same bindings for Node
addons and Emscripten. I suppose a wrapper around nan.h could be made that
exposes both node.h and embind.h?

~~~
nfroidure
Browserify has an option to avoid parsing a given file so that the Emscripten
module can be used as is since it is already prepared for the browser. I would
have prefer an option to either build for Node or the browser. I hope it'll be
the case soon.

About unifying both Node and Emscripten API, i assume it is possible but it
would be a lot of work, too much for doing it in my spare time ;).

