Re:The state of JavaScript modules
by aaron-lebo on Monday May 29, 2017 @06:03AM
(#14438355)
You don't need any of those if you are doing a node project, yeah, but if you want to do any work on the browser, you're gonna need to transpile anyway, so it's something people should be aware of.
Plus it's literally a 20 line config file to do so.
module.exports = {
entry: './src/app.js',
output: {
path: './bin',
filename: 'app.bundle.js',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
}
}
Include your app.bundle.js file in your webpage and you are good to go.Soon with the new webpack-cli, you'll just be able to 'webpack init':
https://medium.com/webpack/announcing-the-new-webpack-cli-75...
> Plain Javascript is just fine, especially with the improvements of ES6.
With React pushing hard to use JSX and discontinuing the in-browser JSX-to-JS transformation step, this is no longer completely true. You have to introduce the tooling from the start. (Yes, technologically you are not forced to use JSX and can use JS, but this is clearly declared as unwanted in the React ecosystem.)
Tools are here to solve problems. Don't bother with them until you have that problem yourself. If you one day decide you want to set up things like auto-minification, image compression, CSS-preprocessing, then look into build script options. Otherwise, it'll just overwhelm you.