Search code examples
google-closure-compiler

Closure Compiler not generating minified file after upgrade


This works perfectly with compiler version 2013.11.18:

java -jar C:/closure/compiler_v20131118.jar 
--compilation_level ADVANCED_OPTIMISATIONS
--warning_level=VERBOSE 
--jscomp_off=externsValidation
--summary_detail_level=3
--externs C:\path\externs.js 
--create_source_map C:\path\min.map.js 
--output_wrapper "%output%//# sourceMappingURL=urlToMap
--source_map_format V3 
--js C:\path\file1.js 
--js C:\path\file2.js 
--js_output_file C:\path\min.js 
--version 2>&1

But the minified file doesn't get created with compiler version 2016.05.17:

java -jar C:/closure/compiler_v20160517.jar 
--compilation_level ADVANCED 
--warning_level=VERBOSE 
--jscomp_off=externsValidation
--summary_detail_level=3
--externs C:\path\externs.js 
--create_source_map C:\path\min.map.js
--output_wrapper "%output%//# sourceMappingURL=urlToMap
--source_map_format V3 
--js C:\path\file1.js 
--js C:\path\file2.js 
--js_output_file C:\path\min.js 
--version 2>&1

I only get this output in the console:

Closure Compiler (http://github.com/google/closure-compiler)
Version: v20160517
Built on: 2016/05/18 16:21

What am I doing wrong?


Solution

  • A lot has changed with the compiler from 2013 to 2016. This wiki page has some of the more important changes:

    https://github.com/google/closure-compiler/wiki/Managing-Dependencies

    As a data point here is an example compile command that is working for me:

    java -jar ../javascript/closure-compiler/build/compiler.jar
    --entry_point=goog:myphysicslab.sims.pendulum.DoublePendulumApp
    --compilation_level=SIMPLE --define=goog.DEBUG=true --define=goog.LOCALE='de'
    --define=myphysicslab.lab.util.UtilityCore.ADVANCED=false --generate_exports
    --js=../closure-library/ --js=src --jscomp_error=accessControls
    --jscomp_error=ambiguousFunctionDecl --jscomp_error=checkTypes
    --jscomp_error=checkVars --jscomp_error=const --jscomp_error=constantProperty
    --jscomp_error=fileoverviewTags --jscomp_error=globalThis
    --jscomp_error=invalidCasts --jscomp_error=misplacedTypeAnnotation
    --jscomp_error=missingProperties --jscomp_error=missingProvide
    --jscomp_error=missingRequire --jscomp_error=missingReturn
    --jscomp_error=newCheckTypes --jscomp_error=strictModuleDepCheck
    --jscomp_error=suspiciousCode --jscomp_error=typeInvalidation
    --jscomp_error=undefinedNames --jscomp_error=undefinedVars
    --jscomp_error=unknownDefines --jscomp_error=uselessCode
    --jscomp_error=visibility --language_in=ECMASCRIPT5_STRICT
    --dependency_mode=STRICT --warning_level=VERBOSE
    

    Most likely you need to add the --entry_point and --dependency_mode options.

    Here is an example command using advanced-compile and output_wrapper:

    java -jar ../javascript/closure-compiler/build/compiler.jar
    --entry_point=goog:myphysicslab.sims.pendulum.DoublePendulumApp
    --compilation_level=ADVANCED --define=goog.DEBUG=true
    '--define=goog.LOCALE='\''en'\'''
    --define=myphysicslab.lab.util.UtilityCore.ADVANCED=true --generate_exports
    --js=../closure-library/ --js=src --jscomp_error=accessControls
    --jscomp_error=ambiguousFunctionDecl --jscomp_error=checkTypes
    --jscomp_error=checkVars --jscomp_error=const --jscomp_error=constantProperty
    --jscomp_error=fileoverviewTags --jscomp_error=globalThis
    --jscomp_error=invalidCasts --jscomp_error=misplacedTypeAnnotation
    --jscomp_error=missingProperties --jscomp_error=missingProvide
    --jscomp_error=missingRequire --jscomp_error=missingReturn
    --jscomp_error=newCheckTypes --jscomp_error=strictModuleDepCheck
    --jscomp_error=suspiciousCode --jscomp_error=typeInvalidation
    --jscomp_error=undefinedNames --jscomp_error=undefinedVars
    --jscomp_error=unknownDefines --jscomp_error=uselessCode
    --jscomp_error=visibility --language_in=ECMASCRIPT5_STRICT
    --dependency_mode=STRICT --warning_level=VERBOSE
    '--output_wrapper='\''(function(){%output%}).call(window)'\'''
    

    You might have some problem with the single quote in your output_wrapper?

    To see compiler options:

    java -jar ../closure-compiler/build/compiler.jar --help
    

    That will give some good info on the options, for example:

    --entry_point VAL                   : A file or namespace to use as the
                                          starting point for determining which
                                          src files to include in the compilatio
                                          n. ES6 and CommonJS modules are
                                          specified as file paths (without the
                                          extension). Closure-library namespaces
                                          are specified with a "goog:" prefix.
                                          Example: --entry_point=goog:goog.Promi
                                          se