taptapship / wiredep

Wire Bower dependencies to your source code.
MIT License
1.15k stars 142 forks source link

Change order of importing Bower dependencies #163

Closed drawcard closed 9 years ago

drawcard commented 9 years ago

Hi,

I am struggling a bit with isotope being called before a few other scripts in wiredep, I was wondering if there is a way we can re-order the dependencies to have them compile in a particular sequence?

CWSpear commented 9 years ago

Hmm... looks like we maybe need to add it to the documentation, but I believe you can override dependcies with the overrides option. In your bower.json:

{
  ...
  "overrides": {
    "isotope": {
      "dependencies": {
        "get-size": ">=1.1.8 <1.3",
        "matches-selector": ">=1 <2",
        "outlayer": "1.3.x",
        "masonry": "3.2.x",
        "jquery": ">=1.10"
      }
    }
  }
}

I don't know what dependency you're missing, but the example above adds jQuery at least version 1.10 to the dependencies.

Note that it replaces the dependencies with the ones you provide as opposed to merging them, so I included the other dependencies from isotope. See lines 149-159 of detect-dependencies.js of the current tag (2.2.2) to see where the magic happens.

CWSpear commented 9 years ago

I should specify: By adding jQuery as a dependency in this manner, it ensures that it will be included before isotope. So just do this for any scripts that must come before isotope. Similarly, you can add isotope to another module's dependencies to make sure isotope comes before that one.

drawcard commented 9 years ago

Thanks for the info!

mhulse commented 9 years ago

:+1: Thanks as well. Having same issue (CSS loading before other CSS dependencies).

dgreene1 commented 8 years ago

Can someone update the documentation to better describe this feature? I see something in the overrides section, but I believe that the json is wrong.

Currently it shows:

{
  ...
  "dependencies": {
    "package-without-main": "1.0.0"
  },

It should show something like:

{
  ...
  'package-that-needs-a-dependency',
  "overrides": {
     "package-that-needs-a-dependency": {
       "dependencies": {
         "new-dependency-you-are-adding": ">=1.1.8 <1.3",
         "old-dependency1": ">=1 <2",
         "old-dependency2": "1.3.x",
         "...": "3.2.x",
         "old-dependencyN": ">=1.10"
      }
    }
  },
drawcard commented 8 years ago

I'd suggest you edit the docs through Github & submit a pull request. That way the author can see your change request and either approve or reject.

HusseinElMotayam commented 7 years ago

In addition to the above, it is worth mentioning that the order of appearance in bower.json also affects the order of insertion done by wiredep if the dependencies do not matter.