// Exporting individual features
export let name1, name2, …, nameN;
// also var, const
export let name1 = …, name2 = …, …, nameN;
// also var, const
export function functionName(){...}
export class ClassName {...}
// Export list
export { name1, name2, …, nameN };
// Renaming exports
export { variable1 as name1, variable2 as name2, …, nameN };
// Exporting destructured assignments with renaming
export const { name1, name2: bar } = o;
// Default exports
export default expression;
export default function (…) { … }
// also class, function*
export default function name1(…) { … }
// also class, function*
export { name1 as default, … };
// Aggregating modules
export * from …;
export { name1, name2, …, nameN } from …;
export { import1 as name1, import2 as name2, …, nameN } from …;
export { default } from …;
import defaultExport from "module-name";
import { default as alias } from "module-name";
import * as name from "module-name";
import { export } from "module-name";
import { export as alias } from "module-name";
import { export1 , export2 } from "module-name";
import { foo , bar } from "module-name/path/to/specific/un-exported/file";
import { export1 , export2 as alias2 , [...] } from "module-name";
import defaultExport, { export [ , [...] ] } from "module-name";
import defaultExport, * as name from "module-name";
import "module-name";
var promise = import("module-name");
// Sample : module.js
function cube(x){
return x * x * x;
}
export {cube};
// app.js
import { cube } from 'module.js';
console.log(cube(3)); // 27