Language-level support for modules for component definition. Codifies patterns from popular JavaScript module loaders (AMD, CommonJS). Runtime behaviour defined by a host-defined default loader. Implicitly async model – no code executes until requested modules are available and processed.
ES6
export function sum(x, y) {
return x + y;
}
export var pi = 3.141593;
Javascript
exports.sum = sum;
function sum(x, y) {
return x + y;
}
var pi = exports.pi = 3.141593;
ES6:
import * as math from "lib/math";
Javascript
var math = require("lib/math");
ES6:
export default function(x) {
return Math.exp(x);
}
Javascript
module.exports = function (x) {
return Math.exp(x);
};