Skip to content

Instantly share code, notes, and snippets.

@don-smith
Last active October 17, 2015 05:50
Show Gist options
  • Save don-smith/96fb0ae2904f86c86e66 to your computer and use it in GitHub Desktop.
Save don-smith/96fb0ae2904f86c86e66 to your computer and use it in GitHub Desktop.
A few examples of exporting and importing ES6 modules

ES6 Modules

To run locally, make sure you have node installed and:

git clone https://gist.github.com/96fb0ae2904f86c86e66.git es6-modules
npm install -g babel
babel-node es6-modules
export function gar() {
console.log('bar.gar');
}
export function zar() {
console.log('bar.zar');
}
function hidden() {
console.log('no see me');
}
export default (g) => {
console.log('foo is fooing with ' + g);
};
export const goo = 'foo.goo';
import foo, {goo} from './foo';
import {zar as z} from './bar';
import * as bar from './bar';
if(bar.hidden) bar.hidden();
foo(goo);
bar.gar();
bar.zar();
z();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment