Javascript 如何在高级_优化中导出闭包编译器中的公共类方法?

Javascript 如何在高级_优化中导出闭包编译器中的公共类方法?,javascript,obfuscation,google-closure-compiler,Javascript,Obfuscation,Google Closure Compiler,我使用的JavaScript继承源于,我的库代码如下所示: var Person = Class.extend({ /** @private */ _dancing: null, /** @private */ _init: function(isDancing){ this._dancing = isDancing; }, /** @public */ dance: function(){ return this._dancing; } }

我使用的JavaScript继承源于,我的库代码如下所示:

var Person = Class.extend({
  /** @private */
  _dancing: null,

  /** @private */
  _init: function(isDancing){
    this._dancing = isDancing;
  },

  /** @public */ 
  dance: function(){
    return this._dancing;
  }
});

var obj = new Person();
obj.dance();
只有那些以下划线开头的类方法才能被破坏,而在高级_优化中保存所有公共方法的最佳方法是什么

我需要获得以下输出:

var a = Class.extend({a:null, b:function(b) {
  this.a = b;
}, dance:function() {
  return this.a;
}});
new a;
a.dance();
做到这一点的“最简单”方法是为编译器创建一个自定义编码约定(您必须修改编译器),并将“导出”约定更改为任何不以“\”开头的内容

见:


以及它的“isExported”方法。

感谢您的回复。但您的意思是,如果类方法或属性以下划线结尾,它将被导出吗?John提到的编码约定有一个方法
isExported
,用于确定是否应保护任何符号不被重命名。如果符号不以“\u1”开头,则可以更改自定义编码约定以返回true。这不是默认行为。是否可以进行任何扩展而不是编辑源代码?您可以使用java api设置编码约定,因此您应该能够在外部维护代码,但您必须在某个时候编写java代码。我使用grunt闭包编译器使用此工具是否可以生成代码?