lodash: Add support for more AMD build optimizers and allow aliasing as the "underscore" module. [jddalton]

Former-commit-id: 6b3fa45d19f6a55aa7565bcb4d9221f6f159e9c9
This commit is contained in:
John-David Dalton
2012-04-24 18:15:47 -04:00
parent bb09d77eb5
commit f9358531ad
5 changed files with 37 additions and 28 deletions

View File

@@ -12,7 +12,7 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<script src="../vendor/qunit/qunit/qunit.js"></script>
<script>var _2, _ = 1;</script>
<script>var _2, _3, _ = 1;</script>
<script src="../lodash.js"></script>
<script src="../vendor/requirejs/require.js"></script>
<script>
@@ -21,16 +21,21 @@
document.write('<script src="test.js"><\/script>');
}
else {
define.amd.lodash = true;
require({
'baseUrl': '../vendor/requirejs/',
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': '../../lodash'
'lodash': '../../lodash',
'underscore': './../../lodash'
}
},
['lodash'], function(_) {
_2 = _.noConflict();
['lodash', 'underscore'], function(lodash, lodashAsUnderscore) {
_2 = lodash.noConflict();
_2.moduleName = 'lodash';
_3 = lodashAsUnderscore.noConflict();
_3.moduleName = 'underscore';
require(['test.js']);
});
}

View File

@@ -47,9 +47,17 @@
QUnit.module('lodash');
(function() {
test('supports loading lodash.js as a module', function() {
test('supports loading lodash.js as the "lodash" module', function() {
if (window.document && window.require) {
equal((_2 || {}).VERSION, _.VERSION);
equal((_2 || {}).moduleName, 'lodash');
} else {
skipTest(1)
}
});
test('supports loading lodash.js as the "underscore" module', function() {
if (window.document && window.require) {
equal((_3 || {}).moduleName, 'underscore');
} else {
skipTest(1)
}