Skip to content

Commit ae10634

Browse files
committed
only do the loadLib once per each uselib context.
1 parent 2b95c92 commit ae10634

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

build/jslib/parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ define(['uglifyjs/index'], function (uglify) {
401401
//This is a litle bit inefficient, it ends up with two uglifyjs parser
402402
//calls. Can revisit later, but trying to build out larger functional
403403
//pieces first.
404-
var astRoot = parser.parse(fileContents);
404+
var dependencies = [],
405+
astRoot = parser.parse(fileContents);
405406

406407
parse.recurse(astRoot, function (callName, config, name, deps) {
407408
//Normalize the input args.

build/jslib/x.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 1.0.4+ Copyright (c) 2010-2011, 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,9 +20,10 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.4',
23+
version = '1.0.4+',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
26+
useLibLoaded = {},
2627
//Used by jslib/rhino/args.js
2728
rhinoArgs = args,
2829
readFile = typeof readFileFunc !== 'undefined' ? readFileFunc : null;
@@ -196,9 +197,12 @@ var requirejs, require, define;
196197
callback = contextName;
197198
contextName = 'uselib';
198199
}
199-
200-
loadLib();
201-
200+
201+
if (!useLibLoaded[contextName]) {
202+
loadLib();
203+
useLibLoaded[contextName] = true;
204+
}
205+
202206
var req = requirejs({
203207
context: contextName
204208
});

build/tests/tools/uselib/parseDeps.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var requirejs = require('../../../../r.js'),
99
dir = __dirname,
1010
thisName = path.basename(__filename);
1111

12-
requirejs.tools.useLib(function (require) {
12+
function onLib(require) {
1313
require(['parse'], function (parse) {
1414
var deps = {};
1515

@@ -25,4 +25,8 @@ requirejs.tools.useLib(function (require) {
2525

2626
console.log(JSON.stringify(deps, null, ' '));
2727
});
28-
});
28+
}
29+
30+
//Do it twice, just to make sure it all holds together on multiple passes.
31+
requirejs.tools.useLib(onLib);
32+
requirejs.tools.useLib(onLib);

dist/r-edge.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 1.0.4+ 20120106 9pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 1.0.4+ 20120106 9:40pm Copyright (c) 2010-2011, 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,9 +20,10 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.4+ 20120106 9pm',
23+
version = '1.0.4+ 20120106 9:40pm',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
26+
useLibLoaded = {},
2627
//Used by jslib/rhino/args.js
2728
rhinoArgs = args,
2829
readFile = typeof readFileFunc !== 'undefined' ? readFileFunc : null;
@@ -9187,9 +9188,12 @@ function (lang, logger, file, parse, optimize, pragma,
91879188
callback = contextName;
91889189
contextName = 'uselib';
91899190
}
9190-
9191-
loadLib();
9192-
9191+
9192+
if (!useLibLoaded[contextName]) {
9193+
loadLib();
9194+
useLibLoaded[contextName] = true;
9195+
}
9196+
91939197
var req = requirejs({
91949198
context: contextName
91959199
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy