joyent/node — pull request #4634 by rvagg (2013-01-21 03:31:29+00:00)
Title: Introduce NODE_MODULE_INIT() to pass full `module` object to addons

Proposal to allow native addons have access to the full `module` object so they can optionally overwrite `exports`, with a single function for example. Currently they are restricted to operating on an existing object.

Keeps `NODE_MODULE()` intact so doesn't affect existing addons, introduces `NODE_MODULE_INIT()` as an alternative and perhaps `NODE_MODULE()` could be deprecated and replaced with `NODE_MODULE_INIT()` in the docs with

```c++
NODE_SET_METHOD(target->Get(String::New("exports")), "foo", Foo);
```

(or a new, more convenient macro perhaps?).

Thoughts?