Javascript Module Systems in 30 Seconds

 •  Filed under javascript

Here's my attempt at the most compact description of Javascript module systems on the internet:

ES6 (aka ES Harmony)

import a from 'b'
export c


var a = require(‘b’)
exports = c

CommonJS is synchronous, and supports one file per module.

NodeJS is a CommonJS variant

var a = require(‘b’)
modules.exports = c


define(['a', 'b'], function(a, b) { return c })

AMD supports multiple files per module.

RequireJS is a loader that implements AMD and loads plain JS files as modules