CUF_meeting_knowledge_share icon indicating copy to clipboard operation
CUF_meeting_knowledge_share copied to clipboard

2014-12-23 CommonJS AMD CMD and UMD | 一周前端好文分享

Open hjzheng opened this issue 10 years ago • 1 comments

CommonJS AMD CMD and UMD (Zhen Ou Yun)

  • CommonJS
  • AMD(Asynchromous Module Definition)
  • CMD(Common Module Definition)
  • UMD(Universal Module Definition)

CommonJS

  • CommonJs 是服务器端模块的规范,Node.js采用了这个规范 (Modues/1.x)
  • 一个单独的文件就是一个模块
  • 加载模块是同步的

AMD(Asynchromous Module Definition)

  • AMD 是 RequireJS 在推广过程中对模块定义的规范化产出
  • AMD异步加载模块

CMD(Common Module Definition) 延自CommonJS Modules/2.0规范

  • CMD是SeaJS 在推广过程中对模块定义的规范化产出
  • 对于依赖的模块AMD是提前执行,CMD是延迟执行。不过RequireJS从2.0开始,也改成可以延迟执行(根据写法不同,处理方式不通过)
  • CMD推崇依赖就近,AMD推崇依赖前置

UMD(Universal Module Definition)

  • UMD是AMD和CommonJS的糅合
  • AMD 浏览器第一的原则发展 异步加载模块
  • CommonJS 模块以服务器第一原则发展,选择同步加载,它的模块无需包装(unwrapped modules)
  • UMD先判断是否支持Node.js的模块(exports)是否存在,存在则使用Node.js模块模式。 在判断是否支持AMD(define是否存在),存在则使用AMD方式加载模块

hjzheng avatar Dec 29 '14 09:12 hjzheng

一周前端好文分享

JavaScript Bad Parts (翻墙) http://johnkpaul.github.io/presentations/empirejs/javascript-bad-parts

decimal.js 处理某些JS数学运算的精度问题 https://github.com/MikeMcl/decimal.js?utm_source=javascriptweekly&utm_medium=email

Overview of ECMAScript 6 features https://github.com/lukehoban/es6features#template-strings

Chrome support ES6 template string (翻墙) https://twitter.com/addyosmani/status/541978036904554496?utm_source=javascriptweekly&utm_medium=email b4vugdcceaekhho

Five Traits of Well-Managed JavaScript http://www.ifwe.co/blog/posts/five-traits-of-well-managed-javascript/?utm_source=javascriptweekly&utm_medium=email

Planning A Front-end JavaScript Application http://developer.telerik.com/featured/planning-front-end-javascript-application/?utm_source=javascriptweekly&utm_medium=email

一个基于D3的开源, 风格简洁清爽的图形库 https://github.com/mozilla/metrics-graphics

performance工具合集 http://perf-tooling.today/

http://www.html-js.com/article/2126

requirejs 使用r.js压缩 http://developer.51cto.com/art/201305/392668.htm

什么是响应式Web设计?怎样进行? http://beforweb.com/node/6 https://developer.mozilla.org/zh-CN/docs/Web_Development/Mobile/Responsive_design

响应式设计 案例学习 http://beforweb.com/node/21

Dojo and NodeJS http://dojotoolkit.org/documentation/tutorials/1.10/node/

How to use NPM as a build tool https://github.com/keithamus/npm-scripts-example

hjzheng avatar Dec 29 '14 09:12 hjzheng