Created
May 20, 2011 13:44
-
-
Save neonstalwart/982913 to your computer and use it in GitHub Desktop.
relative module id resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// foo/bar/one.js | |
define(['./two'], function (two) { | |
return { | |
two: two | |
}; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// foo/bar/two.js | |
// this would be returned if resolution is relative to url | |
define(function () { | |
return 'foo/bar/two'; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.js | |
require({ | |
baseUrl: './', | |
paths: { | |
one: 'foo/bar/one' | |
} | |
}, | |
['one'], function (one) { | |
console.log(one.two); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// two.js | |
// this would be returned if resolution is relative to module id | |
define(function () { | |
return 'two'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment