I'm trying to summarize my knowledge about the most popular JavaScript package managers, bundlers, and task runners. Please correct me if I'm wrong:
npm
&bower
are package managers. They just download the dependencies and don't know how to build projects on their own. What they know is to callwebpack
/gulp
/grunt
after fetching all the dependencies.bower
is likenpm
, but builds flattened dependencies trees (unlikenpm
which do it recursively). Meaningnpm
fetches the dependencies for each dependency (may fetch the same a few times), whilebower
expects you to manually include sub-dependencies. Sometimesbower
andnpm
are used together for front-end and back-end respectively (since each megabyte might matter on front-end).grunt
andgulp
are task runners to automate everything that can be automated (i.e. compile CSS/Sass, optimize images, make a bundle and minify/transpile it).grunt
vs.gulp
(is likemaven
vs.gradle
or configuration vs. code). Grunt is based on configuring separate independent tasks, each task opens/handles/closes file. Gulp requires less amount of code and is based on Node streams, which allows it to build pipe chains (w/o reopening the same file) and makes it faster.webpack
(webpack-dev-server
) - for me it's a task runner with hot reloading of changes which allows you to forget about all JS/CSS watchers.npm
/bower
+ plugins may replace task runners. Their abilities often intersect so there are different implications if you need to usegulp
/grunt
overnpm
+ plugins. But task runners are definitely better for complex tasks (e.g. "on each build create bundle, transpile from ES6 to ES5, run it at all browsers emulators, make screenshots and deploy to dropbox through ftp").browserify
allows packaging node modules for browsers.browserify
vsnode
'srequire
is actually AMD vs CommonJS.
Questions:
- What is
webpack
&webpack-dev-server
? Official documentation says it's a module bundler but for me it's just a task runner. What's the difference? - Where would you use
browserify
? Can't we do the same with node/ES6 imports? - When would you use
gulp
/grunt
overnpm
+ plugins? - Please provide examples when you need to use a combination