mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Change how lodash-modularie build path is resolved.
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
Object.keys = function() { return []; };
|
Object.keys = function() { return []; };
|
||||||
|
|
||||||
// load Lo-Dash and expose it to the bad `Object.keys` shim
|
// load Lo-Dash and expose it to the bad `Object.keys` shim
|
||||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// store Lo-Dash to test for bad shim detection
|
// store Lo-Dash to test for bad shim detection
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
delete Object._keys;
|
delete Object._keys;
|
||||||
|
|
||||||
// load Lo-Dash again to overwrite the existing `_` value
|
// load Lo-Dash again to overwrite the existing `_` value
|
||||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||||
|
|
||||||
// load test.js if not using require.js
|
// load test.js if not using require.js
|
||||||
document.write(ui.urlParams.loader != 'none'
|
document.write(ui.urlParams.loader != 'none'
|
||||||
@@ -55,34 +55,32 @@
|
|||||||
}
|
}
|
||||||
var reBasename = /[\w.-]+$/,
|
var reBasename = /[\w.-]+$/,
|
||||||
basePath = ('//' + location.host + location.pathname).replace(/\btest\/$/, ''),
|
basePath = ('//' + location.host + location.pathname).replace(/\btest\/$/, ''),
|
||||||
isModularize = /modularize/.test(ui.urlParams.build),
|
|
||||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||||
|
locationPath = modulePath.replace(reBasename, ''),
|
||||||
moduleMain = modulePath.match(reBasename)[0];
|
moduleMain = modulePath.match(reBasename)[0];
|
||||||
|
|
||||||
var locationPath = isModularize
|
|
||||||
? '../modularize'
|
|
||||||
: modulePath.replace(reBasename, '');
|
|
||||||
|
|
||||||
QUnit.config.autostart = false;
|
QUnit.config.autostart = false;
|
||||||
|
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
require({
|
require({
|
||||||
'baseUrl': './',
|
'baseUrl': './',
|
||||||
'urlArgs': 't=' + (+new Date),
|
'urlArgs': 't=' + (+new Date),
|
||||||
'paths': {
|
|
||||||
'shimmed': './abc/../' + modulePath,
|
|
||||||
'underscore': './xyz/../' + modulePath
|
|
||||||
},
|
|
||||||
'aliases': [
|
|
||||||
['shimmed', 'lodash'],
|
|
||||||
['underscore', 'lodash']
|
|
||||||
],
|
|
||||||
'packages': [
|
'packages': [
|
||||||
{
|
{
|
||||||
'name': 'lodash',
|
'name': 'lodash',
|
||||||
'location': locationPath,
|
'location': locationPath,
|
||||||
'main': moduleMain
|
'main': moduleMain
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'shimmed',
|
||||||
|
'location': './abc/../' + locationPath,
|
||||||
|
'main': moduleMain
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'underscore',
|
||||||
|
'location': './xyz/../' + locationPath,
|
||||||
|
'main': moduleMain
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'test',
|
'name': 'test',
|
||||||
'location': basePath + '/test',
|
'location': basePath + '/test',
|
||||||
@@ -113,7 +111,7 @@
|
|||||||
lodashModule = lodash.noConflict();
|
lodashModule = lodash.noConflict();
|
||||||
lodashModule.moduleName = 'lodash';
|
lodashModule.moduleName = 'lodash';
|
||||||
}
|
}
|
||||||
if (isModularize) {
|
if (ui.isModularize) {
|
||||||
window._ = lodash;
|
window._ = lodash;
|
||||||
}
|
}
|
||||||
require(['test'], function() {
|
require(['test'], function() {
|
||||||
|
|||||||
@@ -49,11 +49,11 @@
|
|||||||
case 'lodash-modern': result = 'dist/lodash.min.js'; break;
|
case 'lodash-modern': result = 'dist/lodash.min.js'; break;
|
||||||
case 'lodash-legacy': result = 'dist/lodash.legacy.min.js'; break;
|
case 'lodash-legacy': result = 'dist/lodash.legacy.min.js'; break;
|
||||||
case 'lodash-mobile': result = 'dist/lodash.mobile.min.js'; break;
|
case 'lodash-mobile': result = 'dist/lodash.mobile.min.js'; break;
|
||||||
|
case 'lodash-modularize': result = 'modularize/lodash.js'; break;
|
||||||
case 'lodash-underscore': result = 'dist/lodash.underscore.min.js'; break;
|
case 'lodash-underscore': result = 'dist/lodash.underscore.min.js'; break;
|
||||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||||
case 'lodash-compat-dev':
|
case 'lodash-compat-dev':
|
||||||
case 'lodash-modularize':
|
|
||||||
case undefined: result = 'lodash.js'; break;
|
case undefined: result = 'lodash.js'; break;
|
||||||
default: return build;
|
default: return build;
|
||||||
}
|
}
|
||||||
@@ -73,6 +73,9 @@
|
|||||||
return basePath + result;
|
return basePath + result;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
// used to indicate testing a modularized build
|
||||||
|
ui.isModularize = /\b(?:lodash-(?:amd|node)|modularize)\b/.test(ui.buildPath);
|
||||||
|
|
||||||
// initialize controls
|
// initialize controls
|
||||||
addListener(window, 'load', function() {
|
addListener(window, 'load', function() {
|
||||||
function eventHandler(event) {
|
function eventHandler(event) {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load Lo-Dash again to overwrite the existing `_` value
|
// load Lo-Dash again to overwrite the existing `_` value
|
||||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||||
|
|
||||||
// load test.js if not using require.js
|
// load test.js if not using require.js
|
||||||
document.write(ui.urlParams.loader != 'none'
|
document.write(ui.urlParams.loader != 'none'
|
||||||
@@ -91,12 +91,9 @@
|
|||||||
var reBasename = /[\w.-]+$/,
|
var reBasename = /[\w.-]+$/,
|
||||||
basePath = ('//' + location.host + location.pathname).replace(/\btest\/$/, ''),
|
basePath = ('//' + location.host + location.pathname).replace(/\btest\/$/, ''),
|
||||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||||
|
locationPath = modulePath.replace(reBasename, ''),
|
||||||
moduleMain = modulePath.match(reBasename)[0];
|
moduleMain = modulePath.match(reBasename)[0];
|
||||||
|
|
||||||
var locationPath = /modularize/.test(ui.urlParams.build)
|
|
||||||
? '../modularize'
|
|
||||||
: modulePath.replace(reBasename, '');
|
|
||||||
|
|
||||||
QUnit.config.autostart = false;
|
QUnit.config.autostart = false;
|
||||||
|
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
|
|||||||
Reference in New Issue
Block a user