jpcasa
12/20/2018 - 3:01 AM

ES6 Modules

ES6 Modules

import { projectId as id, projectName } from 'module.js';

console.log(`${id} has id: ${projectName}`);
export let projectId = 99;
export let projectName = 'BuildIt';

// lib/counter.js
export let counter = 1;

export function increment() {
  counter++;
}

export function decrement() {
  counter--;
}


// src/main.js
import * as counter from '../../counter';

console.log(counter.counter); // 1
counter.increment();
console.log(counter.counter); // 2