Reputation: 12403
I am trying to compile a javascript app written in angularjs with the google closure compiler. My ant build looks like this:
<?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>
But the build is breaking based on errors in angular.js like so:
[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]);
What should I to get around these "errors"?
Upvotes: 1
Views: 1122
Reputation: 14411
int
is an ecmascript 3 reserved word. You'll need to use the --language_in
option of the compiler to specify one of the two ecmascript 5 options. Newer compiler builds use ecmascript 5 as the default language.
Upvotes: 3