in Frontend Tech, Programming

ECMAScript 6 modules

AMD is new standard in my book and I am glad that ECMAScript 6 introduces modules.

This blog has great depth of the new ECMAScript 6 module.

From the spec, importing a module is very flexible in ECMAScript 6, which I like a lot.
Examples are (also found in the blog above):

  • import { square } from ‘lib/calc’;
  • import { square, MY_CONSTANT } from ‘lib/calc’;
  • import ‘lib/calc’ as c;
  • import { square as squ } from ‘lib/calc’;

As you can see there are 4 ways to import.

Aslo it has requirejs like syntax such as:

which is very similar to AMD syntax