hsume2 / browserify-rails

Deprecated https://github.com/browserify-rails/browserify-rails
MIT License
57 stars 11 forks source link

coffeescript files are not working without coffeeify #22

Closed adrianpacala closed 10 years ago

adrianpacala commented 10 years ago

application.js

var message = require('./home');

console.log(message());

home.js.coffee

module.exports = ->
  'Hello!'

produces the following error:

Error while running `/Users/adrian/Code/exampleapp/./node_modules/.bin/browserify --list`:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Cannot find module './home' from '/Users/adrian/Code/exampleapp/app/assets/javascripts'
    at /Users/adrian/Code/exampleapp/node_modules/browserify/node_modules/resolve/lib/async.js:36:25
    at load (/Users/adrian/Code/exampleapp/node_modules/browserify/node_modules/resolve/lib/async.js:54:43)
    at /Users/adrian/Code/exampleapp/node_modules/browserify/node_modules/resolve/lib/async.js:60:22
    at /Users/adrian/Code/exampleapp/node_modules/browserify/node_modules/resolve/lib/async.js:16:47
    at Object.oncomplete (fs.js:107:15)

  (in /Users/adrian/Code/exampleapp/app/assets/javascripts/application.js)

As you can see, browserify doesn't recognize home.js.coffee as a valid dependency for require('./home');

After adding coffeeify to package.json and changing:

command = "#{browserify_cmd} #{options}"

to:

command = "#{browserify_cmd} #{options} -t coffeeify --extension=\".js.coffee\""

everything works fine. Is this a bug or am I doing something wrong here?

martenlienen commented 10 years ago

Solved in #24