benjamn / install

Minimal JavaScript module loader
https://benjamn.github.io/install/
MIT License
61 stars 24 forks source link

Not requiring .node files for NAN. #7

Closed meyer9 closed 7 years ago

meyer9 commented 8 years ago

https://github.com/nodejs/nan

Seems to be a problem with this:

https://github.com/benjamn/install/blob/master/install.js#L6

benjamn commented 7 years ago

This library is just a bundling format for ordinary JS modules that can be represented as strings. If you want to be able to import binary .node files, you need to define an options.fallback function.

The function should take three arguments:

  1. the required module identifier
  2. the parent module identifier
  3. an error object that should be thrown if no fallback can be found

If successful, the options.fallback function should return whatever require(id) would return in native Node.