Skip to content

Commit f570461

Browse files
committed
requirejs 2.1.14
1 parent 900b560 commit f570461

File tree

2 files changed

+79
-37
lines changed

2 files changed

+79
-37
lines changed

tools/r.js

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define, xpcUtil;
2020
(function (console, args, readFileFunc) {
2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
23-
version = '2.1.13',
23+
version = '2.1.14',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
useLibLoaded = {},
@@ -238,7 +238,7 @@ var requirejs, require, define, xpcUtil;
238238
}
239239

240240
/** vim: et:ts=4:sw=4:sts=4
241-
* @license RequireJS 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
241+
* @license RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
242242
* Available via the MIT or new BSD license.
243243
* see: http://github.com/jrburke/requirejs for details
244244
*/
@@ -251,7 +251,7 @@ var requirejs, require, define, xpcUtil;
251251
(function (global) {
252252
var req, s, head, baseElement, dataMain, src,
253253
interactiveScript, currentlyAddingScript, mainScript, subPath,
254-
version = '2.1.13',
254+
version = '2.1.14',
255255
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
256256
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
257257
jsSuffixRegExp = /\.js$/,
@@ -683,7 +683,16 @@ var requirejs, require, define, xpcUtil;
683683
return normalize(name, parentName, applyMap);
684684
});
685685
} else {
686-
normalizedName = normalize(name, parentName, applyMap);
686+
// If nested plugin references, then do not try to
687+
// normalize, as it will not normalize correctly. This
688+
// places a restriction on resourceIds, and the longer
689+
// term solution is not to normalize until plugins are
690+
// loaded and all normalizations to allow for async
691+
// loading of a loader plugin. But for now, fixes the
692+
// common uses. Details in #1131
693+
normalizedName = name.indexOf('!') === -1 ?
694+
normalize(name, parentName, applyMap) :
695+
name;
687696
}
688697
} else {
689698
//A regular module.
@@ -22754,7 +22763,11 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2275422763

2275522764
//This string is saved off because JSLint complains
2275622765
//about obj.arguments use, as 'reserved word'
22757-
var argPropName = 'arguments';
22766+
var argPropName = 'arguments',
22767+
//Default object to use for "scope" checking for UMD identifiers.
22768+
emptyScope = {},
22769+
mixin = lang.mixin,
22770+
hasProp = lang.hasProp;
2275822771

2275922772
//From an esprima example for traversing its ast.
2276022773
function traverse(object, visitor) {
@@ -22856,7 +22869,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2285622869
needsDefine = true,
2285722870
astRoot = esprima.parse(fileContents);
2285822871

22859-
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier) {
22872+
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier, fnExpScope) {
2286022873
if (!deps) {
2286122874
deps = [];
2286222875
}
@@ -22876,7 +22889,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2287622889
});
2287722890
}
2287822891

