madebymany / sir-trevor-rails

Rails gem for Sir Trevor integration.
MIT License
149 stars 50 forks source link

Issue with rails-assets.org #36

Closed firedev closed 9 years ago

firedev commented 9 years ago

Here are my files:

# Gemfile
source 'https://rails-assets.org' do
  gem 'rails-assets-sir-trevor-js'
  gem 'rails-assets-underscore'
  gem 'rails-assets-Eventable'
end

# application.coffee
//= require underscore
//= require Eventable
//= require sir-trevor-js

Html output:

<script src="/assets/underscore/underscore.js"></script>
<script src="/assets/underscore.js"></script>
<script src="/assets/Eventable/eventable.js"></script>
<script src="/assets/Eventable.js"></script>
<script src="/assets/sir-trevor-js/index.js"></script>

Yet index.js consists of only one line:

module.exports = require('./src/');

And the pages gives me an error:

Uncaught ReferenceError: module is not defined

So I tried to add rails-assets-angular to the mix. But that didn't help either.

Please advise what am I doing wrong. Thank you.

olvado commented 9 years ago

@firedev The correct file you need to reference is sir-trevor.js rather than index.js located in the same directory.

firedev commented 9 years ago

That is closed too soon I guess. Packages installed via rails-assets are supposed to obey the rules. I.e. the require line matches the name of asset installed.

lukaszsagol commented 9 years ago

Our bower.json is missing definition of main files, therefore you have to include them by hand.

Don't know what rules you're talking about?

firedev commented 9 years ago

Well guess I was expected main to expose assets.

olvado commented 9 years ago

The main definition is now present (as of 0.5.0-beta2) in bower.json - correctly referencing the sir-trevor.js file. Until this is available through rails-assets.org you can refence the correct file manually. Note the dependency on jQuery:

//= require jquery
//= require underscore
//= require Eventable
//= require sir-trevor-js/sir-trevor

This all loads up ok.

firedev commented 9 years ago

Yep that's what I did, thanks.

lukaszsagol commented 9 years ago

Be aware that using 0.5.0-beta isn't recommended for production yet, we're in the middle of huge rewrite.