 _packages = []
 
 exports.rebuildPackageCache = ->
+	moduleCache = {}
 	packageCache = {}
 	
 	for name in _packages

	exports.rebuildPackageCache() unless packageCache?
	
	results = {}
	
	invokeRecursive = (path, parent) ->
		
		for key, objectOrFunction of parent
			
			if key.charCodeAt(0) is '$'.charCodeAt(0)
	
				if key is "$#{hook}"
					
					results[path] = objectOrFunction args...
					
			else
				
				invokeRecursive "#{path}/#{key}", objectOrFunction
				
	invokeRecursive name, package_ for name, package_ of packageCache
	
	results

				
			throw error
			
		moduleCache[name] = package_
		
	cacheRecursive = (path, parent) ->
		
		for key, objectOrFunction of parent
			
			if key.charCodeAt(0) is '$'.charCodeAt(0)
				
				(packageCache[key.slice 1] ?= []).push
					path: path
					fn: objectOrFunction
	
			else
				
				cacheRecursive "#{path}/#{key}", objectOrFunction
				
	cacheRecursive path, module for path, module of moduleCache
		
	return

