[dojo-contributors] Loader-less builds?

Stephen Chung Stephen.Chung at intexact.com
Thu Mar 10 21:25:52 EST 2011

My $0.02 worth on Closure:

The best conversion format from AMD to ensure max. compression potential for 
Closure is:

1) One global var per module, holding the module return (preferably one 
return per module).  Closure has mechanisms to automatically unwrap global 

2) Do not save those module returns in hashes (e.g. for module lookup) 
unless absolutely necessary -- this creates an alias; anything stored cannot 
be optimized.  In a regular build, any module that is built in really does 
not need to be stored, only "plugin" ones.  The build process can convert 
any mini-require calls to built-in modules directly to accessing the global 

3) No passing those global variables into wrapper function closures as 
arguments -- again creating alias.  In fact, the argument needs to be 
eliminated and the code referring directly to the global var's (or remapped 
into the name of the argument via a special Closure construct called 

Therefore, there probably should be a build flag that normally builds a 
minimal-load version for regular use, and a special Closure flag to take 
care of the above factors for best optimization by Closure.  There will be 
more limitations for user code with this flag turned on, but programmers who 
run Closure learn to live with limitations...

- Stephen

-----Original Message----- 
From: James Burke
Sent: Friday, 11 March, 2011 5:51 AM
To: dojo dev.
Subject: Re: [dojo-contributors] Loader-less builds?

On Thu, Mar 10, 2011 at 1:27 PM, Kris Zyp <kzyp at dojotoolkit.org> wrote:
> Along the lines of creating more compressible (with Closure or other
> future tools) and lighter builds, I was wondering if any of our build
> tools could ever create builds that directly generated variables from
> modules in such a way as to make the connections more visible to code
> compressors and avoiding even needing a module loader. Here is an
> example of what I mean:
> https://gist.github.com/864958

It may be safer to embed a mini-require/define implementation to do
the string-to-object lookup, in particular for plugin-inlined modules
-- they do not have a natural JS variable to map them to. Something
like what is done in Ace[1], or what CoffeeScript does for building
its browser friendly version[2]. I'm not sure if that limits some of
the optimizations Closure Compiler can do, but it would likely have
fewer edge case breakages.

[1] https://github.com/mozilla/ace/blob/master/build_support/mini_require.js
[2] https://github.com/jashkenas/coffee-script/blob/master/Cakefile#L88

dojo-contributors mailing list
dojo-contributors at mail.dojotoolkit.org

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.872 / Virus Database: 271.1.1/3499 - Release Date: 03/11/11 

More information about the dojo-contributors mailing list