如何为Closure编译器设置language

编程入门 行业动态 更新时间:2024-10-26 21:29:40
本文介绍了如何为Closure编译器设置language_in选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在Closure编译器上设置language_in选项,以防止IE8解析错误:

I need to set the language_in option on the Closure compiler to prevent the IE8 parse error:

ERROR-解析错误. IE8(及更低版本)将错误地解析数组和对象文字中的尾部逗号.如果您要定位较新的JS版本,请设置相应的language_in选项.

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.

我确实在闭包组中找到了与此相关的帖子,但是,该选项直接在Java编译器上设置,而不是通过构建脚本之一设置.我需要能够在构建脚本上进行设置.

I did find a post in the closure group relating to this, however, the option is set directly on the java compiler, rather than through one of the build scripts. I need to be able to set it on a build script.

我正在查看Closure/bin/build/中的脚本,那里有几个.我尝试将选项添加到闭包生成器,但失败了.

I'm looking at the scripts in closure/bin/build/ and there are several there. I tried adding the option to closure builder, but it failed.

有人可以指导我如何正确设置此选项吗?

Can someone direct me about how to set this option correctly?

谢谢.

推荐答案

运行关闭带有--help标志的编译器应用程序,以查看每个标志的描述.

Run the Closure Compiler Application with the --help flag to see a description of each flag.

java -jar compiler.jar --help

CommandLineRunner 定义--language_in的允许值集:

--language_in 设置输入源符合的语言规范. 选项:ECMASCRIPT3,ECMASCRIPT5,ECMASCRIPT5_STRICT, ECMASCRIPT6_TYPED(实验性),ECMASCRIPT_2015,ECMASCRIPT_2016, ECMASCRIPT_2017,ECMASCRIPT_NEXT

--language_in Sets what language spec that input sources conform. Options: ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT5_STRICT, ECMASCRIPT6_TYPED (experimental), ECMASCRIPT_2015, ECMASCRIPT_2016, ECMASCRIPT_2017, ECMASCRIPT_NEXT

LanguageMode枚举具有关于这些值的更多详细信息.

The LanguageMode enum has a bit more detail about these values.

使用 Closure Builder ,--language_in标志将以的参数 --compiler_flags如下:

Using Closure Builder, the --language_in flag would be passed as an argument to --compiler_flags as in:

--compiler_flags="--language_in=ECMASCRIPT5"

更多推荐

如何为Closure编译器设置language

本文发布于:2023-11-14 19:04:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588278.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   何为   Closure   language

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!