Module naming and declarations
samth at ccs.neu.edu
Tue May 7 13:22:28 PDT 2013
On Tue, May 7, 2013 at 4:01 PM, Anne van Kesteren <annevk at annevk.nl> wrote:
> On Tue, May 7, 2013 at 11:48 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>> On Tue, May 7, 2013 at 2:35 PM, Anne van Kesteren <annevk at annevk.nl> wrote:
>>> But you are treating them as URLs by default (with a small dose of magic).
>> No. This is not what's happening at all.
>> Modules are given logical names, such a "backbone" or "jquery/ui".
>> Module loaders map logical names to URLs and then map the URLs to
>> The default behavior of the initial module loader for the browser is
>> to convert a logical name to a URL in a certain way, and then to fetch
>> that URL with http in the usual way to get JS source.
> How is that not treating it as a URL with a dose of magic by default?
> E.g. import "http://code.jquery.com/jquery-1.9.1.min" will work given
> the way things are defined now. Similarly if I put jquery in root
> import "/jquery-1.9.1.min" will always work, regardless of location.
> This might not be how things are intended to be used, but I'd expect
> to see this kind of usage.
Using an absolute URL (as in your first example) opts out of any
processing. Otherwise it wouldn't work, of course -- adding the
baseURL would break that URL.
In the second case, what is the complain? That's a reasonable module name.
>> The way we think that conversion should happen is to use the loader
>> baseURL, which defaults to the document base URL, as a prefix, and
>> ".js" as a suffix. Certainly we could choose other prefixes instead,
>> but it doesn't sound like you think there's a clear better choice.
>> We could also choose a different suffix, or no suffix, but it would be
>> odd to force everyone to remove the extensions on their files.
> I think making them URLs (i.e. requiring import "/js/jquery.js") and
> allowing people who want them to be something different to override
> that with hooks is better. (Or with a new URL scheme as Kevin
The whole point of my original email to Andreas is that this doesn't
work. These names are *not* intended to specify where to find the
resource. They *are* intended to be names that different modules can
coordinate with. Should backbone put `import "/js/jquery.js"` in
their source file?
More information about the es-discuss