简体   繁体   English

Javascript编译器/依赖管理器?

[英]Javascript compiler / dependency manager?

I have many JS files. 我有很多JS文件。 Some of them depend on each other. 其中一些相互依赖。 Many of them depend on jQuery. 他们中的许多人都依赖于jQuery。 I need tool that can accept one file as parameter, fetch all its dependencies transitively and compile them into one file in proper order (based on dependencies) 我需要可以接受一个文件作为参数的工具,可以传递地获取所有依赖项并按正确的顺序将它们编译成一个文件(基于依赖项)

Dependency information not always available inside files itself, so it would be nice to have it somewhere outside (xml file? folder structure?) 依赖信息并不总是在文件本身内部可用,所以将它放在外面的某个地方会很好(xml文件?文件夹结构?)

I've heard about Yahoo JS compiler, closure and so on, but I am not sure they do what I need. 我听说过Yahoo JS编译器,关闭等等,但我不确定它们是否符合我的要求。

Look: I have module "CustomerPage". 看:我有模块“CustomerPage”。 It sould include "validation.js" and "gui.js". 它应该包括“validation.js”和“gui.js”。 Both require jquery.js. 两者都需要jquery.js。 And "gui.js" also requires "myFunctions.js". 而“gui.js”也需要“myFunctions.js”。

I want some ant task or some script that would generate "CustomerPage.js" as result of all that files. 我想要一些ant任务或一些脚本,它们会生成所有文件的“CustomerPage.js”。

Tool should check dependency order, prevent double including and so on. 工具应检查依赖顺序,防止双重包括等。

My project could have around 500 js files, how could I live with out of this tool? 我的项目可能有大约500个js文件,我怎么能忍受这个工具? People says "use GWT", but I need plain JS. 人们说“使用GWT”,但我需要简单的JS。

You might want to look at one of the AMD-style module loaders, such as RequireJS . 您可能想要查看其中一个AMD样式的模块加载器,例如RequireJS Some of these can do what you want for precompiling, and can run in a development mode which makes it easier to debug by including all the files directly. 其中一些可以执行预编译所需的操作,并且可以在开发模式下运行,通过直接包含所有文件,可以更轻松地进行调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM