Google Groups

Re: Module sharing

James Burke Feb 29, 2012 8:55 PM
Posted in group: mozilla-labs-jetpack
On Feb 28, 10:56 pm, Irakli Gozalishvili <> wrote:
> I think all this boils down to convention vs configuration, where !foo is suggested convention and /* package.json */
> is a configuration. I do agree that later one is more flexible in many ways but at the cost of complexity. I'm trying to
> provide simple solution out of the box and make more complex solutions possible via alternative tooling. I have updated proposal to include more details about it (added sections about glue / adapter modules).

For me, the convention is "place the module at a baseUrl location and
it just works". So if the dependency is "underscore" and that is at
baseUrl + underscore.js then everything works out.

If the system needs more information about which particular underscore
is suggested at "install time" if there is not already an underscore
installed by the developer, then look in the configuration. For me,
the require module ID domain/version stuff or /*package.json*/, those
are equivalent ways of providing that config, just different places to
do it.

Since require is a runtime command, adding install info to that
runtime value does not seem like the right separation of concerns, and
it seems to make it less clear how to allow alternative "underscore"
providers. It seems to enforce a very specific implementation version.
Even if another one could be allowed because it is found at baseUrl+
underscore.js so that the domain/version installation info is not
consulted, it seems confusing.

I would not base too much on how harmony modules are currently
constructed too. They are not ready yet. In particular, they should
allow for short meaningful interface names like 'jquery' or
'underscore' instead of full URLs for the same reasons as above, and a
custom resolver should not need to be provided. Otherwise, it is not
much better than having to ask people to use an AMD module loader --
the problem is asking developers to carry a script dependency that
enforces the conventions they want, and it is best if the short names
that map to a baseUrl + shortname.js are supported as the default
resolver so a library would not have to be provided.

Anyway, I'm starting to monologue, and repeat the same points, so I'll
stop posting now.