taptapship / wiredep

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

Child dependency is not overriding bower main files #183

Closed bramcordie closed 9 years ago

bramcordie commented 9 years ago

I have a project that's split up in 2 parts. An app that does some basic routing and styling and a library that does the heavy lifting and contains most of the code. Bower is used to include the library in the app.

The library has its own overrides for main defined in the bower.json file. The app has overrides as well, but uses grunt to configure them. The overrides in the library aren't handled like expected when I build my app. When I copy-paste the overrides property from the library to the app bower.json file I do get the right main files.

Is this behaviour by design? I guess including all the child overrides could cause conflicts? Is there a way to explicitly use the overrides of a dependency?

mkoryak commented 9 years ago

yes, i consider this a bug. overrides in your dependencies' bower.json should be applied when pulling that dependency's dependencies. right now overrides ONLY from the app where you run wiredep are used.

This leads to having to copy overrides from all other bower.json files into your main one.

CWSpear commented 9 years ago

This is sort of beyond the scope of our control. There's a few other issues on the matter, most notably: #149, #105,

overrides is nonstandard and we've tried to work with the Bower peeps to make it a real thing with no luck.

The bottom line: overrides is only for the app developer, not for the component developer. See other threads for more.

Closing as duplicate.

mkoryak commented 9 years ago

I disagree that it is out of scope - if overrides exist in child deps, why not respect them?

I also have an app that consists of multiple repos which all have a bower.json with some overrides. right now if "the core" repo adds a new dep which requires an override, all repos which require core (10+) now need to have that override copied into them. Isnt the point of this tool to remove the need to do this exact thing?

CWSpear commented 9 years ago

As it's not a real standard, implementing it would be dangerous (again, those other threads discuss this). If we start supporting it, it opens us up to a lot of other edge cases and reduces stability. And for component developers to start supporting a non-standard is just asking for all sorts of trouble.

As you are both the app and component developer, it is a bit of an edge case. You're welcome to create a fork and try implementing this yourself.

But ultimately @stephenplusplus is the boss around here; but for me, the matter has been discussed, and I agree that it is unfortunate, but I don't believe the solution is found here in wiredep, but within Bower itself. Please add your two cents on the matter on these issues: bower/bower#585 and bower/bower.json-spec#27.

mkoryak commented 9 years ago

fair enough - I think the best path forward for me will be to write a gulp task that gets me the overrides from my dependencies, merges them and passes them to wiredep via the overrides option - does that sound like it would work?

CWSpear commented 9 years ago

It sounds like it could. You should share it here if you get it working well!

mkoryak commented 9 years ago

this seems to work, haven't run into any issues after 1 day of use :)

https://gist.github.com/mkoryak/6a1619bf7a84a1bb789f

CWSpear commented 9 years ago

Nice. Thank you for sharing.