browserify-rails / browserify-rails

Browserify + Rails = a great way to modularize your legacy JavaScript
MIT License
704 stars 91 forks source link

2.0 doesn't update coffee files on change #120

Closed dbackeus closed 8 years ago

dbackeus commented 8 years ago

After upgrading from browserify-rails from 1.5 to 2.0.1 our coffeescript assets (.coffee and .cjsx) don't update after saving changes (stuck in cache?).

Our browserify config in application.rb looks like:

config.browserify_rails.source_map_environments << "development"
config.browserify_rails.commandline_options =
  %(-t coffee-reactify -t pkgify --extension=".coffee" --extension=".cjsx")

Downgrading to 1.5 makes it work again. Please let us know if we can help you debug this further.

cymen commented 8 years ago

Same issue underneath as https://github.com/browserify-rails/browserify-rails/issues/101. I should have a fix out shortly. My apologies.

cymen commented 8 years ago

Would you please upgrade to 2.0.2 and confirm this fixes the issue for you? Thank you in advance.

caesarsol commented 8 years ago

Fixed it for me! @cymen I came here looking for the bug, and you were fixing it in real-time :) great work! :+1:

cymen commented 8 years ago

@caesarsol Excellent! Thanks for confirming. I no longer have a big project to test browserify-rails on (due to switching employers) so I'm always a bit nervous in judging if something is truly fixed! Tests help of course but some things are tricky to test for (in theory, we do have a test that should have caught this but somehow the test environment differs from development env).

caesarsol commented 8 years ago

That's true... But wait for @dbackeus feedback because also my project is not so big :)

I should also tell you that on a coworker's machine we had to clean the browserifyinc cache to make it work.

dbackeus commented 8 years ago

It seemed not to work at first but then after messing about back end forth it started to work so I think the fix is valid :)

Might have been the browserifyinc cache mentioned above... though I didn't manually do anything to clear it. What was the commend for that @caesarsol?

caesarsol commented 8 years ago

@dbackeus I doubt it's the "right" way, but I simply do rm -r tmp/cache from the application directory :) Because I saw the browserifyinc cache files in there.

Guess you could do rake tmp:cache:clear or something similar?

cymen commented 8 years ago

Right -- I ran into the same thing with needing to blow away tmp/cache. I believe that sprockets includes the dependency graph in the cache files so it persists between server restarts. That was very surprising! So if the dependency graph is wrong, it'll stay wrong until the cache is cleared. I forgot to mention it.

cymen commented 8 years ago

You can also run bundle exec rake tmp:clear which should do the same thing as rm -rf tmp/cache.

cymen commented 8 years ago

Closing as I'm fairly certain this is resolved. Please do not hesitate to reopen in the event there are still issues.

dbackeus commented 8 years ago

We're actually still seeing files not reloading after change.

We're note sure why it happens. It seems a bit random but when it stops working it's fairly consistently stuck. Even clearing the tmp folder at that point appears to re-transpile old versions of files sometimes... we haven't troubleshooted enough to give any certain patterns.

Using 1.5.0 still seems the most stable option.

caesarsol commented 8 years ago

yes, I had the exact some problem too! no time to debug though, will try the next time

On 8 Dec 2015 4:59 p.m., "David Backeus" notifications@github.com wrote:

We're actually still seeing files not reloading after change.

We're note sure why it happens. It seems a bit random but when it stops working it's fairly consistently stuck. Even clearing the tmp folder at that point appears to re-transpile old versions of files sometimes... we haven't troubleshooted enough to give any certain patterns.

Using 1.5.0 still seems the most stable option.

— Reply to this email directly or view it on GitHub.

cymen commented 8 years ago

@dbackeus @caesarsol Are either of you using other things that would hook into the asset pipeline? We might need to pull 2.0. I like the idea but if it isn't working... Unfortunately, I don't use this project day to day anymore so I don't have a good sense of when things are not working well.

dbackeus commented 8 years ago

We're using react-rails, don't know if they do anything out of the ordinary. Also the Rack::Deflater middleware to compress assets.

Full application.rb config is:

    # Use Rack::Deflator for gzipped assets in dev env (in production we use heroku-deflater)
    config.middleware.use Rack::Deflater if Rails.env.development?

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run 'rake -D time' for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    config.react.variant = :production
    config.react.addons = true
    config.react.max_renderers = 10
    config.react.timeout = 20 # seconds
    config.react.react_js = -> { "" }
    config.react.component_filenames = ["components-server.js"]

    # Browserify
    # Enable source map for development
    config.browserify_rails.source_map_environments << "development"
    config.browserify_rails.commandline_options =
      %(-t coffee-reactify -t pkgify --extension=".coffee" --extension=".cjsx")

    config.generators do |g|
      g.view_specs false
      g.routing_specs false
      g.stylesheets false
      g.javascripts false
      g.helper false
    end