1
1
#!/usr/bin/env node
2
2
/**
3
- * @license r.js 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
3
+ * @license r.js 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
4
4
* Available via the MIT or new BSD license.
5
5
* see: http://github.com/jrburke/requirejs for details
6
6
*/
@@ -21,7 +21,7 @@ var requirejs, require, define, xpcUtil;
21
21
(function (console, args, readFileFunc) {
22
22
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
23
23
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
24
- version = '2.1.13 ',
24
+ version = '2.1.14 ',
25
25
jsSuffixRegExp = /\.js$/,
26
26
commandOption = '',
27
27
useLibLoaded = {},
@@ -239,7 +239,7 @@ var requirejs, require, define, xpcUtil;
239
239
}
240
240
241
241
/** vim: et:ts=4:sw=4:sts=4
242
- * @license RequireJS 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
242
+ * @license RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
243
243
* Available via the MIT or new BSD license.
244
244
* see: http://github.com/jrburke/requirejs for details
245
245
*/
@@ -252,7 +252,7 @@ var requirejs, require, define, xpcUtil;
252
252
(function (global) {
253
253
var req, s, head, baseElement, dataMain, src,
254
254
interactiveScript, currentlyAddingScript, mainScript, subPath,
255
- version = '2.1.13 ',
255
+ version = '2.1.14 ',
256
256
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
257
257
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
258
258
jsSuffixRegExp = /\.js$/,
@@ -684,7 +684,16 @@ var requirejs, require, define, xpcUtil;
684
684
return normalize(name, parentName, applyMap);
685
685
});
686
686
} else {
687
- normalizedName = normalize(name, parentName, applyMap);
687
+ // If nested plugin references, then do not try to
688
+ // normalize, as it will not normalize correctly. This
689
+ // places a restriction on resourceIds, and the longer
690
+ // term solution is not to normalize until plugins are
691
+ // loaded and all normalizations to allow for async
692
+ // loading of a loader plugin. But for now, fixes the
693
+ // common uses. Details in #1131
694
+ normalizedName = name.indexOf('!') === -1 ?
695
+ normalize(name, parentName, applyMap) :
696
+ name;
688
697
}
689
698
} else {
690
699
//A regular module.
@@ -22755,7 +22764,11 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22755
22764
22756
22765
//This string is saved off because JSLint complains
22757
22766
//about obj.arguments use, as 'reserved word'
22758
- var argPropName = 'arguments';
22767
+ var argPropName = 'arguments',
22768
+ //Default object to use for "scope" checking for UMD identifiers.
22769
+ emptyScope = {},
22770
+ mixin = lang.mixin,
22771
+ hasProp = lang.hasProp;
22759
22772
22760
22773
//From an esprima example for traversing its ast.
22761
22774
function traverse(object, visitor) {
@@ -22857,7 +22870,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22857
22870
needsDefine = true,
22858
22871
astRoot = esprima.parse(fileContents);
22859
22872
22860
- parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier) {
22873
+ parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier, fnExpScope ) {
22861
22874
if (!deps) {
22862
22875
deps = [];
22863
22876
}
@@ -22877,7 +22890,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22877
22890
});
22878
22891
}
22879
22892
22880
- if (factoryIdentifier) {
22893
+ if (callName === 'define' && factoryIdentifier && hasProp(fnExpScope, factoryIdentifier) ) {
22881
22894
return factoryIdentifier;
22882
22895
}
22883
22896
@@ -22930,14 +22943,18 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22930
22943
* @param {Function} onMatch function to call on a parse match.
22931
22944
* @param {Object} [options] This is normally the build config options if
22932
22945
* it is passed.
22946
+ * @param {Object} [fnExpScope] holds list of function expresssion
22947
+ * argument identifiers, set up internally, not passed in
22933
22948
*/
22934
- parse.recurse = function (object, onMatch, options) {
22949
+ parse.recurse = function (object, onMatch, options, fnExpScope ) {
22935
22950
//Like traverse, but skips if branches that would not be processed
22936
22951
//after has application that results in tests of true or false boolean
22937
22952
//literal values.
22938
- var key, child, result,
22953
+ var key, child, result, i, params, param,
22939
22954
hasHas = options && options.has;
22940
22955
22956
+ fnExpScope = fnExpScope || emptyScope;
22957
+
22941
22958
if (!object) {
22942
22959
return;
22943
22960
}
@@ -22948,24 +22965,44 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22948
22965
object.test.type === 'Literal') {
22949
22966
if (object.test.value) {
22950
22967
//Take the if branch
22951
- this.recurse(object.consequent, onMatch, options);
22968
+ this.recurse(object.consequent, onMatch, options, fnExpScope );
22952
22969
} else {
22953
22970
//Take the else branch
22954
- this.recurse(object.alternate, onMatch, options);
22971
+ this.recurse(object.alternate, onMatch, options, fnExpScope );
22955
22972
}
22956
22973
} else {
22957
- result = this.parseNode(object, onMatch);
22974
+ result = this.parseNode(object, onMatch, fnExpScope );
22958
22975
if (result === false) {
22959
22976
return;
22960
22977
} else if (typeof result === 'string') {
22961
22978
return result;
22962
22979
}
22963
22980
22981
+ //Build up a "scope" object that informs nested recurse calls if
22982
+ //the define call references an identifier that is likely a UMD
22983
+ //wrapped function expresion argument.
22984
+ if (object.type === 'ExpressionStatement' && object.expression &&
22985
+ object.expression.type === 'CallExpression' && object.expression.callee &&
22986
+ object.expression.callee.type === 'FunctionExpression') {
22987
+ object = object.expression.callee;
22988
+
22989
+ if (object.params && object.params.length) {
22990
+ params = object.params;
22991
+ fnExpScope = mixin({}, fnExpScope, true);
22992
+ for (i = 0; i < params.length; i++) {
22993
+ param = params[i];
22994
+ if (param.type === 'Identifier') {
22995
+ fnExpScope[param.name] = true;
22996
+ }
22997
+ }
22998
+ }
22999
+ }
23000
+
22964
23001
for (key in object) {
22965
23002
if (object.hasOwnProperty(key)) {
22966
23003
child = object[key];
22967
23004
if (typeof child === 'object' && child !== null) {
22968
- result = this.recurse(child, onMatch, options);
23005
+ result = this.recurse(child, onMatch, options, fnExpScope );
22969
23006
if (typeof result === 'string') {
22970
23007
break;
22971
23008
}
@@ -22977,23 +23014,10 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
22977
23014
//passed in as a function expression, indicating a UMD-type of
22978
23015
//wrapping.
22979
23016
if (typeof result === 'string') {
22980
- if (object.type === 'ExpressionStatement' && object.expression &&
22981
- object.expression.type === 'CallExpression' && object.expression.callee &&
22982
- object.expression.callee.type === 'FunctionExpression') {
22983
- object = object.expression.callee;
22984
-
22985
- if (object.params && object.params.length) {
22986
- if (object.params.some(function(param) {
22987
- //Found an identifier match, so stop parsing from this
22988
- //level down.
22989
- return param.type === 'Identifier' &&
22990
- param.name === result;
22991
- })) {
22992
- //Just a plain return, parsing can continue past this
22993
- //point.
22994
- return;
22995
- }
22996
- }
23017
+ if (hasProp(fnExpScope, result)) {
23018
+ //Just a plain return, parsing can continue past this
23019
+ //point.
23020
+ return;
22997
23021
}
22998
23022
22999
23023
return result;
@@ -23471,11 +23495,14 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23471
23495
* @param {Function} onMatch a function to call when a match is found.
23472
23496
* It is passed the match name, and the config, name, deps possible args.
23473
23497
* The config, name and deps args are not normalized.
23498
+ * @param {Object} fnExpScope an object whose keys are all function
23499
+ * expression identifiers that should be in scope. Useful for UMD wrapper
23500
+ * detection to avoid parsing more into the wrapped UMD code.
23474
23501
*
23475
23502
* @returns {String} a JS source string with the valid require/define call.
23476
23503
* Otherwise null.
23477
23504
*/
23478
- parse.parseNode = function (node, onMatch) {
23505
+ parse.parseNode = function (node, onMatch, fnExpScope ) {
23479
23506
var name, deps, cjsDeps, arg, factory, exp, refsDefine, bodyNode,
23480
23507
args = node && node[argPropName],
23481
23508
callName = parse.hasRequire(node);
@@ -23549,7 +23576,8 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23549
23576
}
23550
23577
23551
23578
return onMatch("define", null, name, deps, node,
23552
- (factory && factory.type === 'Identifier' ? factory.name : undefined));
23579
+ (factory && factory.type === 'Identifier' ? factory.name : undefined),
23580
+ fnExpScope);
23553
23581
} else if (node.type === 'CallExpression' && node.callee &&
23554
23582
node.callee.type === 'FunctionExpression' &&
23555
23583
node.callee.body && node.callee.body.body &&
@@ -23577,7 +23605,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
23577
23605
23578
23606
if (refsDefine) {
23579
23607
return onMatch("define", null, null, null, exp.expression,
23580
- exp.expression.arguments[0].name);
23608
+ exp.expression.arguments[0].name, fnExpScope );
23581
23609
}
23582
23610
}
23583
23611
}
@@ -25152,6 +25180,11 @@ define('requirePatch', [ 'env!env/file', 'pragma', 'parse', 'lang', 'logger', 'c
25152
25180
falseProp = lang.falseProp,
25153
25181
getOwn = lang.getOwn;
25154
25182
25183
+ //Turn off throwing on resolution conflict, that was just an older prim
25184
+ //idea about finding errors early, but does not comply with how promises
25185
+ //should operate.
25186
+ prim.hideResolutionConflict = true;
25187
+
25155
25188
//This method should be called when the patches to require should take hold.
25156
25189
return function () {
25157
25190
if (!allowRun) {
0 commit comments