Make modularized paths relative and always include a dependency array, even if it's empty.

Former-commit-id: 8f5edb85f01b472b6cc705da6e292d760d3ab12a
This commit is contained in:
John-David Dalton
2013-07-03 23:53:16 -07:00
parent 63a1c8b63e
commit c740562dd8

View File

@@ -791,24 +791,29 @@
var categories = _.uniq(_.compact(identifiers.map(getCategory))), var categories = _.uniq(_.compact(identifiers.map(getCategory))),
isAMD = _.contains(exportsOptions, 'amd'), isAMD = _.contains(exportsOptions, 'amd'),
outputPath = options[_.indexOf(options, '-o') + 1]; outputPath = options[_.indexOf(options, '-o') + 1],
sep = '/';
var topLevel = { var topLevel = {
'lodash': true, 'lodash': true,
'support': true 'support': true
}; };
function getDepPaths(dependencies) { var getDepPaths = function(dependencies, fromPath) {
fromPath || (fromPath = '');
return dependencies.map(function(depName) { return dependencies.map(function(depName) {
return getPath(depName) + depName; var toPath = getPath(depName),
}); relative = (path.relative(fromPath, toPath) || '.').replace(RegExp(path.sepEscaped, 'g'), sep);
}
function getPath(identifier) { return relative + sep + depName;
});
};
var getPath = function(identifier) {
return topLevel[identifier] return topLevel[identifier]
? '' ? ''
: (getCategory(identifier) || 'internals').toLowerCase() + '/'; : (getCategory(identifier) || 'internals').toLowerCase() + sep;
} };
// create modules for each identifier // create modules for each identifier
identifiers.forEach(function(identifier) { identifiers.forEach(function(identifier) {
@@ -820,8 +825,9 @@
if (identifier == 'templateSettings') { if (identifier == 'templateSettings') {
deps = ['escape', 'reInterpolate']; deps = ['escape', 'reInterpolate'];
} }
var depArgs = deps.join(', '), var modulePath = getPath(identifier),
depPaths = deps.length ? "['" + getDepPaths(deps).join("', '") + "'], " : '', depArgs = deps.join(', '),
depPaths = '[' + (deps.length ? "'" + getDepPaths(deps, modulePath).join("', '") + "'" : '') + '], ',
iife = []; iife = [];
if (isAMD) { if (isAMD) {
@@ -837,7 +843,7 @@
'exports=none', 'exports=none',
'include=' + identifier, 'include=' + identifier,
'iife=' + iife.join('\n'), 'iife=' + iife.join('\n'),
'-o', path.join(outputPath, getPath(identifier) + identifier + '.js') '-o', path.join(outputPath, modulePath + identifier + '.js')
)); ));
}); });
@@ -845,7 +851,7 @@
categories.forEach(function(category) { categories.forEach(function(category) {
var deps = _.intersection(categoryMap[category], identifiers).sort(), var deps = _.intersection(categoryMap[category], identifiers).sort(),
depArgs = deps.join(', '), depArgs = deps.join(', '),
depPaths = deps.length ? "['" + getDepPaths(deps).join("', '") + "'], " : '', depPaths = "['" + getDepPaths(deps).join("', '") + "'], ",
iife = []; iife = [];
if (isAMD) { if (isAMD) {