Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

If the module resolves in the cache when adding ./index to the module…

… name, try using it if the default name doesn't resolve in cache rather than re-executing the module function.
  • Loading branch information...
commit 740be5146c2445a754cba97dc5e8f85ad15bd85f 1 parent 98f71ed
Mason Browne authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/stitch.coffee
View
7 src/stitch.coffee
@@ -61,10 +61,13 @@ exports.Package = class Package
(function(/*! Stitch !*/) {
if (!this.#{@identifier}) {
var modules = {}, cache = {}, require = function(name, root) {
- var path = expand(root, name), module = cache[path], fn;
+ var path = expand(root, name), altPath = expand(path, './index'), module = cache[path], altModule = cache[altPath], fn;
if (module) {
return module.exports;
- } else if (fn = modules[path] || modules[path = expand(path, './index')]) {
+ }
+ else if (altModule){
+ return altModule.exports
+ } else if (fn = modules[path] || modules[path = altPath]) {
module = {id: path, exports: {}};
try {
cache[path] = module;
Please sign in to comment.
Something went wrong with that request. Please try again.