22879-
if (factoryIdentifier) {
22892+
if (callName === 'define' && factoryIdentifier && hasProp(fnExpScope, factoryIdentifier)) {
2288022893
return factoryIdentifier;
2288122894
}
2288222895

@@ -22929,14 +22942,18 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2292922942
* @param {Function} onMatch function to call on a parse match.
2293022943
* @param {Object} [options] This is normally the build config options if
2293122944
* it is passed.
22945+
* @param {Object} [fnExpScope] holds list of function expresssion
22946+
* argument identifiers, set up internally, not passed in
2293222947
*/
22933-
parse.recurse = function (object, onMatch, options) {
22948+
parse.recurse = function (object, onMatch, options, fnExpScope) {
2293422949
//Like traverse, but skips if branches that would not be processed
2293522950
//after has application that results in tests of true or false boolean
2293622951
//literal values.
22937-
var key, child, result,
22952+
var key, child, result, i, params, param,
2293822953
hasHas = options && options.has;
2293922954

22955+
fnExpScope = fnExpScope || emptyScope;
22956+
2294022957
if (!object) {
2294122958
return;
2294222959
}
@@ -22947,24 +22964,44 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2294722964
object.test.type === 'Literal') {
2294822965
if (object.test.value) {
2294922966
//Take the if branch
22950-
this.recurse(object.consequent, onMatch, options);
22967+
this.recurse(object.consequent, onMatch, options, fnExpScope);
2295122968
} else {
2295222969
//Take the else branch
22953-
this.recurse(object.alternate, onMatch, options);
22970+
this.recurse(object.alternate, onMatch, options, fnExpScope);
2295422971
}
2295522972
} else {
22956-
result = this.parseNode(object, onMatch);
22973+
result = this.parseNode(object, onMatch, fnExpScope);
2295722974
if (result === false) {
2295822975
return;
2295922976
} else if (typeof result === 'string') {
2296022977
return result;
2296122978
}
2296222979

22980+
//Build up a "scope" object that informs nested recurse calls if
22981+
//the define call references an identifier that is likely a UMD
22982+
//wrapped function expresion argument.
22983+
if (object.type === 'ExpressionStatement' && object.expression &&
22984+
object.expression.type === 'CallExpression' && object.expression.callee &&
22985+
object.expression.callee.type === 'FunctionExpression') {
22986+
object = object.expression.callee;
22987+
22988+
if (object.params && object.params.length) {
22989+
params = object.params;
22990+
fnExpScope = mixin({}, fnExpScope, true);
22991+
for (i = 0; i < params.length; i++) {
22992+
param = params[i];
22993+
if (param.type === 'Identifier') {
22994+
fnExpScope[param.name] = true;
22995+
}
22996+
}
22997+
}
22998+
}
22999+
2296323000
for (key in object) {
2296423001
if (object.hasOwnProperty(key)) {
2296523002
child = object[key];
2296623003
if (typeof child === 'object' && child !== null) {
22967-
result = this.recurse(child, onMatch, options);
23004+
result = this.recurse(child, onMatch, options, fnExpScope);
2296823005
if (typeof result === 'string') {
2296923006
break;
2297023007
}
@@ -22976,23 +23013,10 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2297623013
//passed in as a function expression, indicating a UMD-type of
2297723014
//wrapping.
2297823015
if (typeof result === 'string') {
22979-
if (object.type === 'ExpressionStatement' && object.expression &&
22980-
object.expression.type === 'CallExpression' && object.expression.callee &&
22981-
object.expression.callee.type === 'FunctionExpression') {
22982-
object = object.expression.callee;
22983-
22984-
if (object.params && object.params.length) {
22985-
if (object.params.some(function(param) {
22986-
//Found an identifier match, so stop parsing from this
22987-
//level down.
22988-
return param.type === 'Identifier' &&
22989-
param.name === result;
22990-
})) {
22991-
//Just a plain return, parsing can continue past this
22992-
//point.
22993-
return;
22994-
}
22995-
}
23016+
if (hasProp(fnExpScope, result)) {
23017+
//Just a plain return, parsing can continue past this
23018+
//point.
23019+
return;
2299623020
}
2299723021

2299823022
return result;
@@ -23470,11 +23494,14 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2347023494
* @param {Function} onMatch a function to call when a match is found.
2347123495
* It is passed the match name, and the config, name, deps possible args.
2347223496
* The config, name and deps args are not normalized.
23497+
* @param {Object} fnExpScope an object whose keys are all function
23498+
* expression identifiers that should be in scope. Useful for UMD wrapper
23499+
* detection to avoid parsing more into the wrapped UMD code.
2347323500
*
2347423501
* @returns {String} a JS source string with the valid require/define call.
2347523502
* Otherwise null.
2347623503
*/
23477-
parse.parseNode = function (node, onMatch) {
23504+
parse.parseNode = function (node, onMatch, fnExpScope) {
2347823505
var name, deps, cjsDeps, arg, factory, exp, refsDefine, bodyNode,
2347923506
args = node && node[argPropName],
2348023507
callName = parse.hasRequire(node);
@@ -23548,7 +23575,8 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2354823575
}
2354923576

2355023577
return onMatch("define", null, name, deps, node,
23551-
(factory && factory.type === 'Identifier' ? factory.name : undefined));
23578+
(factory && factory.type === 'Identifier' ? factory.name : undefined),
23579+
fnExpScope);
2355223580
} else if (node.type === 'CallExpression' && node.callee &&
2355323581
node.callee.type === 'FunctionExpression' &&
2355423582
node.callee.body && node.callee.body.body &&
@@ -23576,7 +23604,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2357623604

2357723605
if (refsDefine) {
2357823606
return onMatch("define", null, null, null, exp.expression,
23579-
exp.expression.arguments[0].name);
23607+
exp.expression.arguments[0].name, fnExpScope);
2358023608
}
2358123609
}
2358223610
}
@@ -25151,6 +25179,11 @@ define('requirePatch', [ 'env!env/file', 'pragma', 'parse', 'lang', 'logger', 'c
2515125179
falseProp = lang.falseProp,
2515225180
getOwn = lang.getOwn;
2515325181

25182+
//Turn off throwing on resolution conflict, that was just an older prim
25183+
//idea about finding errors early, but does not comply with how promises
25184+
//should operate.
25185+
prim.hideResolutionConflict = true;
25186+
2515425187
//This method should be called when the patches to require should take hold.
2515525188
return function () {
2515625189
if (!allowRun) {

www/js/lib/require.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** vim: et:ts=4:sw=4:sts=4
2-
* @license RequireJS 2.1.13 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
2+
* @license RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -12,7 +12,7 @@ var requirejs, require, define;
1212
(function (global) {
1313
var req, s, head, baseElement, dataMain, src,
1414
interactiveScript, currentlyAddingScript, mainScript, subPath,
15-
version = '2.1.13',
15+
version = '2.1.14',
1616
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
1717
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
1818
jsSuffixRegExp = /\.js$/,
@@ -444,7 +444,16 @@ var requirejs, require, define;
444444
return normalize(name, parentName, applyMap);
445445
});
446446
} else {
447-
normalizedName = normalize(name, parentName, applyMap);
447+
// If nested plugin references, then do not try to
448+
// normalize, as it will not normalize correctly. This
449+
// places a restriction on resourceIds, and the longer
450+
// term solution is not to normalize until plugins are
451+
// loaded and all normalizations to allow for async
452+
// loading of a loader plugin. But for now, fixes the
453+
// common uses. Details in #1131
454+
normalizedName = name.indexOf('!') === -1 ?
455+
normalize(name, parentName, applyMap) :
456+
name;
448457
}
449458
} else {
450459
//A regular module.

0 commit comments

Comments
 (0)