2013-08-30 45 views
1

我想編譯一個JavaScript應用程序編寫與谷歌關閉編譯器在angularjs中。我的Ant構建是這樣的:AngularJS未能編譯與谷歌關閉應用程序+螞蟻

<?xml version="1.0"?> 
<project basedir="../public_html/" default="compile"> 

    <taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="../../global/build/compiler.jar"/> 

    <target name="compile"> 

    <jscomp compilationLevel="simple" warning="verbose" debug="false" output="${basedir}/js/main.js"> 

     <sources dir="${basedir}/js/"> 
     <file name="angular.js"/> 
     <file name="angular-strap.js"/> 
     <file name="underscore.js"/> 
     <file name="app.js"/> 
     </sources> 


    </jscomp> 

    </target> 

</project> 

但建立在像這樣angular.js基於錯誤掰:

[jscomp] widgets/public_html/js/angular.js:57: ERROR - Parse error. identifier is a reserved word 
    [jscomp]  msie    = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]), 
    [jscomp]^
    [jscomp] widgets/public_html/js/angular.js:245: ERROR - Parse error. identifier is a reserved word 
    [jscomp] function int(str) { 
    [jscomp]^
    [jscomp] widgets/public_html/js/angular.js:5066: ERROR - Parse error. identifier is a reserved word 
    [jscomp]  port: int(match[5]) || DEFAULT_PORTS[match[1]] || null, 
    [jscomp]^
    [jscomp] widgets/public_html/js/angular.js:8373: ERROR - Parse error. identifier is a reserved word 
    [jscomp]   android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]); 
    [jscomp]^
    [jscomp] widgets/public_html/js/angular.js:10128: ERROR - Parse error. identifier is a reserved word 
    [jscomp]   tzHour = int(match[9] + match[10]); 
    [jscomp]^
    [jscomp] widgets/public_html/js/angular.js:10129: ERROR - Parse error. identifier is a reserved word 
    [jscomp]   tzMin = int(match[9] + match[11]); 

我應該避開這些「錯誤」?

回答

3

intecmascript 3 reserved word。您需要使用編譯器的--language_in選項指定兩個ecmascript 5選項之一。較新的編譯器構建使用ecmascript 5作爲默認語言。