stephenplusplus/grunt-wiredep

Question: Is there a way to force order of scripts?

dtracers opened this issue · 5 comments

I have a component that I personally made that depends on jquery but when using this plugin it is inserted above it.
Is there a way to force wiredep to order the installation in a different way?

What's your component?

wiredep uses the dependencies in a component's bower.json. So if you properly set jquery as a dependency there, wiredep knows that jquery needs to be included before it.

well basically I have am doing two things. (One of which is a little odd...)
the first one is I a library that uses and changes a method (outside of jquery) so that the $(document).ready does not fire till after the webcomponentjs fires its events. This is because I am using the webcomponents and I am trying to get a little backward compatibility.

The second thing I am doing (also has to deal with webcomponents) is I have to modify jquery (by changing the file itself) so that it only runs once. I am using this component to make that happen. It basically inserts a function at the top of every library that I only want to run once.
https://github.com/dtracers/validateFirstRun

This other problem is that technically every library that uses the firstRun component has a dependency on it. But I don't think it would be a good idea to change the bower file of jquery. Do the overrides contain this ability?

Yes, I think so? Still a little confused as to what you're doing. But if your project needs jQuery to work, you want to list it as a dependency.

Sorry, let me use codeish examples instead of word examples.

order wiredep is inserting into my files

jquery
validateRunOnce
myLibraryThatDependsOnJquery

the order I need is

validateRunOnce
jquery
myLibraryThatDependsOnJquery

Thank you for explaining in so many ways :) I think this is a use case we just don't want to support. It's pretty weird (no fault there; making a website is weird in general!), and the fact we haven't run into this before makes me feel comfortable with the options we give developers now.

I'm not sure this will work for your use case, but maybe using exclude and writing necessary script tags manually will do the trick?