neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
8.04k stars 284 forks source link

Implement default exports. #118

Open knpwrs opened 8 years ago

knpwrs commented 8 years ago

As discussed on Slack, the equivalent of the following JavaScript would be great to have in native modules without having to create a JavaScript wrapper:

module.exports = function () {
  // Do something
};

An example of how to do this in C++ is available here: https://github.com/nodejs/node-addon-examples/tree/6a51626da3438a59d31d43229cee3e6fd09ec8a5/3_callbacks

kjvalencik commented 3 years ago

This is possible in Node-API, but we wouldn't be able to expose it without a breaking change. This should be considered for v1.0.

kjvalencik commented 2 years ago

This could be done without a breaking by adding ModuleContext::set_exports.