Skip to content
Permalink
Browse files

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

  • Loading branch information...
timmywil committed Sep 9, 2013
1 parent 4fd6e8e commit 2fe09ceaf9c261d8e7fbdf37a13b21bfd85da962
Showing with 75 additions and 26 deletions.
  1. +75 −26 build/r.js
@@ -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.
* see: http://github.com/jrburke/requirejs for details
*/
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
(function (console, args, readFileFunc) {
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
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$/,
commandOption = '',
useLibLoaded = {},
@@ -2663,8 +2663,8 @@ define('lang', function () {
_mixin: function(dest, source, override){
var name;
for (name in source) {
if(source.hasOwnProperty(name)
&& (override || !dest.hasOwnProperty(name))) {
if(source.hasOwnProperty(name) &&
(override || !dest.hasOwnProperty(name))) {
dest[name] = source[name];
}
}
@@ -2692,6 +2692,42 @@ define('lang', function () {
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 () {
// boodman/crockford delegation w/ cornford optimization
function TMP() {}
if (config.optimizeCss && config.optimizeCss !== "none" && config.dir) {
buildFileContents += optimize.css(config.dir, config);
}
}).then(function() {
baseConfig = lang.deeplikeCopy(require.s.contexts._.config);
}).then(function () {
var actions = [];

return function () {
//Save off buildPath to module index in a hash for quicker
//lookup later.
config._buildPathToModuleIndex[module._buildPath] = i;
config._buildPathToModuleIndex[file.normalize(module._buildPath)] = i;

//Call require to calculate dependencies.
return build.traceDependencies(module, config)
return build.traceDependencies(module, config, baseConfig)
.then(function (layer) {
module.layer = layer;
});
if (found) {
module.excludeLayers[i] = found;
} else {
return build.traceDependencies({name: exclude}, config)
return build.traceDependencies({name: exclude}, config, baseConfig)
.then(function (layer) {
module.excludeLayers[i] = { layer: layer };
});
//Be sure not to remove other build layers.
if (config.removeCombined) {
module.layer.buildFilePaths.forEach(function (path) {
if (file.exists(path) && !modules.some(function (mod) {
var isLayer = modules.some(function (mod) {
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);
}
});
* given module.
*
* @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
* be in the flattened module.
*/
build.traceDependencies = function (module, config) {
var include, override, layer, context, baseConfig, oldContext,
build.traceDependencies = function (module, config, baseLoaderConfig) {
var include, override, layer, context, oldContext,
rawTextByIds,
syncChecks = {
rhino: true,

//Grab the reset layer and context after the reset, but keep the
//old config to reuse in the new context.
baseConfig = oldContext.config;
layer = require._layer;
context = layer.context;

//Put back basic config, use a fresh object for it.
//WARNING: probably not robust for paths and packages/packagePaths,
//since those property's objects can be modified. But for basic
//config clone it works out.
require(lang.mixin({}, baseConfig, true));
if (baseLoaderConfig) {
require(lang.deeplikeCopy(baseLoaderConfig));
}

logger.trace("\nTracing dependencies for: " + (module.name || module.out));
include = module.name && !module.create ? [module.name] : [];

//If there are overrides to basic config, set that up now.;
if (module.override) {
override = lang.mixin({}, baseConfig, true);
lang.mixin(override, module.override, true);
if (baseLoaderConfig) {
override = build.createOverrideConfig(baseLoaderConfig, module.override);
} else {
override = lang.deeplikeCopy(module.override);
}
require(override);
}


return deferred.promise.then(function () {
//Reset config
if (module.override) {
require(baseConfig);
if (module.override && baseLoaderConfig) {
require(lang.deeplikeCopy(baseLoaderConfig));
}

build.checkForErrors(context);
};

build.createOverrideConfig = function (config, override) {
var cfg = {};
var cfg = lang.deeplikeCopy(config),
oride = lang.deeplikeCopy(override);

lang.mixin(cfg, config, true);
lang.eachProp(override, function (value, prop) {
lang.eachProp(oride, function (value, prop) {
if (hasProp(build.objProps, prop)) {
//An object property, merge keys. Start a new object
//so that source object in config does not get modified.
cfg[prop] = override[prop];
}
});

return cfg;
};

dir = dir.split('/');
dir.pop();
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, '\\$&') + "'});");
}
}

(typeof Packages !== 'undefined' || (typeof window === 'undefined' &&
typeof Components !== 'undefined' && Components.interfaces) ?
Array.prototype.slice.call(arguments, 0) : []),
(typeof readFile !== 'undefined' ? readFile : undefined)));
(typeof readFile !== 'undefined' ? readFile : undefined)));

0 comments on commit 2fe09ce

Please sign in to comment.
You can’t perform that action at this time.