diff --git a/platform/framework/src/FrameworkLayer.js b/platform/framework/src/FrameworkLayer.js index c25afe5be7..753eb91dfe 100644 --- a/platform/framework/src/FrameworkLayer.js +++ b/platform/framework/src/FrameworkLayer.js @@ -55,11 +55,15 @@ define([ this.$log = $log; } - FrameworkLayer.prototype.initializeApplication = function (angular, logLevel) { + FrameworkLayer.prototype.initializeApplication = function ( + angular, + legacyRegistry, + logLevel + ) { var $http = this.$http, $log = this.$log, app = angular.module(Constants.MODULE_NAME, ["ngRoute"]), - loader = new BundleLoader($http, $log), + loader = new BundleLoader($http, $log, legacyRegistry), resolver = new BundleResolver( new ExtensionResolver( new ImplementationLoader(require), diff --git a/platform/framework/src/Main.js b/platform/framework/src/Main.js index caf66b7b6a..936461bfaf 100644 --- a/platform/framework/src/Main.js +++ b/platform/framework/src/Main.js @@ -56,7 +56,7 @@ define( function Main() { } - Main.prototype.run = function () { + Main.prototype.run = function (legacyRegistry) { // Get a reference to Angular's injector, so we can get $http and $log // services, which are useful to the framework layer. var injector = angular.injector(['ng']); @@ -74,7 +74,7 @@ define( // to the root now. requirejs.config({"baseUrl": ""}); injector.instantiate(['$http', '$log', FrameworkLayer]) - .initializeApplication(angular, logLevel()); + .initializeApplication(angular, legacyRegistry, logLevel()); }; return Main; diff --git a/platform/framework/src/load/BundleLoader.js b/platform/framework/src/load/BundleLoader.js index 1ae3a2eb70..737771809f 100644 --- a/platform/framework/src/load/BundleLoader.js +++ b/platform/framework/src/load/BundleLoader.js @@ -44,9 +44,10 @@ define( * @param $http Angular's HTTP requester * @param $log Angular's logging service */ - function BundleLoader($http, $log) { + function BundleLoader($http, $log, legacyRegistry) { this.$http = $http; this.$log = $log; + this.legacyRegistry = legacyRegistry; } /** @@ -96,6 +97,13 @@ define( // Load an individual bundle, as a Bundle object. // Returns undefined if the definition could not be loaded. function loadBundle(bundlePath) { + if (this.legacyRegistry.contains(bundlePath)) { + return Promise.resolve(new Bundle( + bundlePath, + this.legacyRegistry.get(bundlePath) + )); + } + return loadBundleDefinition(bundlePath).then(function (definition) { return definition && (new Bundle(bundlePath, definition)); }); @@ -104,7 +112,9 @@ define( // Load all named bundles from the array, returned as an array // of Bundle objects. function loadBundlesFromArray(bundleArray) { - var bundlePromises = bundleArray.map(loadBundle); + var bundlePromises = this.legacyRegistry.list() + .concat(bundleArray) + .map(loadBundle); return Promise.all(bundlePromises) .then(filterBundles); @@ -117,8 +127,8 @@ define( } return Array.isArray(bundles) ? loadBundlesFromArray(bundles) : - (typeof bundles === 'string') ? loadBundlesFromFile(bundles) : - Promise.reject(new Error(INVALID_ARGUMENT_MESSAGE)); + (typeof bundles === 'string') ? loadBundlesFromFile(bundles) : + Promise.reject(new Error(INVALID_ARGUMENT_MESSAGE)); }; return BundleLoader; diff --git a/src/BundleRegistry.js b/src/BundleRegistry.js index 4bf2f8091c..73d6ebecae 100644 --- a/src/BundleRegistry.js +++ b/src/BundleRegistry.js @@ -22,6 +22,8 @@ /*global define*/ define(function () { + 'use strict'; + function BundleRegistry() { this.bundles = {}; } @@ -38,5 +40,9 @@ define(function () { return this.bundles[path]; }; + BundleRegistry.prototype.list = function () { + return Object.keys(this.bundles); + }; + return BundleRegistry; }); \ No newline at end of file