Update r.js (running latest master until new r.js is published to NPM)

This commit is contained in:
Timmy Willison 2013-09-09 11:23:16 -04:00
parent 4fd6e8e760
commit 2fe09ceaf9

View File

@ -1,5 +1,5 @@
/** /**
* @license r.js 2.1.8+ Tue, 13 Aug 2013 02:54:07 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license r.js 2.1.8+ Fri, 30 Aug 2013 03:19:39 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
(function (console, args, readFileFunc) { (function (console, args, readFileFunc) {
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire, var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci, nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
version = '2.1.8+ Tue, 13 Aug 2013 02:54:07 GMT', version = '2.1.8+ Fri, 30 Aug 2013 03:19:39 GMT',
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
commandOption = '', commandOption = '',
useLibLoaded = {}, useLibLoaded = {},
@ -2663,8 +2663,8 @@ define('lang', function () {
_mixin: function(dest, source, override){ _mixin: function(dest, source, override){
var name; var name;
for (name in source) { for (name in source) {
if(source.hasOwnProperty(name) if(source.hasOwnProperty(name) &&
&& (override || !dest.hasOwnProperty(name))) { (override || !dest.hasOwnProperty(name))) {
dest[name] = source[name]; dest[name] = source[name];
} }
} }
@ -2692,6 +2692,42 @@ define('lang', function () {
return dest; // Object return dest; // Object
}, },
/**
* Does a type of deep copy. Do not give it anything fancy, best
* for basic object copies of objects that also work well as
* JSON-serialized things, or has properties pointing to functions.
* For non-array/object values, just returns the same object.
* @param {Object} obj copy properties from this object
* @param {Object} [result] optional result object to use
* @return {Object}
*/
deeplikeCopy: function (obj) {
var type, result;
if (lang.isArray(obj)) {
result = [];
obj.forEach(function(value) {
result.push(lang.deeplikeCopy(value));
});
return result;
}
type = typeof obj;
if (obj === null || obj === undefined || type === 'boolean' ||
type === 'string' || type === 'number' || lang.isFunction(obj) ||
lang.isRegExp(obj)) {
return obj;
}
//Anything else is an object, hopefully.
result = {};
lang.eachProp(obj, function(value, key) {
result[key] = lang.deeplikeCopy(value);
});
return result;
},
delegate: (function () { delegate: (function () {
// boodman/crockford delegation w/ cornford optimization // boodman/crockford delegation w/ cornford optimization
function TMP() {} function TMP() {}
@ -24119,6 +24155,8 @@ define('build', function (require) {
if (config.optimizeCss && config.optimizeCss !== "none" && config.dir) { if (config.optimizeCss && config.optimizeCss !== "none" && config.dir) {
buildFileContents += optimize.css(config.dir, config); buildFileContents += optimize.css(config.dir, config);
} }
}).then(function() {
baseConfig = lang.deeplikeCopy(require.s.contexts._.config);
}).then(function () { }).then(function () {
var actions = []; var actions = [];
@ -24127,10 +24165,10 @@ define('build', function (require) {
return function () { return function () {
//Save off buildPath to module index in a hash for quicker //Save off buildPath to module index in a hash for quicker
//lookup later. //lookup later.
config._buildPathToModuleIndex[module._buildPath] = i; config._buildPathToModuleIndex[file.normalize(module._buildPath)] = i;
//Call require to calculate dependencies. //Call require to calculate dependencies.
return build.traceDependencies(module, config) return build.traceDependencies(module, config, baseConfig)
.then(function (layer) { .then(function (layer) {
module.layer = layer; module.layer = layer;
}); });
@ -24158,7 +24196,7 @@ define('build', function (require) {
if (found) { if (found) {
module.excludeLayers[i] = found; module.excludeLayers[i] = found;
} else { } else {
return build.traceDependencies({name: exclude}, config) return build.traceDependencies({name: exclude}, config, baseConfig)
.then(function (layer) { .then(function (layer) {
module.excludeLayers[i] = { layer: layer }; module.excludeLayers[i] = { layer: layer };
}); });
@ -24241,9 +24279,16 @@ define('build', function (require) {
//Be sure not to remove other build layers. //Be sure not to remove other build layers.
if (config.removeCombined) { if (config.removeCombined) {
module.layer.buildFilePaths.forEach(function (path) { module.layer.buildFilePaths.forEach(function (path) {
if (file.exists(path) && !modules.some(function (mod) { var isLayer = modules.some(function (mod) {
return mod._buildPath === path; return mod._buildPath === path;
})) { }),
relPath = build.makeRelativeFilePath(config.dir, path);
if (file.exists(path) &&
// not a build layer target
!isLayer &&
// not outside the build directory
relPath.indexOf('..') !== 0) {
file.deleteFile(path); file.deleteFile(path);
} }
}); });
@ -25069,13 +25114,14 @@ define('build', function (require) {
* given module. * given module.
* *
* @param {Object} module the module object from the build config info. * @param {Object} module the module object from the build config info.
* @param {Object} the build config object. * @param {Object} config the build config object.
* @param {Object} [baseLoaderConfig] the base loader config to use for env resets.
* *
* @returns {Object} layer information about what paths and modules should * @returns {Object} layer information about what paths and modules should
* be in the flattened module. * be in the flattened module.
*/ */
build.traceDependencies = function (module, config) { build.traceDependencies = function (module, config, baseLoaderConfig) {
var include, override, layer, context, baseConfig, oldContext, var include, override, layer, context, oldContext,
rawTextByIds, rawTextByIds,
syncChecks = { syncChecks = {
rhino: true, rhino: true,
@ -25090,15 +25136,13 @@ define('build', function (require) {
//Grab the reset layer and context after the reset, but keep the //Grab the reset layer and context after the reset, but keep the
//old config to reuse in the new context. //old config to reuse in the new context.
baseConfig = oldContext.config;
layer = require._layer; layer = require._layer;
context = layer.context; context = layer.context;
//Put back basic config, use a fresh object for it. //Put back basic config, use a fresh object for it.
//WARNING: probably not robust for paths and packages/packagePaths, if (baseLoaderConfig) {
//since those property's objects can be modified. But for basic require(lang.deeplikeCopy(baseLoaderConfig));
//config clone it works out. }
require(lang.mixin({}, baseConfig, true));
logger.trace("\nTracing dependencies for: " + (module.name || module.out)); logger.trace("\nTracing dependencies for: " + (module.name || module.out));
include = module.name && !module.create ? [module.name] : []; include = module.name && !module.create ? [module.name] : [];
@ -25108,8 +25152,11 @@ define('build', function (require) {
//If there are overrides to basic config, set that up now.; //If there are overrides to basic config, set that up now.;
if (module.override) { if (module.override) {
override = lang.mixin({}, baseConfig, true); if (baseLoaderConfig) {
lang.mixin(override, module.override, true); override = build.createOverrideConfig(baseLoaderConfig, module.override);
} else {
override = lang.deeplikeCopy(module.override);
}
require(override); require(override);
} }
@ -25155,8 +25202,8 @@ define('build', function (require) {
return deferred.promise.then(function () { return deferred.promise.then(function () {
//Reset config //Reset config
if (module.override) { if (module.override && baseLoaderConfig) {
require(baseConfig); require(lang.deeplikeCopy(baseLoaderConfig));
} }
build.checkForErrors(context); build.checkForErrors(context);
@ -25237,10 +25284,10 @@ define('build', function (require) {
}; };
build.createOverrideConfig = function (config, override) { build.createOverrideConfig = function (config, override) {
var cfg = {}; var cfg = lang.deeplikeCopy(config),
oride = lang.deeplikeCopy(override);
lang.mixin(cfg, config, true); lang.eachProp(oride, function (value, prop) {
lang.eachProp(override, function (value, prop) {
if (hasProp(build.objProps, prop)) { if (hasProp(build.objProps, prop)) {
//An object property, merge keys. Start a new object //An object property, merge keys. Start a new object
//so that source object in config does not get modified. //so that source object in config does not get modified.
@ -25251,6 +25298,7 @@ define('build', function (require) {
cfg[prop] = override[prop]; cfg[prop] = override[prop];
} }
}); });
return cfg; return cfg;
}; };
@ -25570,7 +25618,8 @@ define('build', function (require) {
dir = dir.split('/'); dir = dir.split('/');
dir.pop(); dir.pop();
dir = dir.join('/'); dir = dir.join('/');
exec("require({baseUrl: '" + dir + "'});"); //Make sure dir is JS-escaped, since it will be part of a JS string.
exec("require({baseUrl: '" + dir.replace(/[\\"']/g, '\\$&') + "'});");
} }
} }