A question about Loader baseURL

Sam Tobin-Hochstadt samth at ccs.neu.edu
Mon Aug 27 05:10:33 PDT 2012


On Mon, Aug 27, 2012 at 6:32 AM, Shijun He <hax.sfo at gmail.com> wrote:
> It seems current loader spec is so simple and I'm full of confusion of
> baseURL props.
>
>
> // lib/a.js
>
> System.baseURL // "lib/a.js" ??

No, the base url will be an absolute URL, like 'http://example.com/lib/a.js'.

> System.load('b.js', ...)  // I suppose this should load "lib/b.js", right?

Yes.

> var myLoader = new Loader(System, { baseURL: 'mypath/c.js' , fetch:myFetch })
>
> myLoader.baseURL // 'mypath/c.js' or 'lib/mypath/c.js' or any other value?

'mypath/c.js', which is what you provided as the 'baseURL'.

> myLoader.load('b.js' ...) // load 'lib/mypath/b.js' or 'lib/b.js' ?

Neither -- this invokes the `fetch` hook with relative url 'b.js', and
the base url 'mypath/c.js' -- it's up to the fetch hook to determine
what to do with it.  But 'lib' isn't in either of those arguments
(although `myFetch` might contain a reference to `System.baseURL`).

> function myFetch(relURL, baseURL, ...) {
>     relURL // 'b.js' or 'mypath/b.js' or any other value?
>     baseURL // ?
> }

See above.

> and what happens if I call myLoader in other code for example which
> url is '/otherpath/' ?

I don't understand what you're asking here.

-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list