JavaScript Modules


  • import defaultMember from 'module';
  • import { memberA, memberB, ... } from 'module';
  • import * as module from 'module';
  • import { memberA as a, memberB, ... } from 'module';
  • import defaultMember, * as module from 'module';
  • import defaultMember, { moduleA, ... } from 'module';
  • import 'module';


From MDN (emphasis added):

This feature is not implemented in any browsers natively at this time. It is implemented in many transpilers, such as the Traceur Compiler, Babel or Rollup.

Many transpilers are able to convert ES6 module syntax into CommonJS for use in the Node ecosystem, or RequireJS or System.js for use in the browser.

It is also possible to use a module bundler like Browserify to combine a set of inter-dependent CommonJS modules into a single file which can be loaded in the browser.