简体   繁体   English

Google Closure Compiler ADVANCED_OPTIMIZATIONS - 排除所有函数名称

[英]Google Closure Compiler ADVANCED_OPTIMIZATIONS - Exclude All function names

I'm using Google's Closure Compiler to reduce the size of my Java Script code. 我正在使用Google的Closure Compiler来减小Java Script代码的大小。 Unfortunately the Closure Compiler does also change ALL function names in the Advanced mode without an easy option to change that. 不幸的是,Closure Compiler还会在高级模式下更改所有函数名称,而无需更改它。

I do need to exclude functions that are defined as properties (eg car.bla = function() ) completely. 我确实需要完全排除被定义为属性的car.bla = function()例如car.bla = function() )。 This includes the ones that I use and that are not defined at all in the local code, and the ones that I define myself. 这包括我使用的和本地代码中根本没有定义的那些,以及我自己定义的那些。

I know that there is externs and exports (although I don't fully understand them) but I do not want to have to keep maintaining any extra files beside my code. 我知道有外部和导出(虽然我不完全理解它们)但我不想在代码旁边继续维护任何额外的文件。

I would also be find to exclude any functions (also non-property functions). 我也会发现排除任何函数(也是非属性函数)。

After googling for a few hours I've still not found an options for that. 谷歌搜索几个小时后,我仍然没有找到一个选项。

There are a few answers here; 这里有几个答案;

  1. Use @export to label a property as "used by external sources", such as an Angular binding. 使用@export将属性标记为“由外部源使用”,例如Angular绑定。
  2. Create an externs . 创建一个externs These are used when you have code that is compiled separately from your code, but they need to interact. 如果您的代码与代码分开编译,但需要进行交互,则会使用这些代码。 Have a look at how simple Angular's externs are. 看看Angular的外部是多么简单。
  3. Reduce your compilation level to WHITESPACE_ONLY 将编译级别降低到WHITESPACE_ONLY
  4. Depending on your setup, you may be able to pass --property_renaming=ALL_UNQUOTED and use foo['bar'] to access foo.bar 根据您的设置,您可以传递--property_renaming=ALL_UNQUOTED并使用foo['bar']访问foo.bar
  5. Depending on your setup, you may be able to Pass --property_renaming=OFF 根据您的设置,您可以通过--property_renaming=OFF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Closure编译器的ADVANCED_OPTIMIZATIONS选项 - Google Closure Compiler's ADVANCED_OPTIMIZATIONS option 具有Closure Compiler和ADVANCED_OPTIMIZATIONS的模块模式 - Module pattern with Closure Compiler and ADVANCED_OPTIMIZATIONS 使用闭包编译器 ADVANCED_OPTIMIZATIONS 的奇怪对象属性行为 - strange object property behavior with closure compiler ADVANCED_OPTIMIZATIONS 是否可以使用闭包编译器ADVANCED_OPTIMIZATIONS与jQuery? - Is it possible to use Closure Compiler ADVANCED_OPTIMIZATIONS with jQuery? 如何在ADVANCED_OPTIMIZATIONS中的Closure Compiler中导出公共类方法? - How to export public class methods in Closure Compiler in ADVANCED_OPTIMIZATIONS? 如何不编译goog.closure中的某些代码ADVANCED_OPTIMIZATIONS - How to not compile certain code in goog.closure ADVANCED_OPTIMIZATIONS 关闭编译ADVANCED_OPTIMIZATIONS抱怨使用此方法 - closure compilation ADVANCED_OPTIMIZATIONS complaining about use of this 具有高级优化和外部功能的Closure编译器 - Closure Compiler with Advanced Optimizations and Externs 闭包编译器,缺少具有高级优化功能的方法? - Closure Compiler, missing method with advanced optimizations? 是否可以避免使用带有getter和setter的模式,而仍然使用Closure ADVANCED_OPTIMIZATIONS最小化JavaScript? - Can a pattern with getters and setters be avoided and still minify JavaScript with Closure ADVANCED_OPTIMIZATIONS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM