0

[DOJO]Custom builder command

dojo is a powerful javascript framework, but it has a poor documentation, to generate custom build of dojo, there are several commands very useful but you just can’t find any doc other than searching in the code. I gathered the doc from their code:

To run the build, you must have Java 1.4.2 or later installed.
To run a build run the following command from this directory:

> java -classpath ../shrinksafe/js.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main build.js [name=value…]

Here is an example of a typical release build:

> java -classpath ../shrinksafe/js.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main  build.js profile=base action=release

If you get a ‘java.lang.OutOfMemoryError: Java heap space’ error, try increasing the memory Java can use for the command:

> java -Xms256m -Xmx256m -classpath ../shrinksafe/js.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main build.js profile=base action=release

Change the 256 number to the number of megabytes you want to give Java.

The possible name=value build options are shown below with the defaults as their values:

cssImportIgnore=
If using cssOptimize=”comments”, then you can force the @import inlining step to
 ignore a set of files by using this option. The value of this option should be
a comma separated list of CSS files names to ignore. The file names should match
 whatever strings are used for the @import calls.

xdScopeArgs=
If the loader=xdomain build option is used, then the value of this option will be used as the arguments to the function that defines the modules in the .xd.js files. This allows for more than one version of the same module to be in a page.
See documentation on djConfig.scopeMap for more information.

cssOptimize=
Specifies how to optimize CSS files. If “comments” is specified, then code comments and line returns are stripped, and files referenced via @import are inlined.
If “comments.keepLines” is specified, then code comments are stripped and @import calls are inlined, but line returns are preserved.

releaseName=dojo
The name of the release. A directory inside ‘releaseDir’ will be created with this name.

localeList=ar,ca,cs,da,de-de,el,en-gb,en-us,es-es,fi-fi,fr-fr,he-il,hu,it-it,ja-jp,ko-kr,nl-nl,nb,pl,pt-br,pt-pt,ru,sk,sl,sv,th,tr,zh-tw,zh-cn
The set of locales to use when flattening i18n bundles.

releaseDir=../../release/
The top level release directory where builds end up. The ‘releaseName’ directories will  be placed inside this directory.

copyTests=false
Turn on or off copying of test files.

action=help
The build action(s) to run. Can be a comma-separated list, like action=clean,release. The possible build actions are: clean, release.

symbol=
Inserts function symbols as global references so that anonymous functions will show up in all debuggers (esp. IE which does not attempt to infer function names from the context of their definition). Valid values are “long” and “short”. If “short” is used, then a symboltables.txt file will be generated in each module prefix’s release directory which maps the short symbol names to more descriptive names.

internStrings=true
Turn on or off widget template file interning.

removeDefaultNameSpaces=false
Removes the default ‘com’, ‘org’ and ‘net’ namespaces that are present in Rhino.
This is hazardous to use if the build system is used as part of a Rhino-based server-side solution, so use with caution. Weird build errors might occur. Only use if your own code includes things in a com, org or net namespace.

scopeMap=
Change the default dojo, dijit and dojox scope names to something else. Useful if you want to use Dojo as part of a JS library, but want to make a self-contained library with no external dojo/dijit/dojox references. Format is a string that contains no spaces, and is similar to the djConfig.scopeMap value (note that the backslashes below are required to avoid shell escaping):
scopeMap=[[\”dojo\”,\”mydojo\”],[\”dijit\”,\”mydijit\”],[\”dojox\”,\”mydojox\”]]

mini=true
Removes files like tests, demos dijit/bench, unfinished themes, and interned Dijit templates from the build. Overrides the value set for copyTests.

optimize=
Specifies how to optimize module files. If “comments” is specified, then code comments are stripped. If “shrinksafe” is specified, then Dojo Shrinksafe will be used on the files, and line returns will be removed. If “shrinksafe.keepLines” is specified, then Dojo Shrinksafe will be used on the files, and line returns will be preserved.  See also “stripConsole”. Google Closure’s compiler can be used by specifying “closure” as the value. It does not use the stripConsole build option, and it REQUIRES Java 6 to run, and it may make some complaints about the code and print out ‘error’s, but if the build completes, then the code should work. Do not taunt happy Closure compiler. To use Closure compiler, download it from here:
http://code.google.com/p/closure-compiler/downloads/list
And place the compiler.jar file somewhere you can easily reference. Then use the following to execute the build (remember Java 6):
java -classpath ../shrinksafe/js.jar:../closurecompiler/compiler.jar org.mozilla.javascript.tools.shell.Main build.js
and place your build arguments on the same line after that text. Change the ../closurecompiler path to the path where you keep Closure’s compiler.jar.

