Use html5 storage to cache coffee script compilation by file md5

This commit is contained in:
Nathan Sobo
2012-07-02 19:21:46 -06:00
parent 06cdcaa820
commit f92faffb5b

View File

@@ -106,7 +106,13 @@ __exists = (path) ->
__coffeeCache = (filePath) ->
{CoffeeScript} = require 'coffee-script'
CoffeeScript.compile(__read(filePath), filename: filePath)
cacheKey = 'coffee.' + $native.md5ForPath(filePath)
if compiled = localStorage.getItem(cacheKey)
compiled
else
compiled = CoffeeScript.compile(__read(filePath), filename: filePath)
localStorage.setItem(cacheKey, compiled)
compiled
__read = (path) ->
try