js-loaders icon indicating copy to clipboard operation
js-loaders copied to clipboard

Is it ever correct to call System.resolve(normalized, options) directly?

Open johnjbarton opened this issue 11 years ago • 2 comments

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.

johnjbarton avatar Nov 01 '13 18:11 johnjbarton

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.

jorendorff avatar Nov 01 '13 19:11 jorendorff

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().

johnjbarton avatar Nov 01 '13 20:11 johnjbarton