【问题标题】:How do i use the closurebuilder for compiling and minifying scripts我如何使用closurebuilder来编译和缩小脚本
【发布时间】:2012-03-12 08:46:11
【问题描述】:

我对闭包库完全陌生,并且正在开始。我刚刚在我的 windows7 机器上安装了 Python,想要连接和缩小脚本。我按照here 记录了一些命令,但没有任何收获。这里有一些参数

  • Python 安装在c:\python27\python.exe

  • c:\closure\ 中的闭包库

  • c:\closure\bin\build\compiler.jar 中的闭包编译器

  • 我在D:\projects\closureapp\js\index.js中的Javascript文件

index.js 的内容如下

/// <reference path="../closure/base.js" />
/// <reference path="../closure/dom/dom.js" />


/*Hello world into Closure Library Example*/

//Load the dom module
goog.require("goog.dom");


//refer the document body
var pageBody = document.body;

//after the body is loaded execute and add a header
pageBody.onload = function () {

    //create a header for the page
    var pageHeader = goog.dom.createDom('h1', { 'style': 'background-color:#EEE' }, 'Hello world!');

    //append the header to the document body
    goog.dom.appendChild(pageBody, pageHeader);

};

我执行了下面的命令来生成编译好的 javascript 但没有任何收获

c:\python27\python.exe c:\closure\bin\build\c
losurebuilder.py --root=closure/ --root=d:\Projects\closureapp\js\ --
output_mode=compiled  --compiler_jar=compiler.jar > d:\Projects\closureapp\js\output.js

我收到一些奇怪的消息,如下所示

c:\closure\bin\build\closurebuilder.py: Building dependency tree..
Traceback (most recent call last):
  File "c:\closure\bin\build\closurebuilder.py", line 257, in <module> main()
  File "c:\closure\bin\build\closurebuilder.py", line 204, in main tree = depstree.DepsTree(sources)
  File "c:\closure\bin\build\depstree.py", line 56, in __init__ raise NamespaceNotFoundError(require, source)
  depstree.NamespaceNotFoundError: Namespace "goog.async.Deferred" never provided.
  Required in Source closure\messaging\portchannel.js

【问题讨论】:

    标签: google-closure-compiler google-closure google-closure-library


    【解决方案1】:

    【讨论】:

    • --root=third_party 按照约翰的说法
    • 这是否意味着闭包编译器已经死了? 4 年前确定的一个大问题基本上会使记录的示例不起作用:developers.google.com/closure/library/docs/closurebuilder 我喜欢闭包编译器的想法,但似乎已经从难以使用变为几乎无法使用。
    • 一点也不。您只需要查看 github 项目就知道它仍在积极开发中。它以什么方式变得更难使用?然而,据我所知,python 脚本几乎没有什么用处。至少我从不使用它们。
    • @John 你从不使用它们?你如何计算依赖关系?编译器现在能做到吗?
    猜你喜欢
    • 2012-11-14
    • 2016-09-15
    • 2013-04-26
    • 1970-01-01
    • 2023-03-22
    • 2022-11-17
    • 1970-01-01
    • 2012-06-12
    • 1970-01-01
    相关资源
    最近更新 更多