Search code examples
node.jsbowerbrowserifycommonjs

Would bower only be useful for css if using browserify and node.js commonJs


I see from this stack overflow question the difference between bower and npm:

npm is used for managing Node.js modules, but can work on the front-end too when combined with Browserify or WebPack. npm does nested dependency tree, so your dependencies can have their own dependencies which can have their own... which basically can mean a lot of versions of the same modules together, but not a problem on the server, and Browserify handles this by only bundling the appropriate modules.

Bower is used for the front-end only and is optimized with that in mind. It requires a flat dependency tree, putting the burden of dependency resolution on the user, which makes sense on the client as we want to minimize the number of includes,

My question:

If we are using Browserify, Is there much point to using bower for managing front end dependencies, other than the following 2 benefits?

  • managing front end css modules includes, e.g. pure.css or bootstrap.css,
  • including 1 or 2 large JavaScript libraries e.g. Angular, React or jQuery as a global version on the page separate to your Browserify bundle - would that be a benefit to reduce bloat from your bundle.js, even if it means an additional http request

Solution

  • You can also get the 2 benefits you mention using npm:

    • Bootstrap and PureCSS are available as npm packages
    • You can install large libraries with npm and create separate bundles for them using Browserify

    This is also a debate we are having in my company and I am starting to opt for a npm-only approach.

    More on this: