duojs / duo

A next-generation package manager for the front-end
3.42k stars 118 forks source link

Require local bower component? #467

Open topherfangio opened 9 years ago

topherfangio commented 9 years ago

Since Duo does not currently support private Bower/GitHub URLs, I was hoping I could still use Bower to download my dependencies, but then use Duo to bundle everything. I like how Duo scans my CSS/JS files for bower assets like images and copies them to the proper location after bundling, which I can't find anything similar in the Gulp world.

So, I'm trying to do the following in my app.js file:

require('./bower_components/my-special-component');

// My code goes down here

Unfortunately, I get the following error:

Error: bower_components/my-special-component@*: cannot resolve

Is there another/better way to do this? I was hoping it would find the bower.json file that has a main with all of my dependencies, but it looks like it's not.

Thanks! Looking forward to when Duo takes over the world ;-)

dominicbarnes commented 9 years ago

I believe this issue is caused by Duo looking for an index.js in the my-special-component directory. If that component uses something other that index.js as it's entry, you'll need to specify that instead.

require('./bower_components/my-special-component/my-special-component.js');

If that doesn't work, I think I know something else that might be the problem.

topherfangio commented 9 years ago

Ah, I see my incorrect thinking...I was thinking I needed to point to where the bower.json was so that Duo would automatically pick up the CSS file too, but that is totally wrong. I need to have a require pointing to the JS file, and an import pointing to the CSS. From there, it should be able to figure out everything else.

I'll give that a try and post back.

dominicbarnes commented 9 years ago

Yeah, you need to import your JS and CSS for duo to recognize them, plus duo doesn't even consider the bower.json file.