Wednesday, April 29, 2015

Using npm to download bower packages

At work we are using npm packages along with require.js  and the webpack module bundler in our gulp build chain.  Overall this works quite nicely, however as many folks do, we were also using bower as the front-end package manager.  While there is nothing wrong with this, bower is just one more piece of the JavaScript jig-saw puzzle that was adding noise in our system.

My coworker had the idea to drop bower from the chain, and simply use npm in its place.  This change is very simple.  In our package.json file he added entries inside the dependencies object for each bower package we had a dependency on, including its repository path.

  "dependencies": {
    "Class.js": "git://github.com/arinet/Class.js", <-- bower package
    "angular": "=1.3.14", <-- npm package
    "angular-cookie": "git://github.com/ivpusic/angular-cookie"  <-- bower package
   }

This simple change has allowed us to clean up our build tasks and make the process just a little simpler.

No comments:

Post a Comment