jrburke/r.js — pull request #656 by owiber (2014-03-21 16:55:15+00:00)
Title: Relax namespace regexps

The regular expressions used in namespace rewrites don't properly recognize defines that look like:

```javascript
if (typeof define == 'function' && define.amd) {
define(...);
}
```

... because it currently expects strict equivalence, like this:

```javascript
if (typeof define === 'function' && define.amd) {
define(...);
}
```

While I agree the latter is preferable, if there are no downsides to supporting the former as well, that would help the "namespace-ability" of many modules out there that use the former syntax (where they won't notice any issues if namespacing isn't used).

That said, I wonder if namespacing is better done via a method similar to that described in http://requirejs.org/docs/faq-advanced.html#rename, where instead of attempting to regular expression match and rewrite `define` calls, we instead wrap the entire file in something like:

```javascript
(function (define, require) {
// file contents here
}(NS.define, NS.require);
```