Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ework into ahmedshuhel-relative-module
  • Loading branch information
EisenbergEffect committed Mar 26, 2016
2 parents bb5b5b5 + b57f290 commit f6611c6
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/framework-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,41 @@ function loadResources(aurelia, resourcesToLoad, appResources) {
});

function _normalize(load) {
return aurelia.loader.normalize(load.moduleId, load.relativeTo)
let moduleId = load.moduleId;
let ext = getExt(moduleId);

if(isOtherResource(moduleId)) {
moduleId = removeExt(moduleId);
}

return aurelia.loader.normalize(moduleId, load.relativeTo)
.then(normalized => {
return {
name: load.moduleId,
importId: normalized
importId: isOtherResource(load.moduleId) ? addOriginalExt(normalized, ext) : normalized
};
});
}

function isOtherResource(name) {
let ext = getExt(name);
if(!ext) return false;
if(ext === '') return false;
if(ext === '.js' || ext === '.ts') return false;
return true;
}

function removeExt(name) {
return name.replace(/\.[^/.]+$/, "");
}

function getExt(name) {
return name.split('.')[1];
}

function addOriginalExt(normalized, ext) {
return removeExt(normalized) + '.' + ext;
}
}

function assertProcessed(plugins) {
Expand Down Expand Up @@ -179,7 +206,7 @@ export class FrameworkConfiguration {
return this.plugin({ moduleId: plugin + '/index', resourcesRelativeTo: [plugin, ''], config: config || {} });

function hasExt(name) {
return (plugin.split('.')).length > 1;
return (name.split('.')).length > 1;
}
}

Expand Down

0 comments on commit f6611c6

Please sign in to comment.