Difference between module type in tsconfig.json
Solution 1:
CommonJS pattern (or nodejs):
var someOtherFunction = require('./someOtherFunction.js');
exports.add = function() {
var sum = 0, i = 0, args = arguments, l = args.length;
while (i < l) {
sum += args[i++];
}
return sum;
}
ES6 pattern:
import someOtherFunction from './someOtherFunction.js';
export function add() {
var sum = 0, i = 0, args = arguments, l = args.length;
while (i < l) {
sum += args[i++];
}
return sum;
}
AMD pattern:
define(['someOtherFunction'], function () {
return function () {
var sum = 0, i = 0, args = arguments, l = args.length;
while (i < l) {
sum += args[i++];
}
return sum;
};
});
Asynchronous Module Definition (AMD) is the most popular for client-side code, while node.js modules (an extension to CommonJS Modules/1.1) is the leading pattern in server-side environments.
Universal Module Definition (UMD) is a set of boilerplate recipes that attempt to bridge the differences between AMD and node.js, allowing engineers to author their code bases in a single format, rather than author in both formats or convert to the other format in a build step.
ES5 is the normal JavaScript that you used to see.
You'd be using ES6 for Angular2, also known as ECMAScript 2015.