Typescript模块创建AMD与Common JS [英] Typescript module creation AMD vs Common JS

查看:83
本文介绍了Typescript模块创建AMD与Common JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何Typescript专家都可以澄清使用Typescript时何时以及为何选择AMD vs Common JS进行模块创建吗?

Can any Typescript experts clarify when and why you would choose AMD vs Common JS for module creation when using Typescript?

推荐答案

浏览器中使用了AMD(例如RequireJS):原因是它允许并行下载文件,因为网络延迟是一个主要瓶颈.

AMD is used in the browser (e.g RequireJS) : reason is it allows parallel download of files as network latency is a major bottleneck.

CommonJS用于服务器(例如nodejs)中,可以从磁盘上预先读取文件,但是在尝试使用其中包含的代码之前,您不希望读取文件.

CommonJS is used in the server (e.g. nodejs) where files can be read from disk upfront, but you don't want to read a file till you try to use the code it contains.

以下是有关该主题的视频,进一步解释了此问题: http://www.youtube.com/watch?v = KDrWLMUY0R0

Here is a video on the subject that further explains this : http://www.youtube.com/watch?v=KDrWLMUY0R0

这篇关于Typescript模块创建AMD与Common JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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