Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jjb opened this issue Oct 2, 2015 · 2 comments
Open

Comments

@jjb
Copy link
Contributor

jjb commented Oct 2, 2015

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)

@jjb jjb changed the title Something odd happening with file name inference based on name. Something odd happening with file name or path inference based on name. Oct 2, 2015
@SergeyKishenin
Copy link
Collaborator

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
Copy link
Contributor Author

jjb commented Oct 2, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants