TypeScript Obfuscation

≡放荡痞女 提交于 2020-12-01 08:55:30

问题


Are there any tools or forks of TypeScript to support public namespace obfuscation? I.e. to turn:

class MyUtil {
   print(): void { ... }
}

Into something like:

class xxy {
   aab(): void { ... }
}

If not, would be be straight forward to fork the compiler to provide this? Perhaps with some type of class annotation indication what should / shouldn't be obfuscated.

(Obviously public obfuscation has to be used carefully, no good for libraries! But great if used consistently across your project)


回答1:


I had the exact same question, and it was instantly deleted by SO.

https://github.com/angular/ts-minify

This is exactly the tool you (and I) are looking for, it seems to work pretty well, I needed to comment out a few parts where the the author was taking precautions I don't think are applicable.




回答2:


I don't believe there is any reason to do this in TypeScript. You can instead use something like Closure Compiler to do the obfuscation on your JavaScript output. Specifically look into Closure's Advanced Compilation settings.




回答3:


 Not a direct answer! Js obfuscator

https://github.com/javascript-obfuscator/javascript-obfuscator

Plugins:

Webpack plugin: webpack-obfuscator
Webpack loader: obfuscator-loader
Gulp: gulp-javascript-obfuscator
Grunt: grunt-contrib-obfuscator
Rollup: rollup-plugin-javascript-obfuscator

NOTE:

Only obfuscate the code that belongs to you.

It is not recommended to obfuscate vendor scripts and polyfills, since the obfuscated code is 15-80% slower (depends on options) and the files are significantly larger.



来源:https://stackoverflow.com/questions/14102242/typescript-obfuscation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!