Skip to content

Instantly share code, notes, and snippets.

@gauravchl
Last active April 3, 2016 08:40
Show Gist options
  • Save gauravchl/8eaa9324779fa7907be73a97721c795f to your computer and use it in GitHub Desktop.
Save gauravchl/8eaa9324779fa7907be73a97721c795f to your computer and use it in GitHub Desktop.
ES6 import export cheat

module.js

var x = 10;
var y = 20;
export {x, y};
export default x;

main.js

import {x, y} from 'module'; 
import z from 'module'; // will import default
console.log(x); // 10
console.log(y); // 20
console.log(z); // 10


imports/startup/client/index.js

export default name = "John Doe";

main.js

import item from 'imports/startup/client/' // will look for index.js
console.log(item); // "john doe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment