Open knpwrs opened 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
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.
This could be done without a breaking by adding ModuleContext::set_exports.
ModuleContext::set_exports
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:
An example of how to do this in C++ is available here: https://github.com/nodejs/node-addon-examples/tree/6a51626da3438a59d31d43229cee3e6fd09ec8a5/3_callbacks