jrburke/r.js — Issue #32: When building a single file referencing text! and name of the module is not at the same level of baseUrl...
Author: jonobr1
Created: 2011-10-27 02:26:03+00:00
State: open

I'm using [this r.js](http://requirejs.org/docs/release/1.0.0/r.js) and have an odd configuration to build my require module..:

My directory structure looks like:

+ /Project
* examples
- lib
+ main.js
+ content.html
* src
- main.js
* third-party
* utils
- r.js

I want to build `Project/examples/lib/main.js` and most of my dependencies happen to fold under `Project/src`. The problem that I ran into is that when I run `node` from `Project/examples/lib` with these options (below) it actually compiles `Project/src/main`. I assumed that this is because the `baseUrl` is set to the `src` directory.

`node ../../utils/r.js -o name=main out=./build/example.js baseUrl=../../src paths.text=../third-party/requirejs/text...`

So, I tried changing the `name` property to `name=../examples/gui/main`. This works _except_ that one of my dependencies in `Project/examples/lib/main.js` relies on the plugin text.js (`content.html`) and somehow `r.js` misreads where that particular file is... it resolves the path to content.html to:

`/Project/src/../examples/examples/examples/lib/contents.html`

I'm not positive, but I'm pretty sure that somewhere in r.js it's being resolved incorrectly, because I've `console.log`'d in text and the path was already resolved by the time text tried to find the file and threw the error in node. I don't want to jump to conclusions, but I think this is a bug — I feel strongly towards the API resolving the `name` property agnostic of `baseUrl` and / or this odd case of `text!` being fixed.

Cheers,

-Jono