[dojo-contributors] Asynchronous Module Definition (was Re: [CommonJS] Another idea on unifying Transport/C and /D)
kzyp at dojotoolkit.org
Tue Oct 12 17:36:55 EDT 2010
On 10/12/2010 2:55 PM, James Burke wrote:
> On Tue, Oct 12, 2010 at 11:31 AM, Kris Zyp <kriszyp at gmail.com> wrote:
>> Again, the suggestion is that CommonJS only define a single global not
> This specific suggestion might be for just one, but for the loader to
> actually be useful, it will need a bootstrap call require() or
> require.ensure, so I still see it as needing two globals, since
> hanging the bootstrap call off of define seems unlikely.
If you have implementation specific properties/functions, they *should*
be in a separate global/namespace than a CommonJS defined namespace.
Putting implementation specific properties in a shared namespace defeats
the entire purpose of namespacing! This is analagous to Dojo putting all
its functions on Object.* or $.* because they already exist and then we
could avoid "needing an extra global". This would cause horrible
problems. The point of namespacing is to partition naming authorities.
Reusing a namespaces that others are adding names to, defeats the entire
whole purpose of namespacing, and reintroduces name conflict hazardous!
If you care about reducing naming hazards (which is the whole purpose of
minimizing globals), it seems like the best options would be for
CommonJS to keep "require" and RequireJS to use "requirejs", or CommonJS
could use "define" and RequireJS could keep "require". Sharing naming
authority of "require" isn't really a tenable option for naming safety.
More information about the dojo-contributors