如何使用Google Closure编译器 [英] How to use Google Closure compiler

查看:425
本文介绍了如何使用Google Closure编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从closurebuilder.py脚本迁移到 Closure编译器,因为消息:

I'm trying to migrate from the closurebuilder.py script to the Closure compiler because of this message:

../../closure-library/closure/bin/build/closurebuilder.py: Closure Compiler now natively understands and orders Closure dependencies and

优先使用此脚本执行JavaScript编译

is prefererred over using this script for performing JavaScript compilation

因为我正在使用 Google Closure Library OpenLayers 3 ,我如何调用编译器(compiler.jar)

Since I'm using Google Closure Library and the OpenLayers 3, how do I have to call the compiler (compiler.jar) to


  • 构建myapp-deps.js依赖文件

  • 构建仅包含已使用OL3的缩小版myapp.js和CL类

  • 使用预先计算的OL3和CL依赖文件(例如ol3-deps.js)构建两者

让我们进一步说一切都位于以下结构中。这几乎等于我自己的项目,但直接在这里发布是大而复杂的。

Let's further say everything is located in the following structure. This almost equals to my own project but it is to big and complex to be posted here directly.

project/
    src/
        js/
            <some other js "required" in myapp.js>
            myapp.js
            myapp-deps.js                 # This should be the dependency file
        lib/
            closure/goog/...
            third_party/closure/goog/...  
            myapp.js                      # This should be the minified version
    ol3/

我很感谢每一个提示。

推荐答案

Closure Compile现在可以管理Closure依赖项,即使用<$定义的依赖项JavaScript代码中的c $ c> goog.provide 和 goog.require 。因此,您不再需要使用 closurebuilder.py 脚本。这就是它被弃用的原因。

Closure Compile can now manage Closure dependencies, that is dependencies defined with goog.provide and goog.require in the JavaScript code. So you do not need to use the closurebuilder.py script anymore. And this is why it's deprecated.

请参阅维基页 https://github.com/google/closure-compiler/wiki/Manage-Closure-Dependencies ,了解Closure Compiler提供的选项/标志。

See the wiki page https://github.com/google/closure-compiler/wiki/Manage-Closure-Dependencies to know about the options/flags Closure Compiler provides for that.

关于生成 deps 文件,这可能是为了调试/开发目的逐个加载js文件所必需的,仍然需要Closure Library的 depswriter.py 脚本。 Closure Compiler没有工具或标志。阅读 https://github.com/google/closure-library/issues/382 depswriter.py 在Google中不再使用,但看起来仍然保留了脚本。

Regarding the generation of deps files, which may be necessary for loading js files one by one for debugging/development purposes, you will still need Closure Library's depswriter.py script. Closure Compiler has no tool or flag for that. Reading https://github.com/google/closure-library/issues/382 depswriter.py is no longer used within Google, but it looks like the script is still maintained.

这篇关于如何使用Google Closure编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