[英]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; 这里有几个答案;
@export
to label a property as "used by external sources", such as an Angular binding. 使用@export
将属性标记为“由外部源使用”,例如Angular绑定。 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的外部是多么简单。 WHITESPACE_ONLY
将编译级别降低到WHITESPACE_ONLY
--property_renaming=ALL_UNQUOTED
and use foo['bar']
to access foo.bar
根据您的设置,您可以传递--property_renaming=ALL_UNQUOTED
并使用foo['bar']
访问foo.bar
--property_renaming=OFF
根据您的设置,您可以通过--property_renaming=OFF
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.