timrwood/moment — pull request #485 by timrwood (2012-10-30 18:44:58+00:00)
Title: Adding AMD wrapper to lang files

This addresses #128 and #479.

This changes the way language files are defined. Rather than adding the [complex environment forking](https://github.com/timrwood/moment/blob/1445773224bdc284c70bc317fa5d764958805785/lang/bg.js#L59) to each language file, the source files are instead [only targeting Node.js](https://github.com/timrwood/moment/blob/a775f290a7d0f4156ecd72575356370d115eddcb/lang/bg.js#L5).

Then, during the build process, the `require('../moment')` string is replaced with `moment` and is wrapped with the AMD/browser code.

```javascript
// en.js source file
require('../moment').lang('en', {
// the good stuff
});
```

```javascript
// en.min.js file targeted towards browsers and Require.js
(function(){
function onload (moment) {
moment.lang('en', {
// the good stuff
});
}
if (typeof define === "function" && define.amd) {
define(["moment"], onload);
}
if (typeof window !== "undefined" && window.moment) {
onload(window.moment);
}
})()
```

Thoughts @mlegenhausen, @Morriz, and @trondkla?