我如何将函数标记为“私有”通过 Google Closure Compiler 重命名它?
我有 private function createSomething():
function Player(id) {
/**
* Creates stuff
* @private
*/
this.createSomething = function() {
// do something good
};
}
并且我想在使用 Google Closure Compiler 编译源代码后看到重命名的函数“createSomething()”。 是的,我知道 ADVANCED_OPTIMIZATIONS 但它与 jQuery 和其他库不兼容。
I have private function createSomething():
function Player(id) {
/**
* Creates stuff
* @private
*/
this.createSomething = function() {
// do something good
};
}
and I want to see the renamed function "createSomething()" after compiling the source with Google Closure Compiler.
Yes, I know about ADVANCED_OPTIMIZATIONS but it is incompatible with jQuery and other libraries.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案是使用字符串文字来引用该属性。
这是可行的,因为编译器从不重命名字符串文字。 但要小心。
您可以使用 ADVANCED_OPTIMIZATIONS 编译代码并且仍然与其他库兼容。您需要阅读库文档中有关externs和exports的内容:
The solution is to use a string literal to refer to the property.
This works because the compiler never renames string literals. But be careful.
You can compile your code with ADVANCED_OPTIMIZATIONS and still have you compatibility with other libraries. You'll need to read about externs and exports in the library documentation:
只需使用没有这个
Just use without this