jrburke/r.js — Issue #35: r.js doesn't set define.amd during optimization
Author: samcday
Created: 2011-11-08 23:58:45+00:00
State: open

Hi James,

It seems that during the optimization step in r.js, define.amd is undefined. This causes issues when executing plugins during optimization.

Please refer to this gist for an example: https://gist.github.com/1349759

Running `r.js -o name=main.js baseUrl=. out=out.js` on this example will result in the following output:

```
Tracing dependencies for: main.js
Has define(): true
Has define.amd: false
It's broken :(
```

I'm not sure whether r.js is *supposed* to set define.amd, but to me it feels like it should. During optimization plugins are evaluated as regular AMD modules, and as such their dependencies are also loaded. By not setting define.amd the contract for AMD is being violated and causing unpredictable results with plugin dependencies.

Thanks for your time :)