tldr; I’m asking about best practices when installing a bower dependency which brings along it’s own dependencies.
I’ve come across a bit of a problem with the Javascript bower/gulp workflow.
In my example, I installed Isotope via bower install isotope --save
. Now, Isotope’s bower.json has it’s main attribute set like so: "main": "js/isotope.js"
, which is not actually the packaged version. That’s easy enough to override in my main bower.json:
"overrides": {
"isotope": {
"main": ["./dist/isotope.pkgd.min.js"]
}
}
The problem is that Isotope brings along a whole bunch of it’s own dependencies. In my case it is:
"dependencies": {
"get-size": "~1.2.2",
"matches-selector": ">=1 <2",
"outlayer": "~1.4.0",
"masonry": "~3.3.0",
"fizzy-ui-utils": "~1.0.1"
},
These all get installed by npm
, and all have main
files defined. So bower-main-files gets them all, gulp concatenates and minifies them all, and I get a giant Javascript file which doesn’t work at all.
Now, I’ve overridden them all specifically, which seems to work:
"overrides": {
"isotope": {
"main": ["./dist/isotope.pkgd.min.js"]
},
"get-size": {
"ignore": true
},
"matches-selector": {
"ignore": true
},
"outlayer": {
"ignore": true
},
"masonry": {
"ignore": true
},
"fizzy-ui-utils": {
"ignore": true
},
}
However, this feels fragile and rather arbitrary. I’m sure Isotope isn’t the only useful Bower package to bring along it’s dependencies in this way. Is there a better way of handling these instances?