Skip to content

Commit ba79cb9

Browse files
fix(aurelia): plugin loading module id fix
1 parent 07de898 commit ba79cb9

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

src/aurelia.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,34 @@ import {EventAggregator, includeEventsIn} from 'aurelia-event-aggregator';
66

77
var logger = LogManager.getLogger('aurelia');
88

9-
function loadPlugins(loader, plugins){
10-
var toLoad = [], i, ii, current;
9+
function loadPlugin(aurelia, loader, info){
10+
logger.debug(`Loading plugin ${info.moduleId}.`);
1111

12-
for(i = 0, ii = plugins.length; i < ii; ++i){
13-
current = plugins[i];
14-
logger.debug(`Loading plugin ${current.moduleId}.`);
15-
toLoad.push(loader.loadModule(current.moduleId).then(exportedValue => {
16-
if('install' in exportedValue){
17-
return exportedValue.install(current.config || {}).then(() =>{
18-
logger.debug(`Installed plugin ${current.moduleId}.`);
12+
return loader.loadModule(info.moduleId, '').then(exportedValue => {
13+
if('install' in exportedValue){
14+
var result = exportedValue.install(aurelia, info.config || {});
15+
16+
if(result){
17+
return result.then(() =>{
18+
logger.debug(`Installed plugin ${info.moduleId}.`);
1919
});
2020
}else{
21-
logger.debug(`Loaded plugin ${current.moduleId}.`);
21+
logger.debug(`Installed plugin ${info.moduleId}.`);
2222
}
23-
}));
23+
}else{
24+
logger.debug(`Loaded plugin ${info.moduleId}.`);
25+
}
26+
});
27+
}
28+
29+
function loadPlugins(aurelia){
30+
var toLoad = [],
31+
loader = aurelia.loader,
32+
plugins = aurelia.plugins,
33+
i, ii, current, result;
34+
35+
for(i = 0, ii = plugins.length; i < ii; ++i){
36+
toLoad.push(loadPlugin(aurelia, loader, plugins[i]));
2437
}
2538

2639
return Promise.all(toLoad);
@@ -82,7 +95,7 @@ export class Aurelia {
8295
logger.error('You must configure Aurelia with a BindingLanguage implementation.');
8396
}
8497

85-
return loadPlugins(this.loader, this.plugins).then(() => {
98+
return loadPlugins(this).then(() => {
8699
return this.container.get(ResourceCoordinator)
87100
.importResources(this.resourcesToLoad).then(resources => {
88101
resources.forEach(x => x.register(this.resources));

0 commit comments

Comments
 (0)