sstephenson/stitch — pull request #35 by maseb (2012-03-01 04:15:59+00:00)
Title: 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.