1

angularjs で書かれた JavaScript アプリを Google クロージャ コンパイラでコンパイルしようとしています。私のアリのビルドは次のようになります。

<?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]);

これらの「エラー」を回避するにはどうすればよいですか?

4

1 に答える 1

3

intecmascript 3の予約語です。--language_in2 つの ecmascript 5 オプションのいずれかを指定するには、コンパイラのオプションを使用する必要があります。新しいコンパイラ ビルドでは、デフォルト言語として ecmascript 5 が使用されます。

于 2013-08-30T19:42:51.070 に答える