js-loaders
js-loaders copied to clipboard
Is it ever correct to call System.resolve(normalized, options) directly?
As far as I can tell, the first argument to System.resolve() must be normalized, so everywhere we want to resolve we have to write something like:
function normalResolve(name, refererUrl) {
var options = {
referer: {
name: refererUrl
}
};
return System.resolve(System.normalize(name, options));
}
An API that did the right thing for the most common case would be more fun.
I'm all for fun, but it's really hard for a method to be both (a) an extension point where users can plug in whatever code they want and (b) well-behaved in corner cases.
System.resolve is primarily (a). It's not normally right to call it directly.
It's not normally right to call it directly. Yes I can see that I should be using System.get() in some places where I'm calling resolve.
Nevertheless I think it would be helpful for extension point authors to know that resolve() will only be called with the result of normalize().