loader=default
The type of dojo loader to use. “default” or “xdomain” are acceptable values.

log=0
Sets the logging verbosity. See jslib/logger.js for possible integer values.

profileFile=
A file path to the the profile file. Use this if your profile is outside of the profiles directory. Do not specify the “profile” build option if you use “profileFile”.

expandProvide=false
Expands dojo.provide calls with faster calls at the expense of a larger file size. Only use the option if your profiling reveals that dojo.provide calls are taking a noticeable amount of time. Even then, it could cause errors in the built files. If you find an error after building, turn this option off. It replaces dojo.provide(“foo.bar”) statements with the shortest valid programmatic equivalent:

if(typeof foo==”undefined”){foo={};};foo.bar=foo.bar||{};
Ignored for xdomain builds.

xdDojoPath=
If the loader=xdomain build option is used, then the value of this option will be used to call dojo.registerModulePath() for dojo, dijit and dojox. The xdDojoPath should be the directory that contains the dojo, dijit and dojox directories, and it should NOT end in a slash. For instance: ‘http://some.domain.com/path/to/dojo090’.

stripConsole=undefined
Strips console method calls from JS source. Applied to layers and individual modules resource files. Valid values are “none” (leaves all console calls alone, same as default “”), “normal” (strips all but console.warn and console.error calls), “warn” (strips all but console.error calls), “all” (strips all console calls).  NOTE: only has effect if optimize includes use of shrinksafe.

query=default
Select a DOM query engine. Default value is the normal dojo.query engine. Using query=sizzle will use the Sizzle engine.Normal Dojo tests are not run routinely with the Sizzle engine. See dojo/_base/sizzle.js for the version of Sizzle.

version=0.0.0.dev
The build will be stamped with this version string.

profile=base
The name of the profile to use for the build. It must be the first part of the profile file name in the profiles/ directory. For instance, to use base.profile.js, specify profile=base.

layerOptimize=shrinksafe
Specifies how to optimize the layer files. If “comments” is specified, then code comments are stripped. If “shrinksafe” is specified, then Dojo Shrinksafe will be used on the files, and line returns will be removed. If “shrinksafe.keepLines” is specified, then Dojo Shrinksafe will be used on the layer files, and line returns will be preserved. Google Closure’s compiler can be used by specifying “closure” as the value. It does not use the stripConsole build option, and it REQUIRES Java 6 to run, and it may make some complaints about the code and print out ‘error’s, but if the build completes, then the code should work. Do not taunt happy Closure compiler. To use Closure compiler, download it from here: http://code.google.com/p/closure-compiler/downloads/list
And place the compiler.jar file somewhere you can easily reference. Then use the following to execute the build (remember Java 6):
java -classpath ../shrinksafe/js.jar:../closurecompiler/compiler.jar org.mozilla.javascript.tools.shell.Main build.js
and place your build arguments on the same line after that text. Change the ../closurecompiler path to the path where you keep Closure’s compiler.jar.

scopeDjConfig=
Burn in a djConfig object into the built dojo.js file. Useful if you are making your own scoped dojo and you want a djConfig object local to your version that will not be affected by any globally declared djConfig object in the page. Value must be a string that will look like a javascript object literal once it is placed in the built source. use Dojo as part of a JS library, but want to make a self-contained library with no external dojo/dijit/dojox. Example (note that the backslashes below are required to avoid shell escaping if you type this on the command line):
scopeDjConfig={isDebug:true,scopeMap:[[\”dojo\”,\”mydojo\”],[\”dijit\”,\”mydijit\”],[\”dojox\”,\”mydojox\”]]}

xdDojoScopeName=dojo
If the loader=xdomain build option is used, then the value of this option will be used instead of ‘dojo’ for the ‘dojo._xdResourceLoaded()’ calls that are done in the .xd.js files. This allows for dojo to be under a different scope name but still allow xdomain loading with that scope name.

buildLayers=
A comma-separated list of layer names to build. Using this option means that only those layers will be built. This helps if you are doing quick development and test cycles with layers. If you have problems using this option, try removing it and doing a full build with action=clean,release. This build option assumes you have done at least one full build first.

Possible generation command: build.bat profile=fx action=clean,release cssOptimize=comments localeList=en-gb,en-us,fr,zh-cn optimize=shrinksafe cssImportIgnore=comments

Darktalker

Leave a Reply