我如何使用closurebuilder来编译和缩小脚本

时间:2012-03-12 08:46:11

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

我是关闭图书馆的新手,我开始了。我刚刚在我的windows7机器上安装了Python,想要连接和缩小脚本。我按照记录的here执行了一些命令但没有获益。这里有一些参数

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

  • 中的Python
  • 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

1 个答案:

答案 0 :(得分:4)