Instantly share code, notes, and snippets.

Embed
What would you like to do?
ES6 Module Syntax Table
// default exports
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}
// variables exports
export var foo = 1;
export var foo = function () {};
export var bar; // lazy initialization
export let foo = 2;
export let bar; // lazy initialization
export const foo = 3;
export function foo () {}
export class foo {}
// named exports
export {foo};
export {foo, bar};
export {foo as bar};
export {foo as default};
export {foo as default, bar};
// exports from
export * from "foo";
export {foo} from "foo";
export {foo, bar} from "foo";
export {foo as bar} from "foo";
export {foo as default} from "foo";
export {foo as default, bar} from "foo";
export {default} from "foo";
export {default as foo} from "foo";
// default imports
import foo from "foo";
import {default as foo} from "foo";
// named imports
import {bar} from "foo";
import {bar, baz} from "foo";
import {bar as baz} from "foo";
import {bar as baz, xyz} from "foo";
// glob imports
import * as foo from "foo";
// mixing imports
import foo, {baz as xyz} from "foo";
import * as bar, {baz as xyz} from "foo";
import foo, * as bar, {baz as xyz} from "foo";
export const bar;
// const variables must have an initializer
export foo;
// Unexpected token identifier, invalid named export syntax
export function () {}
// Unexpected token (, use a function declaration instead
export function default () {}
// Unexpected token default
import foo;
// Missing from after import
import { foo, bar };
// Missing from after import
import foo from bar;
// Invalid module specifier
import default from "foo";
// Unexpected token default
export default from "foo";
// Unexpected token from
export {default};
// Missing from after export
export *;
// Missing from after export
import {default as foo};
// Missing from after import
import * from "foo";
// Missing as after import *'
export default = 42;
// Unexpected token =
import {bar as default} from "foo";
// Unexpected token default
@tjbenton

This comment has been minimized.

tjbenton commented Oct 12, 2015

This is exactly what I was looking for, Thank you!!

@qmcree

This comment has been minimized.

qmcree commented Sep 29, 2016

Thanks man

@albertojacini

This comment has been minimized.

albertojacini commented Nov 12, 2016

Yes, very clear, very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment