8000 2.1.14 · requirejs/requirejs-npm@3be79c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3be79c9

Browse files
committed
2.1.14
1 parent 5c5940b commit 3be79c9

File tree

3 files changed

+80
-38
lines changed

3 files changed

+80
-38
lines changed

requirejs/bin/r.js

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
/**
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.
44
* Available via the MIT or new BSD license.
55
* see: http://github.com/jrburke/requirejs for details
66
*/
@@ -21,7 +21,7 @@ var requirejs, require, define, xpcUtil;
2121
(function (console, args, readFileFunc) {
2222
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2323
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
24-
version = '2.1.13',
24+
version = '2.1.14',
2525
jsSuffixRegExp = /\.js$/,
2626
commandOption = '',
2727
useLibLoaded = {},
@@ -239,7 +239,7 @@ var requirejs, require, define, xpcUtil;
239239
}
240240

241241
/** 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.
243243
* Available via the MIT or new BSD license.
244244
* see: http://github.com/jrburke/requirejs for details
245245
*/
@@ -252,7 +252,7 @@ var requirejs, require, define, xpcUtil;
252252
(function (global) {
253253
var req, s, head, baseElement, dataMain, src,
254254
interactiveScript, currentlyAddingScript, mainScript, subPath,
255-
version = '2.1.13',
255+
version = '2.1.14',
256256
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
257257
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
258258
jsSuffixRegExp = /\.js$/,
@@ -684,7 +684,16 @@ var requirejs, require, define, xpcUtil;
684684
return normalize(name, parentName, applyMap);
685685
});
686686
} 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;
688697
}
689698
} else {
690699
//A regular module.
@@ -22755,7 +22764,11 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2275522764

2275622765
//This string is saved off because JSLint complains
2275722766
//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;
2275922772

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

22860-
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier) {
22873+
parse.recurse(astRoot, function (callName, config, name, deps, node, factoryIdentifier, fnExpScope) {
2286122874
if (!deps) {
2286222875
deps = [];
2286322876
}
@@ -22877,7 +22890,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2287722890
});
2287822891
}
2287922892

22880-
if (factoryIdentifier) {
22893+
if (callName === 'define' && factoryIdentifier && hasProp(fnExpScope, factoryIdentifier)) {
2288122894
return factoryIdentifier;
2288222895
}
2288322896

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

22956+
fnExpScope = fnExpScope || emptyScope;
22957+
2294122958
if (!object) {
2294222959
return;
2294322960
}
@@ -22948,24 +22965,44 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2294822965
object.test.type === 'Literal') {
2294922966
if (object.test.value) {
2295022967
//Take the if branch
22951-
this.recurse(object.consequent, onMatch, options);
22968+
this.recurse(object.consequent, onMatch, options, fnExpScope);
2295222969
} else {
2295322970
//Take the else branch
22954-
this.recurse(object.alternate, onMatch, options);
22971+
this.recurse(object.alternate, onMatch, options, fnExpScope);
2295522972
}
2295622973
} else {
22957-
result = this.parseNode(object, onMatch);
22974+
result = this.parseNode(object, onMatch, fnExpScope);
2295822975
if (result === false) {
2295922976
return;
2296022977
} else if (typeof result === 'string') {
2296122978
return result;
2296222979
}
2296322980

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+
2296423001
for (key in object) {
2296523002
if (object.hasOwnProperty(key)) {
2296623003
child = object[key];
2296723004
if (typeof child === 'object' && child !== null) {
22968-
result = this.recurse(child, onMatch, options);
23005+
result = this.recurse(child, onMatch, options, fnExpScope);
2296923006
if (typeof result === 'string') {
2297023007
break;
2297123008
}
@@ -22977,23 +23014,10 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2297723014
//passed in as a function expression, indicating a UMD-type of
2297823015
//wrapping.
2297923016
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;
2299723021
}
2299823022

2299923023
return result;
@@ -23471,11 +23495,14 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2347123495
* @param {Function} onMatch a function to call when a match is found.
2347223496
* It is passed the match name, and the config, name, deps possible args.
2347323497
* 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.
2347423501
*
2347523502
* @returns {String} a JS source string with the valid require/define call.
2347623503
* Otherwise null.
2347723504
*/
23478-
parse.parseNode = function (node, onMatch) {
23505+
parse.parseNode = function (node, onMatch, fnExpScope) {
2347923506
var name, deps, cjsDeps, arg, factory, exp, refsDefine, bodyNode,
2348023507
args = node && node[argPropName],
2348123508
callName = parse.hasRequire(node);
@@ -23549,7 +23576,8 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2354923576
}
2355023577

2355123578
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);
2355323581
} else if (node.type === 'CallExpression' && node.callee &&
2355423582
node.callee.type === 'FunctionExpression' &&
2355523583
node.callee.body && node.callee.body.body &&
@@ -23577,7 +23605,7 @@ define('parse', ['./esprimaAdapter', 'lang'], function (esprima, lang) {
2357723605

2357823606
if (refsDefine) {
2357923607
return onMatch("define", null, null, null, exp.expression,
23580-
exp.expression.arguments[0].name);
23608+
exp.expression.arguments[0].name, fnExpScope);
2358123609
}
2358223610
}
2358323611
}
@@ -25152,6 +25180,11 @@ define('requirePatch', [ 'env!env/file', 'pragma', 'parse', 'lang', 'logger', 'c
2515225180
falseProp = lang.falseProp,
2515325181
getOwn = lang.getOwn;
2515425182

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+
2515525188
//This method should be called when the patches to require should take hold.
2515625189
return function () {
2515725190
if (!allowRun) {

requirejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "requirejs",
33
"description": "Node adapter for RequireJS, for loading AMD modules. Includes RequireJS optimizer",
4-
"version": "2.1.13",
4+
"version": "2.1.14",
55
"homepage": "http://github.com/jrburke/r.js",
66
"author": "James Burke <jrburke@gmail.com> (http://github.com/jrburke)",
77
"licenses": [

requirejs/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)
0