/**
- * @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
*/
(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 = {},
_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];
}
}
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)));
\ No newline at end of file
+ (typeof readFile !== 'undefined' ? readFile : undefined)));