Google closure complier experience and documentation

Source: Internet
Author: User

After several attempts, I finally gave up using Google closure compiler to compile mootools. The reason is very simple. Google closure cannot use [""] And. Attribute access methods in combination, resulting in someCodeCannot be used after obfuscation.

 

Standard flags:
-- Help describes all flags
-- Helpshort describes the main class 'flags
-- Helpxml emits XML description of all flags

Flags for com. Google. Javascript. jscomp. abstractcompilerrunner:
-- Charset input charset for all files.; default:
-- Create_source_map if specified, a source map file mapping
Generated source files back to the original source file will be
Output to the specified path. If % module % is added, a source Map
Will be generated for each module, with the module's name
Placed into the path at that spot.; default:
-- D override the value of a variable annotated @ define. The format
Is <Name> [= <Val>], where <Name> is the name of a @ define
Variable and <Val> is a Boolean, number, or a single-quoted
String that contains no single quotes. If [= <Val>] is omitted,
The variable is marked true.; default:
-- Externs retains the list of symbolic files, such as function ABC () {}; then all ABC files are not obfuscated. Unlike export, export stores only one alias of the original name, others are obfuscated. If you only provide external interfaces, we recommend using the Export method.
-- Js the Javascript filename. You may specify multiple; default:
-- Js_output_file primary output filename. If not specified, output
Is written to stdout.; default:
-- Jscomp_error make the named class of warnings an error.; default:

-- Jscomp_off turn off the named class of warnings.; default:
-- Jscomp_warning make the named class of warnings a normal
Warning.; default:
-- 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:
-- Output_wrapper interpolate output into this string at the place
Denoted by the marker token % output %. See
-- Output_wrapper_marker; default:
-- Output_wrapper_marker use this token as output marker in
Value of -- output_wrapper; default: % output %
-- Property_map_output_file file where the serialized version of
Property renaming map produced shocould be saved.; default:
-- Summary_detail_level controls how detailed the compilation
Summary is. Values: 0 (never print summary), 1 (print Summary
Only if there are errors or warnings), 2 (print summary if type
Checking is on, see -- check_types), 3 (always print summary ).
The default level is 1.; default: 1
-- Third_party check source validity but do not enforce Google Style
Rules and conventions, such as capitalized constant names or
Opt_parameter.; default: false
-- Variable_map_input_file file containing the serialized version
The variable renaming map produced by a previous compilation .;
Default:

flags for com. google. javaScript. jscomp. compilerrunner:
-- compilation_level specifies the compilation level to use.
options: whitespace_only, simple_optimizations,
advanced_optimizations; default: simple_optimizations
-- debug enable debugging opitons .; default: false
-- formatting: the formatting method is non-formatting or pretty_print
-- process_closure_primitives processes built-ins from the closure
library, such as goog. require (), goog. provide (), and
goog. exportsymbol ().; default: True
-- use_only_custom_externs specifies whether the default externs
shocould be excluded .; default: false
-- warning_level specifies the warning level to use. options: Quiet,
default, verbose; default: Default

 

Examples of modular Compilation Use advanced compression functions: Java-jar compiler. jar -- module M1: 1 -- JS m1_1.js -- module M2: 1: M1 -- JS m2_1.js -- compilation_level advanced_optimizations

 

Note:

Compile the code into M1 and M2 modules. M1 and M2 contain one JS file ("M1: 1", "M2: 1 "), the number of included files must be the same as the number of files passed in by JS. If there are multiple files, use multiple -- JS parameters.

 

M2: 1: M1 indicates that the module m2 contains a file and relies on the M1 module.

 

The dependency sequence cannot be messy. If you use Google's own library, you can use the Python script in the library to calculate dependencies.

 

If you want to be lazy, you can take a look at closure lite, which is a pre-compiled version of Google closure's core part. It is only kb in size and is very suitable for use in the tool class to complete some lightweight development work, with this, jquery is no longer needed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.