diff --git a/src/config.js b/src/config.js index 69022579..ea787348 100644 --- a/src/config.js +++ b/src/config.js @@ -149,12 +149,17 @@ export function setConfig (cfg, isEnvConfig) { var v = cfg.map[p]; if (typeof v === 'string') { - config.map[p] = coreResolve.call(loader, config, v, undefined, false, false); + var mapped = coreResolve.call(loader, config, v, undefined, false, false); + if (mapped[mapped.length -1] === '/' && p[p.length - 1] !== ':' && p[p.length - 1] !== '/') + mapped = mapped.substr(0, mapped.length - 1); + config.map[p] = mapped; } // object map else { - var pkgName = coreResolve.call(loader, config, p, undefined, true, true); + var pkgName = coreResolve.call(loader, config, p[p.length - 1] !== '/' ? p + '/' : p, undefined, true, true); + pkgName = pkgName.substr(0, pkgName.length - 1); + var pkg = config.packages[pkgName]; if (!pkg) { pkg = config.packages[pkgName] = createPackage(); @@ -191,7 +196,7 @@ export function setConfig (cfg, isEnvConfig) { if (p.match(/^([^\/]+:)?\/\/$/)) throw new TypeError('"' + p + '" is not a valid package name.'); - var pkgName = coreResolve.call(loader, config, p[p.length -1] !== '/' ? p + '/' : p, undefined, true, true); + var pkgName = coreResolve.call(loader, config, p[p.length - 1] !== '/' ? p + '/' : p, undefined, true, true); pkgName = pkgName.substr(0, pkgName.length - 1); setPkgConfig(config.packages[pkgName] = config.packages[pkgName] || createPackage(), cfg.packages[p], pkgName, false, config); diff --git a/test/test.js b/test/test.js index aebf7f80..af743e48 100644 --- a/test/test.js +++ b/test/test.js @@ -316,6 +316,23 @@ suite('SystemJS Standard Tests', function() { }); }); + test('Relative map and package config', function () { + System.config({ + map: { + helloworld: './' + }, + packages: { + helloworld: { + main: './helloworld.js' + } + } + }); + + return System.normalize('helloworld').then(function (normalized) { + ok(normalized.substr(normalized.length - 18, 18) === 'test/helloworld.js'); + }); + }); + test('Package with json loader', function () { System.config({ paths: { @@ -419,6 +436,17 @@ suite('SystemJS Standard Tests', function() { }); test('Loading an AMD bundle', function () { + System.config({ + map: { + helloworld: './' + }, + packages: { + helloworld: { + main: './helloworld.js', + defaultExtension: false + } + } + }); System.config({ bundles: { 'tests/amd-bundle.js': ['bundle-*'] @@ -591,6 +619,8 @@ suite('SystemJS Standard Tests', function() { test('CommonJS require.resolve', function () { return System.import('tests/cjs-resolve.js').then(function (m) { + console.log(':' + m); + console.log(m.substr(m.length - 12, 12)); ok(m.substr(m.length - 12, 12) == 'test/tests/a'); }); })