CommonJS
Used in node.js
mod.js
exports.foo = () => {}
app.js
const mod = require("mod")
mod.foo()
AMD (Asynchronous Module Definition)
define(['jquery'] , function ($) {
return function () {};
});
ES2015(ESCMA6)
foo.js
export const a = {} // `equals exports.a = {}` of CommonJS
// or
module.exports = {a: {}}
app.js
import {a} from foo // `equals const a = require("foo").a` of CommonJS
// or
import * as foo from "foo"
const a = foo.a