├── .gitignore
├── README.md
├── index.html
├── package.json
├── src
├── data
│ └── users.js
├── main.js
└── math
│ └── addition.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **This is the source for the [Egghead.io](https://egghead.io/) ES6 lesson [ES6 Modules - Import and Export (ES2015)](https://egghead.io/)**
2 |
3 | ### To Run/Develop
4 |
5 | **npm global dependencies**
6 | - BrowserSync
7 | - Webpack
8 |
9 | ```
10 | npm install
11 | npm start
12 | ```
13 |
14 | This should open your web browser with the BrowserSync server running and watching for changes.
15 |
16 | Open up the console in your dev tools!
17 |
18 | See `package.json` for `npm start` details.
19 |
20 | ## ES6 Modules
21 |
22 | ES6 (ES2015) introduces a [standardized module format](http://babeljs.io/docs/learn-es2015/#modules) to Javascript. We'll take a look at the various forms of defining and importing modules. Using [Webpack](http://webpack.github.io/) to bundle up our modules and [Babel](http://babeljs.io/) to transpile our ES6 into ES5, we'll put this new module syntax to work within our project. Then we'll examine how to import 3rd party packages from npm, importing [lodash](https://lodash.com/) with the `_` underscore alias using the ES6 module syntax.
23 |
24 | **Some Common Import/Export Variations**
25 | ```js
26 | import {someFunction} from 'someModule';
27 |
28 | import {someFunction as someAlias} from 'someModule';
29 |
30 | import * as someModule from 'someModule';
31 |
32 | export function someFunction() {/* */};
33 |
34 | function someFunction() {/* */}; export {someFunction};
35 |
36 | function someFunction() {/* */}; export {someFunction as someAlias};
37 | ```
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |