jrburke/r.js — pull request #206 by edc (2012-06-22 20:37:55+00:00)
Title: fix single file (-o out=xyz) mode

The current code breaks on single-file mode even on empty project because `modules` is undefined. This simple commit fixes it. More info is below.

#### single-file mode is broken

It's broken even with empty project:

~~~
$ mkdir requirejs-build
$ cd requirejs-build
$ mkdir app
$ touch app/empty.js
$ r.js -o main=empty out=out.js baseUrl=app
TypeError: Cannot read property '0' of undefined
at Function._run (/Users/edc/scratch/requirejs-build/node_modules/requirejs/bin/r.js:14294:31)
~~~~

#### fixed with this patch
~~~~
$ mkdir requirejs-build
$ cd requirejs-build
$ mkdir app
$ touch app/empty.js
$ r.js -o main=empty out=out.js baseUrl=app
Tracing dependencies for: empty
Uglifying file: /Users/edc/scratch/requirejs-build/out.js

/Users/edc/scratch/requirejs-build/out.js
----------------
/Users/edc/scratch/requirejs-build/app/empty.js
~~~~

It also works when `out` is set to a function:

~~~~
$ echo '({main:"empty",baseUrl:"app",out:function(x){console.log(x.length)}})' > build.js
$ r.js -o build.js

Tracing dependencies for: empty
Uglifying file: FUNCTION
28

FUNCTION
----------------
/Users/edc/scratch/requirejs-build/app/empty.js
~~~~