m0gg / dart-rails

Handle dart scripts for rails so they get compiled to js for browsers without dart support.
MIT License
21 stars 2 forks source link

Dart Rails doesn't recompile on file change. #10

Closed BenMorganIO closed 10 years ago

BenMorganIO commented 10 years ago

When I load a page up with dart information as so:

void main() {
  print("hey there");
}

It successfully compiles. If I change the contents to:

void main() {
  print("hi there");
}

It appears that the console does not log the updated print, but rather hey there. If I delete the cache and reload, it successfully recompiles.

Are you able to identify that if the file has changed, to recache the compiled dart code?

m0gg commented 10 years ago

I'm not very familiar to the caching in sprockets, but i'll have a look.

BenMorganIO commented 10 years ago

As a note, this is currently what I am doing within my Rails application to remove the files beforehand:

class ApplicationController < ActionController::Base
  before_action :remove_old_dart_files

  protect_from_forgery with: :exception

  def remove_old_dart_files
    files = Dir["#{Rails.root}/tmp/cache/assets/dart2js*"]
    dart_app_mtime = File.mtime("#{Rails.root}/app/assets/dart/dart_app.dart")

    files.each do |file|
      File.delete(file) if File.mtime(file) < dart_app_mtime
    end
  end
end
m0gg commented 10 years ago

Yeah that would do the Job. But it's not like it should be done. Sprockets is only unable to detect the changes, because the actual dart_app.js doesn't change.

m0gg commented 10 years ago

@BenMorganIO would you please try 760bfb2bef597c54fa375da54168ad94bf833141 (the current head).

This worked for me and recognized changes in all imported dart-files, except the ones from the SDK.

m0gg commented 10 years ago

Problem is now fixed in master with v0.2.0