rharriso / bower-rails

Bundler-like DSL + rake tasks for Bower on Rails
MIT License
1.46k stars 128 forks source link

Something odd happening with file name or path inference based on name. #171

Open jjb opened 9 years ago

jjb commented 9 years ago

The package "intro.js" has this bower.json:

{
  "name": "intro.js",
  "description": "A better way for new feature introduction and step-by-step users guide for your website and project.",
  "keywords": ["demo", "intro", "introduction"],
  "homepage": "http://usablica.github.com/intro.js/",
  "author": "Afshin Mehrabani",
  "main": ["intro.js","introjs.css"]
}

and installs with a directory named "intro.js".

As normal I put asset "intro.js" in my Bowerfile.

With either require intro.js or require intro in my application.js, I get the error:

couldn't find file 'intro' with type 'application/javascript'"

If I rename the directory from "intro.js" to "intro" and use require intro in application.js, it works.

I'm totally new to bower and bower-rails but I believe bower-rails is the layer that is at fault here.

Let me know if you would like any more info or if this should be reported elsewhere. Thanks!

(btw, I have config.assets.paths << Rails.root.join("vendor","assets","bower_components") in my application.rb, so I typically can do "require packagname" with no path in my application.js)

SergeyKishenin commented 9 years ago

What if you try to //= require "intro.js/intro for JS and *= require "intro.js/introjs for CSS?

Checkout #37, #110, #144 for example. You have to require fullpath as we don't create aliases for main files.

jjb commented 9 years ago

I am now using the packaged registered as "intro-js" (which points to the same github project) and it works as expected. I need only #= require intro-js to make it work.

I don't think I am having the problem described in those tickets. Also I think I'm not seeing the behavior described in those tickets. Maybe new features have been added in the meantime?

The discussion in those tickets suggests that the javascript "main" file declaration don't matter when deciding what file to require. But I am observing that they do. For example, the "autosize" project. The main file is jquery.autosize.js. In my application.js I have #= require autosize. With this, vendor/assets/bower_components/autosize/jquery.autosize.js is successfully required. As far as I can tell, the only way bower-rails could know to do this is via the "main" declaration.

So I think that the behavior described in this ticket (171) is a bug caused by having a period in the package name.