[dojo-contributors] Asynchronous Module Definition (was Re: [CommonJS] Another idea on unifying Transport/C and /D)

James Burke jrburke at gmail.com
Wed Oct 13 16:58:44 EDT 2010

On Wed, Oct 13, 2010 at 11:21 AM, Kris Zyp <kriszyp at gmail.com> wrote:
> The point is that even if CommonJS defined a bootstrapping call, it
> would be pointless.

The general goal behind a require([]) or require.ensure is the same as
a bootstrap call, so I would expect them to look the same. That was
where I was coming with with standardizing the bootstrap call as part
of the global require. There may be other configuration/setup that
would be loader specific that may not make sense to standardize, but
it seemed possible to standardize the bootstrap call, and it seems
like it would be a restriction on require.

In particular, if Node were to implement define/require.def without a
bootstrap call, there would still be a difference in how you kick off
an app when comparing a browser app to a node app. require([]) gives a
nice way to kick off the main functionality without requiring goofy if
(require.main === me) {} idioms. The require.main thing is
particularly hard to emulate if it is part of an inline script tag in
an HTML document.

Standardizing on require([]) or (less nice) require.ensure, would help
make that process more consistent. Perhaps allowing for the app
kick-off in each env is not a design goal, but it is what I want out
of my apps.

More importantly though, that discussion does not need to kill the
"define" suggestion, it just means that the global require may have a
restriction at some point.

In that context, my major reticence to implement define is inertia. I
already painted the bikeshed, and it does not seem broken to me, and
other people use it today. However, in the interest coming together,
if more people feel define is better than require.def, then I will
implement. I do not think require.define buys anything, I believe the
choice is down to define or require.def.

I care more what actual/potential AMD implementors prefer, though. For
example, if the node contingent prefers define over require.def for
their implementation that would be a strong vote for define.

So implementors, now is a good time to speak up. It would be good to
resolve this by the end of this week.


More information about the dojo-contributors mailing list