我可以为外部库隐藏Closure Compiler警告吗?

时间:2018-02-06 18:29:41

标签: google-closure-compiler

当我运行闭包编译器时,我得到了一堆这样的警告:

 [exec] jquery/3.2.1/dist/jquery.js:733: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
 [exec]     arr[ preferredDoc.childNodes.length ].nodeType;
 [exec]     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

我的构建中有大约30个警告,全部来自jquery和bootstrap.js

我正在使用Ant脚本处理我的构建。对Closure Compiler的调用如下所示:

<target name="build_scripts" description="Compile frontend scripts">
 <exec executable="${java.exec}" failonerror="true">
   <arg line="-client -d64 -jar ${closure.jar}"/>
   <arg line="--js ${src.dir}/assets/js/*.js"/>
   <arg line="--js ${src.dir}/assets/js/**/*.js"/>
   <arg line="--js ${weblib.dir}/jquery/3.2.1/dist/jquery.js"/>
   <arg line="--js ${weblib.dir}/bootstrap-sass/3.3.7/assets/javascripts/bootstrap.js"/>
   <arg line="--externs ${build.dir}/jquery-3.2.externs.js"/>
   <arg line="--dependency_mode=STRICT"/>
   <arg line="--entry_point ${src.dir}/assets/js/main.js"/>
   <arg line="--js_output_file ${out.js.dir}/main.js"/>
   <env key="JAVA_HOME" path="${java_home}"/>
 </exec>
</target>

我认为externs文件的目的是摆脱这样的警告? this question的答案似乎表明我需要在外部库中手动更改它。

我不想让所有警告沉默;只是来自外部图书馆。这可能吗?

1 个答案:

答案 0 :(得分:3)

--hide_warnings_for='path/segment'标志可以满足您的需求。

相关问题