如何管理客户端JavaScript依赖项? [英] How to manage client-side JavaScript dependencies?

查看:226
本文介绍了如何管理客户端JavaScript依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然有很好的解决方案来管理服务器端的依赖,我找不到任何满足我所有的需要一个一致的客户端JavaScript依赖管理工作流。我想满足这5个要求:

Although there are great solutions to manage dependencies on the server side, I could not find any that satisfies all my needs to have a coherent client side JavaScript dependency management workflow. I want to satisfy these 5 requirements:


  1. 以类似于npm的package.json bower bower.json

  2. 它应该有灵活性指向我的 dependency.json中的git repo或实际的js文件/ $> code>

  3. 它应该将所有库文件缩小并命名为单个文件,例如ender - 这是我需要放在客户端中的< script> 标签中的唯一js文件

  4. 它应该像BoxJS一样对CoffeeScript提供现成的支持 4 (现已结束)

  5. 在浏览器中,我应该可以使用需要样式:

  1. Manage my client side dependencies in a format similar to npm's package.json or bower's bower.json
  2. It should have the flexibility to point to git repo or actual js files (either on web or locally) in my dependency.json file for lesser known libraries (npm let you point to git repos)
  3. It should minify and namespace all libraries into a single file like ender - that's the only js file I would need to put in my <script> tag in the client side
  4. It should have out of box support for CoffeeScript like BoxJS4 (now dead)
  5. In the browser, I should be able to use either require style:

var $ = require('jquery');
var _ = require('underscore');

或更好的做法是 headjs style:

Or better yet, do headjs style:

head.js(['jquery', 'underscore', 'mylib'], function($, _, mylib) {
  // executed when all libraries are loaded
});


如果没有这样的单一工具,是工具的最佳组合,即工具链,我可以使用类似 volo (或 grunt )?

If no one such single tool exists, what is the best combination of tools i.e. a tool-chain that I can combine using something like volo (or grunt)?

我已经研究了我在这里链接的所有工具,他们只满足我的要求最好单独。所以,请不要再发布这些工具。我只接受一个答案,提供一个工具,满足我的所有要求,或者如果有人发布一个具体的工作流/脚本/工具示例的多个这样的工具的工具链,也满足我的要求。谢谢。

I have already researched all the tools I have linked to in here and they satisfy only upto 3 of my requirements at best individually. So, please don't post again about these tools. I would only accept an answer that provides a single tool that satisfies all 5 of my requirements or if someone posts a concrete workflow/script/working example of a toolchain of multiple such tools that also satisfies all my requirements. Thank you.

推荐答案

另一个满足我最近发布的标准的框架: http://duojs.org/ (并且还支持将其他资源(如CSS作为依赖关系)处理。)

Another framework that satisfies all my criterion released recently: http://duojs.org/ (and also supports treating other resources like CSS as dependencies).

这篇关于如何管理客户端JavaScript依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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