From 78a4d28d0fec538128463dc94044e73b04f5f142 Mon Sep 17 00:00:00 2001 From: Kenneth Kufluk Date: Mon, 19 Mar 2012 12:44:28 -0700 Subject: [PATCH] Add Bundle dependencies as paused dependencies, so that they aren't evaluated until they're used. --- src/loadrunner.js | 41 +++++++++++++++---------------------- test/modules/modcompiled.js | 1 + test/test.html | 14 +++++++++++++ 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/loadrunner.js b/src/loadrunner.js index 7629346..4e09fef 100644 --- a/src/loadrunner.js +++ b/src/loadrunner.js @@ -288,39 +288,32 @@ function Bundle(id, contents) { this.id = id; this.contents = contents; - if (id.match(/\.js$/)) { - this.path = path(using.path, id); - } else { - this.path = Module.prototype.resolvePath(id); - } + this.dep = createDependency(id); + this.deps = []; + this.path = this.dep.path; } Bundle.prototype = new Script; Bundle.prototype.start = function() { - var me = this, def, file; + var me = this, def, dep, key; for (var i=0, l=this.contents.length; i }); }); + QUnit.test('should only evaluate required modules from a bundle', function() { + expect(3); + stop(2000); + loadrunner.reset(); + window.thingLoaded = false; + equals(false, window.thingLoaded); + using.bundles.push({ 'modules/modcompiled.js': ['thing', 'another'] }); + using('another', function(a) { + equals(a, 'another'); + equals(false, window.thingLoaded); + start(); + }); + }); + QUnit.module('Autofetch tests', { teardown: function() {