|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | System.register(['aurelia-logging', 'aurelia-dependency-injection', 'aurelia-loader', 'aurelia-templating', 'aurelia-pal', 'aurelia-path', 'aurelia-binding', 'aurelia-metadata', 'aurelia-task-queue'], function (_export, _context) { |
4 | | - var TheLogManager, Container, Loader, BindingLanguage, ViewSlot, ViewResources, TemplatingEngine, CompositionTransaction, ViewEngine, DOM, PLATFORM, join, Aurelia, logger, FrameworkConfiguration, LogManager; |
| 4 | + var TheLogManager, Container, Loader, BindingLanguage, ViewSlot, ViewResources, TemplatingEngine, CompositionTransaction, ViewEngine, DOM, PLATFORM, join, Aurelia, logger, extPattern, FrameworkConfiguration, LogManager; |
5 | 5 |
|
6 | 6 | function _classCallCheck(instance, Constructor) { |
7 | 7 | if (!(instance instanceof Constructor)) { |
@@ -80,13 +80,43 @@ System.register(['aurelia-logging', 'aurelia-dependency-injection', 'aurelia-loa |
80 | 80 | }); |
81 | 81 |
|
82 | 82 | function _normalize(load) { |
83 | | - return aurelia.loader.normalize(load.moduleId, load.relativeTo).then(function (normalized) { |
| 83 | + var moduleId = load.moduleId; |
| 84 | + var ext = getExt(moduleId); |
| 85 | + |
| 86 | + if (isOtherResource(moduleId)) { |
| 87 | + moduleId = removeExt(moduleId); |
| 88 | + } |
| 89 | + |
| 90 | + return aurelia.loader.normalize(moduleId, load.relativeTo).then(function (normalized) { |
84 | 91 | return { |
85 | 92 | name: load.moduleId, |
86 | | - importId: normalized |
| 93 | + importId: isOtherResource(load.moduleId) ? addOriginalExt(normalized, ext) : normalized |
87 | 94 | }; |
88 | 95 | }); |
89 | 96 | } |
| 97 | + |
| 98 | + function isOtherResource(name) { |
| 99 | + var ext = getExt(name); |
| 100 | + if (!ext) return false; |
| 101 | + if (ext === '') return false; |
| 102 | + if (ext === '.js' || ext === '.ts') return false; |
| 103 | + return true; |
| 104 | + } |
| 105 | + |
| 106 | + function removeExt(name) { |
| 107 | + return name.replace(extPattern, ''); |
| 108 | + } |
| 109 | + |
| 110 | + function addOriginalExt(normalized, ext) { |
| 111 | + return removeExt(normalized) + '.' + ext; |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + function getExt(name) { |
| 116 | + var match = name.match(extPattern); |
| 117 | + if (match && match.length > 0) { |
| 118 | + return match[0].split('.')[1]; |
| 119 | + } |
90 | 120 | } |
91 | 121 |
|
92 | 122 | function assertProcessed(plugins) { |
@@ -303,6 +333,7 @@ System.register(['aurelia-logging', 'aurelia-dependency-injection', 'aurelia-loa |
303 | 333 | _export('Aurelia', Aurelia); |
304 | 334 |
|
305 | 335 | logger = TheLogManager.getLogger('aurelia'); |
| 336 | + extPattern = /\.[^/.]+$/; |
306 | 337 |
|
307 | 338 | _export('FrameworkConfiguration', FrameworkConfiguration = function () { |
308 | 339 | function FrameworkConfiguration(aurelia) { |
@@ -355,15 +386,11 @@ System.register(['aurelia-logging', 'aurelia-dependency-injection', 'aurelia-loa |
355 | 386 | }; |
356 | 387 |
|
357 | 388 | FrameworkConfiguration.prototype.feature = function feature(plugin, config) { |
358 | | - if (hasExt(plugin)) { |
| 389 | + if (getExt(plugin)) { |
359 | 390 | return this.plugin({ moduleId: plugin, resourcesRelativeTo: [plugin, ''], config: config || {} }); |
360 | 391 | } |
361 | 392 |
|
362 | 393 | return this.plugin({ moduleId: plugin + '/index', resourcesRelativeTo: [plugin, ''], config: config || {} }); |
363 | | - |
364 | | - function hasExt(name) { |
365 | | - return plugin.split('.').length > 1; |
366 | | - } |
367 | 394 | }; |
368 | 395 |
|
369 | 396 | FrameworkConfiguration.prototype.globalResources = function globalResources(resources) { |
|
0 commit comments