Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's resolutions and overrides in a `bower.json` file?

Tags:

json

bower

In a bower.json file, what are the resolution and overrides properties used for?

{
  "name": "name",
  "dependencies": {
    "angular": "~1.4.8",
    ...
    "jquery": "2.2.4"
  },
  "overrides": {
    "ionic": {
      "main": [
        "release/js/ionic.js",
        "release/js/ionic-angular.js"
      ]
    }
  },
  "resolutions": {
    "angular-ui-router": "~0.2.15",
    "angular": "~1.5.3"
  }
}
like image 255
Asim K T Avatar asked Dec 26 '16 09:12

Asim K T


2 Answers

Resolution

The resolution section appears when you need to resolve dependency versions (after bower install) when conflicts occur. It's for making a decision regarding which concrete version of a dependency to use when the need to resolve dependency conflicts arises - bower automatically injects this decision as the "resolution" record. So the next time a conflict occurs (when updating the dependency tree, etc), the resolved version will be based on the "resolution" data in your configuration file.

An example dependency version conflict resolution prompt. The text in the image states: "Unable to find a suitable version for ember, please choose one: 1) ember#~1.0.0 which resolved to 1.0.1 and is required by ember-data#0. 2) ember#1.5.1 which resolved to 1.5.1 and required by melodrama"

Overrides

Overrides section is used to override the file(s) references when pointing to dependent library.

Task runners in most cases use the bower configuration library metadata to inject links to these libraries into a page's content. When we want to inject a bootstrap link into a page, we do not need to go into the "bower_components" folder, find the package, and investigate the file content. We can use the component metadata to find the main, injectable file reference.

The "overrides" section is used to change this data to use another file, or even a set of files, as a package's main entry point.

An example overrides section configuration for the bootstrap-sass-official package.

like image 53
VadimB Avatar answered Nov 19 '22 01:11

VadimB


Multiple Bower packages can list different versions of the same library as a dependency. The resolutions section specifies which version of the library to use whenever this type of situation occurs. If not specified in bower.json, you will receive a command line prompt upon running bower install.

The overrides section makes it possible to override default paths to assets installed through Bower when using a task runner like Gulp. If you intend to move files from their default location in the bower_components folder to accommodate your build process, for example, it could prove handy in this type of setup.

like image 4
Alex Denisov Avatar answered Nov 19 '22 03:11

Alex Denisov