geddesign/wrap.js — Issue #4: Add support for external scripts
Author: aberman
Created: 2012-02-14 23:31:40+00:00
State: open

There are times when I want to use CDN resources. Currently wrap does not support them. If you do it the requireJS way like this:

```javascript
require.config({
wrapJS: {
'recaptcha': {
attach: function() {
var recaptcha = this.Recaptcha;
delete this.Recaptcha;
return recaptcha;
}
}
},
paths: {
recaptcha: 'https://www.google.com/recaptcha/api/js/recaptcha_ajax'
}
});
```

In app.build.js

```javascript
paths: {
recaptcha: 'empty:'
}
```
You get an error:

Tracing dependencies for: main

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Error: Error evaluating module "undefined" at location "/Users/andrew/Documents/workspace/warnly_web/app/scripts/lib/plugins/wrap.js":
Error: ENOENT, no such file or directory 'empty:.js'
fileName:/Users/andrew/Documents/workspace/warnly_web/app/scripts/lib/plugins/wrap.js
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
In module tree:
main
wrap

If you change it to:

```javascript
require.config({
wrapJS: {
'recaptcha': {
attach: function() {
var recaptcha = this.Recaptcha;
delete this.Recaptcha;
return recaptcha;
},
path: 'https://www.google.com/recaptcha/api/js/recaptcha_ajax.js' //NOTE ALSO HOW .JS IS REQUIRED!
}
}
});
```

With or without the path for recaptcha in app.build.js you get:

Error: Error: Error evaluating module "undefined" at location "/Users/andrew/Documents/workspace/warnly_web/app/scripts/lib/plugins/wrap.js":
Error: ENOENT, no such file or directory 'https://www.google.com/recaptcha/api/js/recaptcha_ajax.js'
fileName:/Users/andrew/Documents/workspace/warnly_web/app/scripts/lib/plugins/wrap.js