forestryio / forestry.io

Forestry.io website
https://forestry.io
284 stars 174 forks source link

"Write Better JavaScript With Webpack" - Content Improvements #35

Open clschnei opened 6 years ago

clschnei commented 6 years ago

Just wanted to discuss some possible content changes to a recent blog post:

1. AMD

Webpack supports two standards for Module configuration: EcmaScript and CommonJS.

Even if it's unfashionable these days, webpack does support AMD module syntax. I think there is some value in including a brief example and explanation.

2. npm scripts

{
    "name": "my-webpack-demo",
    ...
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "./node_modules/webpack-cli/bin/webpack.js",
    "watch": "./node_modules/webpack-cli/bin/webpack.js --watch"
    },
    ...
}

A major advantage to using npm scripts is that we can use the namespace given to the cli tools, even if they're installed locally. Because when evaluating scripts, npm adds node_modules/.bin/ to the PATH environment variable. To highlight best practice, we can improve that snippet to read:

    "build": "webpack",
    "watch": "webpack --watch"
dwalkr commented 6 years ago

Thanks for your feedback! I agree that these are worth mentioning - I will provide an update to the article along with PR #34 which addresses your second point.