Obfuscation for web target

Obfuscation for web target
0.0 0


Hi guys,
is there any way to customize cocos creator’s web target builds? In order to use google closure compiler, it is very useful to be able to change the way babel is transpiling the code from ES6 to ES5 to avoid to break code references.
Currently cocos creator’s build system is transpiling code using target ES2015 and not ES2015-loose,
that makes that the generated code does not define member functions explicitly but dynamically.
So after use closure compiler references to those functions will be obfuscated but the functions itself does not, and that will break the game on runtime due to call to undefined functions.

For instance, code like this in ES6:

Class ResourceManager{
addResourcePathList(list) { … }

is being transpiled to ES5 with babel option ES2015 to:

_createClass(ResourceManager, [{
key: “addResourcePathList”,
value: function addResourcePathList(list) { … }

So code calling that function will be obfuscated but the function itself will not.

On the other hand, if the cocos creator could transpile using bable flag ES2015-loose,
the generated code will be like this:

ResourceManager.prototype.addResourcePathList = function addResourcePathList(list) { … };

So after obfuscated the both function and calls will be obfuscated properly and wont be undefined references.

As far as I understand, currently there is not way to change babel settings, but is there any work around?
Having this possibility will be useful for many developers trying to protect a bit their code.

Thanks in advance.