本文介绍了为什么Closure Compiler不使用某些名称重命名对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 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 = {};

输出为:

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

为什么要重命名:

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

但不是:

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

某些单词似乎有问题吗?

It seems to be an issue with certain words?

推荐答案

更新

从Closure-compiler的20150315版本开始,默认情况下启用基于类型的优化.

Update

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

Closure Compiler不会重命名与外部对象中定义的任何属性同名的属性,除非启用了--use_types_for_optimization标志.参见项目常见问题解答以获取更多详细信息.

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.

这篇关于为什么Closure Compiler不使用某些名称重命名对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 03:24
查看更多