Simplify AMD loader config options.

Former-commit-id: 69a89fe05e45f508fefe445f147da5aa4da8fc7b
This commit is contained in:
John-David Dalton
2013-07-14 15:38:16 -07:00
parent 27ca48c6bb
commit 6b3ee1aaaf
2 changed files with 51 additions and 58 deletions

View File

@@ -53,56 +53,44 @@
if (!window.require) {
return;
}
var isModularize = /modularize/.test(ui.urlParams.build);
var modulePath = ui.buildPath.replace(/\.js$/, ''),
reBasename = /[\w.-]+$/;
var baseUrl = isModularize
? '../modularize/'
: '';
var modulePath = isModularize
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
var locationPath = /modularize/.test(ui.urlParams.build)
? '../modularize'
: modulePath.replace(reBasename, '');
var testPath = (
(window.curl ? ui.loaderPath.replace(/[\w.-]+$/, 'curl/plugin/js!') : '') +
(isModularize ? '../test/' : '') +
(window.curl ? ui.loaderPath.replace(reBasename, 'curl/plugin/js!') : '') +
'test.js'
);
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
require({
'baseUrl': baseUrl,
'baseUrl': './',
'urlArgs': 't=' + (+new Date),
'paths': paths,
'paths': {
'shimmed': './abc/../' + modulePath,
'underscore': './xyz/../' + modulePath
},
'aliases': [
['shimmed', 'lodash'],
['underscore', 'lodash']
],
'packages': [
{
'name': 'lodash',
'location': locationPath,
'main': 'lodash'
}
],
'shim': {
'shimmed': {
'exports': '_'
}
},
'packages': packages
}
},
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
if (shimmed && shimmed.noConflict) {

View File

@@ -102,44 +102,49 @@
if (window.curl) {
var require = curl;
}
if (!window.require) {
init(_);
} else {
(function() {
if (!window.require) {
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;
// load Lo-Dash as a module
require((function() {
var reModularize = /modularize/;
var baseUrl = reModularize.test(ui.urlParams.build)
? '../modularize/'
: '';
var modulePath = reModularize.test(ui.urlParams.build)
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
return {
'baseUrl': baseUrl,
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': modulePath
require({
'baseUrl': './',
'urlArgs': 't=' + (+new Date),
'packages': [
{
'name': 'lodash',
'location': locationPath,
'main': 'lodash'
}
};
}()),
]
},
['lodash'], function(lodash) {
init(lodash);
require([
'../vendor/underscore/test/collections.js',
'../vendor/underscore/test/arrays.js',
'../vendor/underscore/test/functions.js',
'../vendor/underscore/test/objects.js',
'../vendor/underscore/test/utility.js'
pluginPath + '../vendor/underscore/test/collections.js',
pluginPath + '../vendor/underscore/test/arrays.js',
pluginPath + '../vendor/underscore/test/functions.js',
pluginPath + '../vendor/underscore/test/objects.js',
pluginPath + '../vendor/underscore/test/utility.js'
], function() {
QUnit.start();
});
});
}
}());
</script>
<script type="text/html" id="template">
<%