Proper help on closure compiler

274 views
Skip to first unread message

DotNetWise

unread,
Nov 13, 2009, 4:09:10 AM11/13/09
to Closure Compiler Discuss
At this stage, there is no help other than command line help about
these:
--module A javascript module specification. The format is
<name>:<num-js-files>[:[<dep>,...][:]]]. Module names must be
unique. Each dep is the name of a module that this module
depends on. Modules must be listed in dependency order, and js
source files must be listed in the corresponding order. Where
--module flags occur in relation to --js flags is unimportant.;
default:
--module_output_path_prefix Prefix for filenames of compiled js
modules. <module-name>.js will be appended to this prefix.
Directories will be created as needed. Use with --module.;
default: ./
--module_wrapper An output wrapper for a javascript module
(optional). The format is <name>:<wrapper>. The module name must
correspond with a module specified using --module. The wrapper
must contain %s as the code placeholder.; default:


http://code.google.com/p/closure-library/issues/detail?id=50
What about proper help with good examples?
-Laurentiu

John Lenz

unread,
Nov 14, 2009, 1:51:27 AM11/14/09
to closure-comp...@googlegroups.com
Until we have the documentation ready, here is a simple overview.  The compiler supports compiling multiple javascript source files together (so they are renamed and optimized as a unit) but the output divided into "modules" that can be loaded separately.  The idea is that core functionality can be part of the initial module that is initially loaded and less used features can be loaded later. 

Here is an example:

  java -jar compiler.jar --js src1.js --js src2.js  --js src3.js --module first:2 --module second:1:first

This will create to modules:
  first.js
  second.js

The first module, I've named "first", contains the 2 file (the first two --js parameters listed).  The second module, I've named "second", contains one file, the next --js entry following those included in the first module, the second module depends on the first.

"--module_output_path_prefix" is straightforward.

"--module_wrapper" is simply a way to add some extra text before and or after the compiler output.  For example, if you wanted to add a comment to the top of the file:

--module_wrapper "/* copyright 2010 */ %s"

Have fun.

-John

DotNetWise

unread,
Nov 14, 2009, 9:47:38 AM11/14/09
to Closure Compiler Discuss
Great, thanks!
This was exact what I was looking for!

-Laurentiu
DotNetWise

On Nov 14, 8:51 am, John Lenz <concavel...@gmail.com> wrote:
> Until we have the documentation ready, here is a simple overview.  The
> compiler supports compiling multiple javascript source files together (so
> they are renamed and optimized as a unit) but the output divided into
> "modules" that can be loaded separately.  The idea is that core
> functionality can be part of the initial module that is initially loaded and
> less used features can be loaded later.
>
> Here is an example:
>
>   java -jar compiler.jar --js src1.js --js src2.js  --js src3.js --module
> first:2 --module second:1:first
>
> This will create to modules:
>   first.js
>   second.js
>
> The first module, I've named "first", contains the 2 file (the first two
> --js parameters listed).  The second module, I've named "second", contains
> one file, the next --js entry following those included in the first module,
> the second module depends on the first.
>
> "--module_output_path_prefix" is straightforward.
>
> "--module_wrapper" is simply a way to add some extra text before and or
> after the compiler output.  For example, if you wanted to add a comment to
> the top of the file:
>
> --module_wrapper "/* copyright 2010 */ %s"
>
> Have fun.
>
> -John
>

DotNetWise

unread,
Nov 16, 2009, 4:07:37 AM11/16/09
to Closure Compiler Discuss
Though, please provide an example of how modules can be used with
calcdeps.py ?
i.e. to determine the prequisite modules automatically for each
module, rather than specifying manual javascript files for each
module.

Best Regards,
Laurentiu
DotNetWise

John Lenz

unread,
Nov 16, 2009, 10:48:19 AM11/16/09
to closure-comp...@googlegroups.com, closure-library
+ closure-library-discuss

I don't believe that calcdeps.py currently has support for modules, but it is maintained by the library folk, so let's ask them.

Nathan Naze

unread,
Nov 16, 2009, 1:40:21 PM11/16/09
to closure-comp...@googlegroups.com, closure-library
It does not seek to support modules. In time, it may be replaced or
updated, but for now, module writers need to write their own tools for
module dependencies.

Nathan

Nathan Naze

unread,
Nov 16, 2009, 3:06:36 PM11/16/09
to closure-comp...@googlegroups.com, closure-library
Additionally to this point -- when I get a chance, I want to
substantially rework the internals of calcdeps.py to make tools for
this purpose -- programatically building and querying dependency
trees, which would be a prerequisite to doing this sort of module
work.

Nathan
Reply all
Reply to author
Forward
0 new messages