让 Google 闭包编译器自动工作,而不是手动修复 IE8 解析错误
Get Google closure compiler to work automatically instead of manually fixing IE8 parse errors
编写了一个脚本 "LC.sh" 来下载 lambda 计算器并将其编译为 Javascript。这是脚本的相关部分:
[ ! -f ./compiler-latest.zip ] && echo "Downloading" && \
curl -R -O -L https://dl.google.com/closure-compiler/compiler-latest.zip
[ ! -f ./uni.c ] && echo "Downloading" && \
curl -R -O -L http://tromp.github.io/cl/uni.c
[ ! -f ./compiler.jar ] && echo "Decompressing" && \
unzip compiler-latest.zip compiler.jar
[ ! -f ./LC.js ] && echo "Compiling" && \
emcc -DM=999999 -m32 -std=c99 uni.c -o LC.js
[ ! -f ./LC-min.js ] && echo "Minifying" && \
java -jar compiler.jar --js LC.js --js_output_file LC-min.js
产生以下错误:
ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
只需删除结尾的逗号并再次 运行 脚本即可解决这个问题。由于我不希望其他人遇到此问题,我该如何在没有人工干预的情况下自动修复此问题?
尾随逗号的行为在 ECMAScript 3 中未定义并产生 different result in Internet Explorer。出于这个原因,当输入语言设置为 ECMAScript 3(当前是默认设置)时,闭包编译器将尾随逗号标记为错误。
如果您只针对 ECMAScript 5 兼容浏览器 (IE9+),那么这不是错误。
要指定 ECMAScript 5,请使用 --language_in=ECMASCRTIP5
标志。
编写了一个脚本 "LC.sh" 来下载 lambda 计算器并将其编译为 Javascript。这是脚本的相关部分:
[ ! -f ./compiler-latest.zip ] && echo "Downloading" && \
curl -R -O -L https://dl.google.com/closure-compiler/compiler-latest.zip
[ ! -f ./uni.c ] && echo "Downloading" && \
curl -R -O -L http://tromp.github.io/cl/uni.c
[ ! -f ./compiler.jar ] && echo "Decompressing" && \
unzip compiler-latest.zip compiler.jar
[ ! -f ./LC.js ] && echo "Compiling" && \
emcc -DM=999999 -m32 -std=c99 uni.c -o LC.js
[ ! -f ./LC-min.js ] && echo "Minifying" && \
java -jar compiler.jar --js LC.js --js_output_file LC-min.js
产生以下错误:
ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
只需删除结尾的逗号并再次 运行 脚本即可解决这个问题。由于我不希望其他人遇到此问题,我该如何在没有人工干预的情况下自动修复此问题?
尾随逗号的行为在 ECMAScript 3 中未定义并产生 different result in Internet Explorer。出于这个原因,当输入语言设置为 ECMAScript 3(当前是默认设置)时,闭包编译器将尾随逗号标记为错误。
如果您只针对 ECMAScript 5 兼容浏览器 (IE9+),那么这不是错误。
要指定 ECMAScript 5,请使用 --language_in=ECMASCRTIP5
标志。