stitch
stitch copied to clipboard
Make caching a little smarter.
CommonJS dictates that if a module has been required in the past, its exports should be cached and returned the next time require is called for that module in the same runtime.
Currently, Stitch does not return cached modules if they're only found after adding "/index" to the require name.
Example module structure:
mf/
index.coffee
events.coffee
If I call:
require("mf/events");
require("mf/events");
the contents of mf/events.coffee will only be executed once, as expected. However, if I call:
require("mf");
require("mf");
the contents of mf/index.coffee will be executed twice. This fixes that.
Fantastic. Could you add a test case for this too?
Word.
Done, by the by. :)
Bump.