如何防止Closure Compiler重命名特定对象的任何属性或方法? [英] How to prevent Closure Compiler from renaming any property or method of a specific object?

查看:81
本文介绍了如何防止Closure Compiler重命名特定对象的任何属性或方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个庞大的3rdparty库( Babylon JS ),该库将由该库提供自己的CDN,并且不能包含在我的Closure Compiler运行中.

I am working with a huge 3rdparty library (Babylon JS) that will be served from its own CDN and cannot be included in my Closure Compiler run.

该库包含一个对象,所有内容都定义为该对象的一部分.

The library contains one object and everything defined as parts of it.

它没有可用的externs文件,所以我开始写一个文件,但是它正在迅速增长.仅仅告诉Closure Compiler不要弄乱我正在设置的任何属性,包括我正在对对象的构造函数创建的对象上设置的属性,都会更容易.

It has no externs file available so I started to write one but it is growing quickly. It would be easier to just tell Closure Compiler to not mangle any properties I am setting, including the ones I am setting on objects created by constructors on the object.

添加了库的名称.

推荐答案

关闭编译器没有功能,除非您禁用此功能,否则您不能说不要对该对象重命名任何属性"财产更名.总体思路是,不可重新定义的对象"很容易泄漏为松散类型的值(未知",对象"等)并禁用整个程序的重命名.这将使维持较大项目的预期优化变得困难.但是,这当然是我希望团队在某些时候重新访问的东西.

The Closure Compiler has no feature that would allow you to say "don't rename any property on this object" except to disable property renaming entirely. The general idea is that it would be very easy for an "unrenamable object" to leak into a loosely typed value ('unknown', Object, etc) and disable renaming for the entire program. And that would make maintaining the expected optimizations for larger projects difficult. However, that is certainly something I would like the team to revisit at some point.

这篇关于如何防止Closure Compiler重命名特定对象的任何属性或方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