leshill / handlebars_assets

Use handlebars.js templates with the Rails asset pipeline.
MIT License
647 stars 159 forks source link

Remove asset version modifier based on handlebars version #144

Closed kapowaz closed 7 years ago

kapowaz commented 8 years ago

Fixes #143.

As discussed in the issue, by appending the HandlebarsAssets::VERSION to the global assets version identifier, this triggers a complete change to all assets whenever the HandlebarsAssets version number changes, even though only the handlebars runtime (and potentially some handlebars templates) will have changed. Also, since Sprockets is smart enough to realise that the version of Handlebars included in a given JS file will result in a different fingerprint, there is no need for this to be handled in the gem anyway.

AlexRiedler commented 8 years ago

@kapowaz so I thought the same as you until I got a heard of complaints regarding getting runtime version mismatches. Sprockets only appears to look at the input file's checksum (for digest); so it does not change when the gem gets updated. If you know of a way to make it so sprockets notices the version change that would be awesome and solve this problem once and for all; I looked for a while but maybe I missed something (tried asking on IRC, no help; and tried to determine in the code as well).

Maybe there is something in Tilt/Sprockets that I overlooked last time...

(Note: this is the case when people commonly make their templates separate from where they include their runtime)

kapowaz commented 8 years ago

@AlexRiedler just to be clear I understand correctly, by changing the version of assets included via a gem, Sprockets won't see that input file as having changed (only files within the project that uses Sprockets proper, i.e. the Rails app itself) and so won't bump the version for any sources that include that external dependency?

AlexRiedler commented 8 years ago

@kapowaz quite exactly, I think it is an issue as well but this work-around is fine for the time being to rebuild all assets. Obviously it is not ideal solution, it would be nice if we could expire assets on the per transformer level in sprockets; maybe in v4 there is support.

AlexRiedler commented 8 years ago

@kapowaz I found this in the release notes for 3.x https://github.com/rails/sprockets/blob/2d30e546872f6f4c5361fe19c2d89b15c5db2dd4/UPGRADING.md#rev-version-less-often

I will implement this as the solution instead, so if your using sprockets 3.x it should bust properly (hopefully).

AlexRiedler commented 7 years ago

I think this has been fixed upstream now. Thanks for the hint!