Why does Closure Compiler not rename objects with certain names?

一世执手 提交于 2019-12-02 01:37:54

问题


When I test the following code in closure compiler at http://closure-compiler.appspot.com:

// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// @formatting pretty_print
// ==/ClosureCompiler==

// These get renamed
window.foo = {};
window.bar = {};

// These don't
window.uid = {};
window.test = {};

The output is:

window.a = {};
window.b = {};
window.uid = {};
window.test = {};

Why does it rename :

window.foo = {};
window.bar = {};

But not:

window.uid = {};
window.test = {};

It seems to be an issue with certain words?


回答1:


Update

As of the 20150315 release of Closure-compiler, the type based optimizations are enabled by default.


Closure Compiler will not rename properties that have the same name as any property defined on an object in the externs unless the --use_types_for_optimization flag is enabled. See the project FAQ for more details.



来源:https://stackoverflow.com/questions/12671041/why-does-closure-compiler-not-rename-objects-with-certain-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!