[dojo-contributors] Module formats for the browser

Kris Zyp kzyp at dojotoolkit.org
Fri Mar 26 00:50:42 EDT 2010



On 3/25/2010 7:45 PM, Bill Keese wrote:
> I see your argument about being able to load random CommonJS modules 
> from dojo without having to run a conversion script on them.   That's 
> definitely an upside.
>
> The downside of using the CommonJS module format for the dojo modules 
> themselves (as James has mentioned) are:
>      - debugging broken except in FF (file names don't appear in 
> debugger, so hard to set breakpoints etc.)
>      - need to run a conversion script to do XD builds
>      - runs slower (but during development, so who cares?   not me, but 
> apparently others do)
>      - added complexity of supporting multiple formats
>   

To be clear, I am not advocating we encourage direct loading of CommonJS
modules (although we could support it, but certainly not encourage it).
I am suggesting that we use RequireJS and that we support the CommonJS
transport format (which is a wrapper around CommonJS modules so they can
be loaded asynchronously with script tags, preserving debugging, speed,
etc.), which is pretty close to the RequireJS's recommended module
loading format, and RequireJS could (and presumably probably will)
support with little effort. This gives users the option of using the
CommonJS module format with a server side CommonJS transport delivery
system (that gives the browser the properly wrapped modules). To not
support the CommonJS transport format when we are 99% of the way there
with RequireJS would be kind of silly. To directly support CommonJS
module format is much different, although it is actually more similar to
the current dojo.require system (possibly reuse those code paths), but I
think this is more questionable in value.

I am also suggesting that we use this module wrapping approach
internally. Perhaps this is the more controversial suggestion. But this
doesn't have any impact on Dojo users, it is only affects the limited
number of dojo contributors and how we internally develop the project. I
already discussed the benefits, but a key is that Dojo is automatically
completely available as CommonJS modules.

Thanks,
Kris


More information about the dojo-contributors mailing list