Ad

How To Include Sub-dependencies In A Bower Repository

- 1 answer

I am creating a basic JS framework which I will be uploading to Github and hope to create a bower package so that I can install it in my other projects using Bower. I've never done this before but I could probably work that bit out.

The confusion comes with other dependencies which my Framework relies on. For example I want to specify Fastclick.js as a dependency and call it from within my framework like this.

window.addEventListener('load', function() {
    FastClick.attach(document.body);
}, false);

So my question is how am I supposed to do this? I assume I don't include the Fastclick library in my compiled "/dist" folder and that I can specify it in my Bower file so that when somebody installs my framework they will get the correct version of Fastclick? If that's the case then how do I make sure they load the library before my library? I don't have control over their HTML or the order in which they load scripts.

I could just copy and past the Fastclick code into my library, that is one option of course but I feel there must be a better way to do this. My brain is telling me that to do it properly would require some kind of JS module loading system though.

As you can tell. I don't really know what I'm talking about so apologies if the question is quite vague. Any help would be greatly appreciated though.

Ad

Answer

In the end I just included the whole Fastclick library in the code I was bundling up. It was the only way to ensure that it got loaded first in the final app. I could have just included it in the bower file and the final app would have needed to include it in their template in the right order, but this way seemed safer.

Ad
source: stackoverflow.com
Ad