error stack loader option, plugin loader normalization fix, alias and loader to use usual resolution

This commit is contained in:
guybedford 2016-03-01 17:20:32 +02:00
parent 479ecd2d2f
commit c27a467bbe
4 changed files with 24 additions and 14 deletions

View File

@ -79,7 +79,7 @@ hookConstructor(function(constructor) {
normalized = normalized.substr(0, normalized.length - 3);
var module = loader.get(normalized);
if (!module)
throw new Error('Module not already loaded loading "' + names + '" from "' + referer + '".');
throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
return module.__useDefault ? module['default'] : module;
}

View File

@ -64,6 +64,7 @@ hookConstructor(function(constructor) {
this.warnings = false;
this.defaultJSExtensions = false;
this.pluginFirst = false;
this.loaderErrorStack = false;
// by default load ".json" files as json
// leading * meta doesn't need normalization
@ -291,9 +292,18 @@ hook('instantiate', function(instantiate) {
*/
SystemJSLoader.prototype.env = 'development';
var curCurScript;
SystemJSLoader.prototype.config = function(cfg) {
var loader = this;
if ('loaderErrorStack' in cfg) {
curCurScript = $__curScript;
if (cfg.loaderErrorStack)
$__curScript = undefined;
else
$__curScript = curCurScript;
}
if ('warnings' in cfg)
loader.warnings = cfg.warnings;
@ -432,7 +442,7 @@ SystemJSLoader.prototype.config = function(cfg) {
for (var c in cfg) {
var v = cfg[c];
if (c == 'baseURL' || c == 'map' || c == 'packages' || c == 'bundles' || c == 'paths' || c == 'warnings' || c == 'packageConfigPaths')
if (c == 'baseURL' || c == 'map' || c == 'packages' || c == 'bundles' || c == 'paths' || c == 'warnings' || c == 'packageConfigPaths' || c == 'loaderErrorStack')
continue;
if (typeof v != 'object' || v instanceof Array) {

View File

@ -58,13 +58,6 @@
* - map targets support conditional interpolation ('./x': './x.#{|env}.js')
* - internal package map targets cannot use boolean conditionals
*
* In addition, the following modules properties will be allowed to be package
* -relative as well in the package module config:
*
* - loader
* - alias
*
*
* Package Configuration Loading
*
* Not all packages may already have their configuration present in the System config
@ -616,11 +609,6 @@
extendMeta(meta, matchMeta, matchDepth && bestDepth > matchDepth);
});
// allow alias and loader to be package-relative
if (meta.alias && meta.alias.substr(0, 2) == './')
meta.alias = pkgName + meta.alias.substr(1);
if (meta.loader && meta.loader.substr(0, 2) == './')
meta.loader = pkgName + meta.loader.substr(1);
extendMeta(load.metadata, meta);
}
}

View File

@ -132,6 +132,18 @@
}
return locate.call(loader, load)
.then(function(address) {
if (pluginSyntaxIndex != -1 || !load.metadata.loader)
return address;
// normalize plugin relative to parent in locate here when
// using plugin via loader metadata
return loader.normalize(load.metadata.loader, load.name)
.then(function(loaderNormalized) {
load.metadata.loader = loaderNormalized;
return address;
});
})
.then(function(address) {
var plugin = load.metadata.loader;