"ReferenceError: $jscomp is not defined" 当通过谷歌闭包编译器 jar 更改输出语言规范时



我已经下载了最新版本的编译器,我已经尝试优化js代码与这些标志:

java -jar close -compiler-v20211006.jar -W VERBOSE -O WHITESPACE_ONLY——js_output_file $script_path_tmp

闭包编译器优化了以下代码行:

for(var extraProperty of extraProperties){  
option.setAttribute(extraProperty,initialOption[extraProperty]);    
}

for (var $jscomp$iter$0 = $jscomp.makeIterator(extraProperties), $jscomp$key$extraProperty = $jscomp$iter$0.next(); !$jscomp$key$extraProperty.done; $jscomp$key$extraProperty = $jscomp$iter$0.next()) {
var extraProperty = $jscomp$key$extraProperty.value;
{
option.setAttribute(extraProperty, initialOption[extraProperty])
}
}

结果我在浏览器中收到这样的错误:

all_compressed.js Uncaught ReferenceError: $jscomp is not defined

是否有一种方法来改变语言规范与这个编译器不添加侧依赖到项目中,或者它可能是一个bug?

Git bug跟踪器

纯空白模式的最佳选择是将语言设置为源代码(或更高版本)使用的最新ECMASCRIPT版本,以避免运行时依赖。

最新更新