-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accept custom resolve function #1441
base: master
Are you sure you want to change the base?
Conversation
Interesting approach @Cactusbone. I've been thinking about a good way to solve that (allow setting it, but also wrapping the original). Part of the issue for me is that I wish to be able to do it from a plugin. |
from what I understood, plugins can interact only after modules_deps right now, so it's not gonna be easy :) |
@Cactusbone That's true. It could be as simple as just documenting |
.resolver did not do the trick for me, since it still required existing files and i wanted to give arbitrary code. |
@Cactusbone I'm not sure what you mean. Wrapping |
@Cactusbone I understand what you're going for, I'm just not sure what difference there would be between what you've PR'ed here and this: var b = browserify();
var mdeps = b.pipeline.get("deps").get(0);
var baseResolve = mdeps.resolver;
mdeps.resolver = function (id, parent, cb) {
customResolve(id, parent, function (err, file, pkg) {
if (!err && !file) return baseResolve(id, parent, cb);
else return cb(err, file, pkg);
});
}; In your PR (Please note that I'm not necessarily saying your proposal shouldn't be considered -- there's a couple of different issues involved here.) |
@jmm looks like my memory was playing against me. indeed using a customResolver here do work as well as my PR :) |
@Cactusbone Ok, thanks for the feedback. I personally do think there should be public API for using a custom resolver eventually -- I would just want to see it have a sensible API (including being able to set it via plugin, for example). |
custom resolve function which default to internal resolve when not found.
allows to easily plug in some files.
not far from #1006 though
along with module_deps fileCache, can be used to provide generated content for #1436