命令行 Google Closure 提供了哪些标准 extern,如何通过 Java 接口获取它们?
我目前正在使用这段代码:
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
List<JSSourceFile> externs = new ArrayList<JSSourceFile>();
externs.add(JSSourceFile.fromFile(extern_src));
List<JSSourceFile> primary = new ArrayList<JSSourceFile>();
primary.add(JSSourceFile.fromFile(tmp));
compiler.compile(externs, primary, options);
但是,我遇到了很多这样的错误:
Error message: JSC_UNDEFINED_VARIABLE. variable Array is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable TypeError is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Object is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable arguments is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Number is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Math is undefined
显然,这些都是不正确的:诸如 Object
和 arguments
等是语言。我可以做什么来解决这个问题?
I'm currently using this code:
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
List<JSSourceFile> externs = new ArrayList<JSSourceFile>();
externs.add(JSSourceFile.fromFile(extern_src));
List<JSSourceFile> primary = new ArrayList<JSSourceFile>();
primary.add(JSSourceFile.fromFile(tmp));
compiler.compile(externs, primary, options);
However, I get lots of errors like this:
Error message: JSC_UNDEFINED_VARIABLE. variable Array is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable TypeError is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Object is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable arguments is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Number is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Math is undefined
Obviously, these are not correct: things like Object
and arguments
etc a core part of the language. What can I do to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否看过 Michael Bolin 关于使用 Java API 的博客?
http://blog.bolinfest.com/2009/11 /calling-closure-compiler-from-java.html
Did you see Michael Bolin blog regarding using the Java API?
http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html