This was a bug in browserify, but was fixed with this patch: https://github.com/substack/node-browserify/pull/907
and your above code should work in version 6.0.1 and above
문제
I have a problem with requiring programmatically created modules for browserify.
var File = require("vinyl"),
browserify = require("browserify");
bundler = browserify();
bundler.require(new File({contents: new Buffer(...)}), {expose: "mymodule"});
bundler.bundle();
...
In the output file i have the content of buffer, but not exposed to "mymodule".
Does anybody used this case?
해결책
This was a bug in browserify, but was fixed with this patch: https://github.com/substack/node-browserify/pull/907
and your above code should work in version 6.0.1 and above
다른 팁
Since this question was posted James Halliday (substack, creator of browserify) has been hard at work coming up with the browserify handbook: https://github.com/substack/browserify-handbook
This resource is excellent. It goes really deep into how requires work and resolve dependencies in general. It is by far the best resource I have ever seen on the subject. Perhaps if you (or anyone else landing on this question with a similar problem) give it a read, the answer might jump out at you.
I know it's not a direct answer to your question, but I only recently found this resource, and I wish I knew it existed earlier.
For an introduction to browserify, I recommend watching this tagtree video: http://tagtree.tv/browserify-an-intro?share_code=uncoopered-inspirer