mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 04:17:49 +00:00
Simplify AMD loader config options.
Former-commit-id: 69a89fe05e45f508fefe445f147da5aa4da8fc7b
This commit is contained in:
@@ -53,56 +53,44 @@
|
|||||||
if (!window.require) {
|
if (!window.require) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var isModularize = /modularize/.test(ui.urlParams.build);
|
var modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||||
|
reBasename = /[\w.-]+$/;
|
||||||
|
|
||||||
var baseUrl = isModularize
|
var locationPath = /modularize/.test(ui.urlParams.build)
|
||||||
? '../modularize/'
|
? '../modularize'
|
||||||
: '';
|
: modulePath.replace(reBasename, '');
|
||||||
|
|
||||||
var modulePath = isModularize
|
|
||||||
? 'lodash'
|
|
||||||
: ui.buildPath.replace(/\.js$/, '');
|
|
||||||
|
|
||||||
var testPath = (
|
var testPath = (
|
||||||
(window.curl ? ui.loaderPath.replace(/[\w.-]+$/, 'curl/plugin/js!') : '') +
|
(window.curl ? ui.loaderPath.replace(reBasename, 'curl/plugin/js!') : '') +
|
||||||
(isModularize ? '../test/' : '') +
|
|
||||||
'test.js'
|
'test.js'
|
||||||
);
|
);
|
||||||
|
|
||||||
QUnit.config.autostart = false;
|
QUnit.config.autostart = false;
|
||||||
|
|
||||||
var paths = {
|
|
||||||
'shimmed': './abc/../' + modulePath,
|
|
||||||
'underscore': './xyz/../' + modulePath
|
|
||||||
};
|
|
||||||
|
|
||||||
var packages = [];
|
|
||||||
|
|
||||||
if (isModularize) {
|
|
||||||
packages.push({
|
|
||||||
'name': 'lodash',
|
|
||||||
'location': '.',
|
|
||||||
'main': 'lodash'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
paths.lodash = modulePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
require({
|
require({
|
||||||
'baseUrl': baseUrl,
|
'baseUrl': './',
|
||||||
'urlArgs': 't=' + (+new Date),
|
'urlArgs': 't=' + (+new Date),
|
||||||
'paths': paths,
|
'paths': {
|
||||||
|
'shimmed': './abc/../' + modulePath,
|
||||||
|
'underscore': './xyz/../' + modulePath
|
||||||
|
},
|
||||||
'aliases': [
|
'aliases': [
|
||||||
['shimmed', 'lodash'],
|
['shimmed', 'lodash'],
|
||||||
['underscore', 'lodash']
|
['underscore', 'lodash']
|
||||||
],
|
],
|
||||||
|
'packages': [
|
||||||
|
{
|
||||||
|
'name': 'lodash',
|
||||||
|
'location': locationPath,
|
||||||
|
'main': 'lodash'
|
||||||
|
}
|
||||||
|
],
|
||||||
'shim': {
|
'shim': {
|
||||||
'shimmed': {
|
'shimmed': {
|
||||||
'exports': '_'
|
'exports': '_'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
'packages': packages
|
|
||||||
},
|
},
|
||||||
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||||
if (shimmed && shimmed.noConflict) {
|
if (shimmed && shimmed.noConflict) {
|
||||||
|
|||||||
@@ -102,44 +102,49 @@
|
|||||||
if (window.curl) {
|
if (window.curl) {
|
||||||
var require = curl;
|
var require = curl;
|
||||||
}
|
}
|
||||||
if (!window.require) {
|
(function() {
|
||||||
init(_);
|
if (!window.require) {
|
||||||
} else {
|
init(_);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||||
|
reBasename = /[\w.-]+$/;
|
||||||
|
|
||||||
|
var locationPath = /modularize/.test(ui.urlParams.build)
|
||||||
|
? '../modularize'
|
||||||
|
: modulePath.replace(reBasename, '');
|
||||||
|
|
||||||
|
var pluginPath = window.curl
|
||||||
|
? ui.loaderPath.replace(reBasename, 'curl/plugin/js!')
|
||||||
|
: '';
|
||||||
|
|
||||||
QUnit.config.autostart = false;
|
QUnit.config.autostart = false;
|
||||||
|
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
require((function() {
|
require({
|
||||||
var reModularize = /modularize/;
|
'baseUrl': './',
|
||||||
|
'urlArgs': 't=' + (+new Date),
|
||||||
var baseUrl = reModularize.test(ui.urlParams.build)
|
'packages': [
|
||||||
? '../modularize/'
|
{
|
||||||
: '';
|
'name': 'lodash',
|
||||||
|
'location': locationPath,
|
||||||
var modulePath = reModularize.test(ui.urlParams.build)
|
'main': 'lodash'
|
||||||
? 'lodash'
|
|
||||||
: ui.buildPath.replace(/\.js$/, '');
|
|
||||||
|
|
||||||
return {
|
|
||||||
'baseUrl': baseUrl,
|
|
||||||
'urlArgs': 't=' + (+new Date),
|
|
||||||
'paths': {
|
|
||||||
'lodash': modulePath
|
|
||||||
}
|
}
|
||||||
};
|
]
|
||||||
}()),
|
},
|
||||||
['lodash'], function(lodash) {
|
['lodash'], function(lodash) {
|
||||||
init(lodash);
|
init(lodash);
|
||||||
require([
|
require([
|
||||||
'../vendor/underscore/test/collections.js',
|
pluginPath + '../vendor/underscore/test/collections.js',
|
||||||
'../vendor/underscore/test/arrays.js',
|
pluginPath + '../vendor/underscore/test/arrays.js',
|
||||||
'../vendor/underscore/test/functions.js',
|
pluginPath + '../vendor/underscore/test/functions.js',
|
||||||
'../vendor/underscore/test/objects.js',
|
pluginPath + '../vendor/underscore/test/objects.js',
|
||||||
'../vendor/underscore/test/utility.js'
|
pluginPath + '../vendor/underscore/test/utility.js'
|
||||||
], function() {
|
], function() {
|
||||||
QUnit.start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}());
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="template">
|
<script type="text/html" id="template">
|
||||||
<%
|
<%
|
||||||
|
|||||||
Reference in New Issue
Block a user