cricri/node-browserify — comment on commit 8a3c28e6eb14afd14a7160f7cccb21c00fe5b5ef
File:  line 0
By cricri:

I needed a generated name for the function wrapping the actual code.

b.js

exports.b = function() {console.log('b');};

a.js

var b = require('./b').b;
b();

will generate:

var __b_js_function = function (module, exports, require) {
exports.b = function() {console.log('b');};

};
require.createModule("/", "/b.js", __b_js_function);

To be sure to have unique names, I use the path/name of the module. But obviously we cannot use '.' or '/' or '-' in function names. To be sure not to break something on existing code using browserify, I also discarded non alphanumeric characters.
To be absolutely sure to avoid pathological cases, an integer id might be be better ??? but I also wanted to make the things easier to debug.

And I suggest to change my code with something simpler:

var fname = (dirname+'_'+path.basename(target)+'_function').replace(/[./]|[^a-zA-Z0-9_]/g, '_');

You are right for namespace pollution, I will include createModule in the 'require' namespace (what is require.define ?).

I will submit a new patch with this change.