jrburke/r.js — pull request #591 by tgriesser (2013-12-23 17:55:20+00:00)
Title: Use module location if one is specified

I ran into an issue when trying to use the module config to build a project, where the config is:

```js
({
baseUrl: ".",
optimize: 'none',
cjsTranslate: true,
paths: {
lodash: './node_modules/lodash/lodash'
},
packages: [{
name: 'bluebird',
location: 'node_modules/bluebird',
main: './js/main/bluebird.js'
}],
name: "knex",
out: "knex-built.js"
})
```

I was getting the error:

```sh
Tracing dependencies for: knex
Error: ENOENT, no such file or directory '/Users/tgriesser/Github/knex/bluebird/js/main/global.js'
In module tree:
knex
lib/raw
lib/common
lib/promise
bluebird/js/main/promise
```
In this case, it was resolving relative paths relative to the `main` file, which wasn't using the `location` to find the correct path. This checks if a location is defined and if so replaces appropriately in the package name.