Lemoncode / webpack-1.x-by-sample

Learn webpack 1.x by sample
http://www.lemoncode.net/
MIT License
27 stars 17 forks source link

00 Intro/01 Import: Documentation and steps to reproduce #23

Closed crsanti closed 8 years ago

crsanti commented 8 years ago

Hi, I found some issues on this guide:

We will start from sample 00 Demo and add a new javascript that will hold a simple algorithm to calculate the average of an score array.

The name 00 Demo should be 00 BoilerPlate.

  • Now let's update students.js to import that file and consume it.
import {averageService} from "./averageService"

const scores = [90, 75, 60, 99, 94, 30]
...

Importing {averageService} will fail because averageService.js has only getAverage function. This should be changed to: import {getAvg} from "./averageService;".

  • Now let's run webpack from the command prompt and click on the index.html, we can see that the new average function is up and running and has been included in the bundle.js file.

enter image description here

The displayed figure has no sense with the text above.

  • Other ways to use modules, one popular way is to use "export default" indicating that by default the average function will be the one exported, then we can directly use an import "alias" and this will point out to our averarge function.

I'm sure my English is not from Cambridge but how does this sound? There are other ways to use modules, one popular way is to use "export default" indicating...

import {averageService} from "./averageService"
...

Add missing trailing semicolon :+1:. Add JavaScript syntax highlighting.

brauliodiez commented 8 years ago

Good stuff, please don't hesitate creating a new branch and fixing what you have mentioned. I think the nonsense pic is fixed in a readme_es version but not on the english one.