AMD and CommonJS: Competing, but Equally Valid Standards
Both AMD and CommonJS are valid module formats with different end goals.
AMD adopts a browser-first approach to development, opting for asynchronous behavior and simplified backward compatibility, but it doesn’t have any concept of file I/O. It supports objects, functions, constructors, strings, JSON and many other types of modules, running natively in the browser. It’s incredibly flexible.
CommonJS on the other hand takes a server-first approach, assuming
synchronous behavior, no global baggage, and attempts
to cater for the future (on the server). What we mean by this is that
because CommonJS supports unwrapped modules, it can feel a little more
close to the ES.next/Harmony specifications, freeing us of the define() wrapper that AMD enforces. CommonJS
modules however only support objects as modules.
UMD: AMD and CommonJS-Compatible Modules for Plug-ins
For developers wishing to create modules that can work in both browser and server-side environments, existing solutions could be considered a little lacking. To help alleviate this, James Burke, a number of other developers, and I created Universal Module Definition (UMD; https://github.com/umdjs/umd).
UMD is an experimental module format that allows the definition of modules that work in both client and server environments with all or most of the popular script-loading techniques available at the time of writing. Although the idea of (yet) another module format may be daunting, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access