Skip to content

Instantly share code, notes, and snippets.

@neonstalwart
Created May 20, 2011 13:44
Show Gist options
  • Save neonstalwart/982913 to your computer and use it in GitHub Desktop.
Save neonstalwart/982913 to your computer and use it in GitHub Desktop.
relative module id resolution
// foo/bar/one.js
define(['./two'], function (two) {
return {
two: two
};
});
// foo/bar/two.js
// this would be returned if resolution is relative to url
define(function () {
return 'foo/bar/two';
});
// main.js
require({
baseUrl: './',
paths: {
one: 'foo/bar/one'
}
},
['one'], function (one) {
console.log(one.two);
});
// 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