问题描述
假设您正在一个具有多个外部库依赖项的javascript项目中工作,并且希望使用Google Closure编译器以ADVANCED_OPTIMIZATIONS模式编译源代码.
Suppose you are working in a javascript project with several external library dependencies, and want to compile your sources using the Google Closure Compiler in ADVANCED_OPTIMIZATIONS mode.
由于在这种模式下,编译器会将您的代码调用重命名为外部库对象和函数,因此您必须提供外部,以防止发生这种重命名.
Since in this mode the compiler will rename your code calls to the external libraries objects and functions, you must provide externs, to prevent this renaming from happening.
但是,手工生成extern的工作量很大,因此,从给定的javascript库中自动生成适当的extern的最佳方法是什么?
But, it is a lot of work to produce the externs by hand, so, what is the best way to auto-generate the appropriate extern from a given javascript lib?
推荐答案
请参阅以下URL作为起点.我还建议将类型信息添加到外部,以最大程度地提高编译器收益.
See the following URL as a starting point. I would also recommend adding type information to your externs to maximize compiler benefit.
http://www.dotnetwise.com/Code/Externs/
这篇关于如何为Google Closure编译器自动生成外部代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!