edgecase / dieter

Asset pipeline ring middleware
135 stars 22 forks source link

dieter should generate dependency information #16

Closed pbiggar closed 11 years ago

jxa commented 12 years ago

+1

jxa commented 12 years ago

I've started work on this in the asset-cache branch

pbiggar commented 12 years ago

I renamed the issue, because I think it's indicative of a larger problem about dependencies.

We use lein dieter-precompile, and we run into frequent problems. When running tests, we use production mode, so it compiles files, but only if they dont exist. What happens when we run the tests again? They dont get regenerated, even if the source files have been changed. Lots of subtle bugs!

The solution to this is the same as for not regenerating files that dont need it: keep track of dependency information. I propose that when we generate a json file providing a map from a sha1 to a generated file. If we see the sha1 again, we can reuse it.

What if the compiled files are stale? Well then, we would see that the current file is not the same as the sha1 in the dependency, and we would regenerate it.

ivanstojic commented 12 years ago

Since it seems that @jxa fell asleep, I'll be trying to tackle this. As the rest of my work, I'll be attacking this on the v8 branch, hopefully it'll get merged into main when the rest of the changes settle down.

ivanstojic commented 12 years ago

Actually, I think @pbiggar is right - there are some deeper problems. For instance, in my latest version, the precompile output filename is broken:

~/Documents/Programming/circleci/dieter/test-projects/t3 $ lein dieter-precompile          
...                                                                                        
~/Documents/Programming/circleci/dieter/test-projects/t3 $ ls resources/asset-cache/assets/
js/  scripts.js-4a1f1a8f98700e7c3f8578c6b9dbaffe.dieter

And after accessing the doc through the Ring middleware, this shows up:

~/Documents/Programming/circleci/dieter/test-projects/t3 $ ls resources/asset-cache/assets/
js/  scripts-4a1f1a8f98700e7c3f8578c6b9dbaffe.js  scripts.js-4a1f1a8f98700e7c3f8578c6b9dbaffe.dieter

Either I misunderstand the Dieter file naming rules, or the precompile is currently broken.

pbiggar commented 11 years ago

The main aim is solved here: caching previously compiled assets is now done in-memory, and parts of manifests and untouched files are typically served from memory (based on a timestamp). It would be trivial to do it on disk, but since dieter is fast now, I don't think that's necessary.