现有的JavaScript框架是否包含CommonJS? [英] Will existing JavaScript frameworks incorporate CommonJS?

查看:72
本文介绍了现有的JavaScript框架是否包含CommonJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript框架,如Prototype,jQuery,YUI,MooTools,Dojo等。所有这些似乎都是针对客户端开发人员的,重点是使用更少的代码实现更高效的通用用户交互模式。

JavaScript frameworks like Prototype, jQuery, YUI, MooTools, Dojo, et al. all seem to target client-side developers, with the focus on enabling common user interaction patterns to be implemented more efficiently and with less code.

随着服务器端的出现JavaScript,这些框架是否打算采用CommonJS标准,以便为服务器端JavaScript重用其库函数,还是允许Node和Narwhal等替代框架处理服务器端用例?

With the emergence of server-side JavaScript, do these frameworks intend to incorporate the CommonJS standards to enable reuse of their library functions for server-side JavaScript, or will they allow alternative frameworks like Node and Narwhal to handle the server-side use case?

(我意识到这个问题危险地接近可以讨论但没有回答的问题,但我认为Stack Overflow社区实际上可以用特定的引用回答这个问题。)

(I realize that this question is dangerously close to one which can be discussed but not answered, but I presume the Stack Overflow community can actually answer the question with specific references.)

推荐答案

这是我的看法(我是YUI开发人员):

Here's my take (I'm a YUI Developer):

好像在那里是你的问题的两个角度。

It seems like there are two angles to your question.

一个是关于模块打包和重用格式(CommonJS),另一个是关于客户端JS库及其ap的一般概念服务器端开发的可行性。

One is about module packaging and reuse formats (CommonJS) and the other is about the general idea of client side JS libraries and their applicability to server side development.

除了说YUI 3固有地使用了正式的模块系统之外,我不是真正适合回答包装角度的人从第一天起封装和交付代码,它就是它的设计不可或缺的一部分。我们一直在讨论提供适配器或构建步骤来将这些模块传递/转换为CommonJS。参与此领域的YUI社区中的其他人可能会在此处添加更多有价值的信息。

I'm not really the right person to answer the packaging angle, other than to say that YUI 3 inherently has used a formal module system for encapsulating and delivering code since day one, and it's been integral to it's design. Providing an adaptor or build step to deliver/translate these modules to CommonJS is something we've been discussing. Other folks in the YUI community who have been involved in this area may have more valuable information to add here.

在第二个角度,我可以告诉您服务器是YUI的第一类目标环境。它在服务器上和在客户端上一样适用。有一组模块只在一个环境或其他环境中有意义,但是大部分的库可以在栅栏的两侧使用,并且有意识地建立这样做。

On the second angle, I can tell you that the server is a first class target environment for YUI. It is just as applicable on the server as on the client. There are a set of modules which only make sense in one environment or the other of course, but a large chunk of the library, can be used on both sides of the fence and it is consciously built to do this.

例如,YUI中的大块模块提供了基础结构和实用程序,它们与服务器上的应用程序开发一样适用于客户端(自定义事件,属性,基础,Intl,把手,IO,YQL,DataType,DataSchema,JSON等......)。

For example, a large chunk of the modules in YUI provide infrastructure and utilities which are just as applicable to app development on the server as on the client (Custom Event, Attribute, Base, Intl, Handlebars, IO, YQL, DataType, DataSchema, JSON etc...).

这从一开始就是设计目标 - 它是一个网络(缺乏一个更好的术语 - 我指的是JS / HTML / CSS技术堆栈)应用程序开发库,而不仅仅是一个DOM抽象库,或者只是一个Widget库。

That's really been the design goal from the start - It's a web (for lack of a better term - I'm referring to the JS/HTML/CSS technology stack) application development library, not just a DOM Abstraction Library, or just a Widget Library.

Dav Glass有一篇博客文章,内容很丰富:

Dav Glass has a blog post with some great content on the subject:

http://www.yuiblog.com/blog/2011/11/07/rocking-yui-on-node-js-and-mob ile /

您还可以查看3.5.0 PR:

You can also check out the 3.5.0 PRs:

http://stage.yuilibrary.com/yui/docs/yui/nodejs.html

这篇关于现有的JavaScript框架是否包含CommonJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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