Skip to content
This repository was archived by the owner on Jun 10, 2018. It is now read-only.
This repository was archived by the owner on Jun 10, 2018. It is now read-only.

cache[path] not cache[name] #23

@philcockfield

Description

@philcockfield

Currently the require JS code is caching modules based on the name. This means that if I have two different modules, with the same name in different folders, I will get the wrong module returned when making relative calls for it.

For example, with modules in the following folder structure

 module1/foo
 module2/foo

If I were to do a require('./foo') from within module2 - if module1/foo had already been required (and thus cached) then it would return the module1/foo module.

This can be resolved by changing the cache key from name to path, eg:

Line 64: https://github.com/sstephenson/stitch/blob/master/src/stitch.coffee

        require = function(name, root) {
            var path = expand(root, name), 
                module = cache[path],
                fn;
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions