1
1
/**
2
- * @license r.js 1.0.4+ 20120124 7pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 1.0.4+ 20120125 8:40pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName , env , fs , vm , path , exec , rhinoContext , dir , nodeRequire ,
22
22
nodeDefine , exists , reqMain , loadedOptimizedLib ,
23
- version = '1.0.4+ 20120124 7pm ' ,
23
+ version = '1.0.4+ 20120125 8:40pm ' ,
24
24
jsSuffixRegExp = / \. j s $ / ,
25
25
commandOption = '' ,
26
26
useLibLoaded = { } ,
@@ -2961,6 +2961,14 @@ define('lang', function () {
2961
2961
return lang . ostring . call ( it ) === "[object Array]" ;
2962
2962
} ,
2963
2963
2964
+ isFunction : function ( it ) {
2965
+ return lang . ostring . call ( it ) === "[object Function]" ;
2966
+ } ,
2967
+
2968
+ isRegExp : function ( it ) {
2969
+ return it && it instanceof RegExp ;
2970
+ } ,
2971
+
2964
2972
/**
2965
2973
* Simple function to mix in properties from source into target,
2966
2974
* but only if target does not already have a property of the same name.
@@ -6933,6 +6941,8 @@ define('parse', ['uglifyjs/index'], function (uglify) {
6933
6941
* @param {String } fileContents
6934
6942
*
6935
6943
* @returns {Object } a config object. Will be null if no config.
6944
+ * Can throw an error if the config in the file cannot be evaluated in
6945
+ * a build context to valid JavaScript.
6936
6946
*/
6937
6947
parse . findConfig = function ( fileName , fileContents ) {
6938
6948
/*jslint evil: true */
@@ -6947,14 +6957,8 @@ define('parse', ['uglifyjs/index'], function (uglify) {
6947
6957
6948
6958
if ( ! foundConfig && configNode ) {
6949
6959
jsConfig = parse . nodeToString ( configNode ) ;
6950
- if ( jsConfig ) {
6951
- try {
6952
- foundConfig = eval ( '(' + jsConfig + ')' ) ;
6953
- } catch ( e ) {
6954
- foundConfig = null ;
6955
- }
6956
- return foundConfig ;
6957
- }
6960
+ foundConfig = eval ( '(' + jsConfig + ')' ) ;
6961
+ return foundConfig ;
6958
6962
}
6959
6963
return undefined ;
6960
6964
} , null , parse . parseConfigNode ) ;
@@ -8876,7 +8880,8 @@ function (lang, logger, file, parse, optimize, pragma,
8876
8880
if ( config . paths ) {
8877
8881
for ( prop in config . paths ) {
8878
8882
if ( config . paths . hasOwnProperty ( prop ) ) {
8879
- config . paths [ prop ] = build . makeAbsPath ( config . paths [ prop ] , config . baseUrl ) ;
8883
+ config . paths [ prop ] = build . makeAbsPath ( config . paths [ prop ] ,
8884
+ ( config . baseUrl || absFilePath ) ) ;
8880
8885
}
8881
8886
}
8882
8887
}
@@ -8898,11 +8903,16 @@ function (lang, logger, file, parse, optimize, pragma,
8898
8903
* nested config, like paths, correctly.
8899
8904
*/
8900
8905
function mixConfig ( target , source ) {
8901
- var prop ;
8906
+ var prop , value ;
8902
8907
8903
8908
for ( prop in source ) {
8904
8909
if ( source . hasOwnProperty ( prop ) ) {
8905
- if ( build . nestedMix [ prop ] ) {
8910
+ //If the value of the property is a plain object, then
8911
+ //allow a one-level-deep mixing of it.
8912
+ value = source [ prop ] ;
8913
+ if ( typeof value === 'object' && value &&
8914
+ ! lang . isArray ( value ) && ! lang . isFunction ( value ) &&
8915
+ ! lang . isRegExp ( value ) ) {
8906
8916
if ( ! target [ prop ] ) {
8907
8917
target [ prop ] = { } ;
8908
8918
}
@@ -8963,7 +8973,17 @@ function (lang, logger, file, parse, optimize, pragma,
8963
8973
mainConfigFile = config . mainConfigFile || ( buildFileConfig && buildFileConfig . mainConfigFile ) ;
8964
8974
if ( mainConfigFile ) {
8965
8975
mainConfigFile = build . makeAbsPath ( mainConfigFile , absFilePath ) ;
8966
- mainConfig = parse . findConfig ( mainConfigFile , file . readFile ( mainConfigFile ) ) ;
8976
+ try {
8977
+ mainConfig = parse . findConfig ( mainConfigFile , file . readFile ( mainConfigFile ) ) ;
8978
+ } catch ( configError ) {
8979
+ throw new Error ( 'The config in mainConfigFile ' +
8980
+ mainConfigFile +
8981
+ ' cannot be used because it cannot be evaluated' +
8982
+ ' correctly while running in the optimizer. Try only' +
8983
+ ' using a config that is also valid JSON, or do not use' +
8984
+ ' mainConfigFile and instead copy the config values needed' +
8985
+ ' into a build file or command line arguments given to the optimizer.' ) ;
8986
+ }
8967
8987
if ( mainConfig ) {
8968
8988
//If no baseUrl, then use the directory holding the main config.
8969
8989
if ( ! mainConfig . baseUrl ) {
0 commit comments