mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
extension & wildcard adjustments
This commit is contained in:
parent
425f87fed9
commit
134cb2e47e
@ -23,7 +23,8 @@
|
||||
* paths: {
|
||||
* // map any internal or external require of 'jquery/vendor/another' to 'another/index.js'
|
||||
* 'vendor/another': 'another/index.js',
|
||||
* 'test': 'lib/test.js'
|
||||
* // test -> lib/test.js (defaultExtension)
|
||||
* 'test': 'lib/test',
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@ -39,8 +40,9 @@
|
||||
* - main is the only property where a leading "./" can be added optionally
|
||||
* - paths and defaultExtension are applied to the main
|
||||
* - defaultExtension adds the extension only if no other extension is present
|
||||
* - defaultExtension applies after paths only if not a path match
|
||||
* - defaultJSExtensions applies only when defaultExtension is not set
|
||||
* - defaultExtension applies after paths
|
||||
* - defaultJSExtensions applies after paths when defaultExtension is not set
|
||||
* - paths do not support wildcards
|
||||
* - if a meta value is available for a module, paths and defaultExtension are skipped
|
||||
* - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
|
||||
*
|
||||
@ -126,26 +128,25 @@
|
||||
normalized += '/' + (pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main);
|
||||
}
|
||||
|
||||
var defaultExtension;
|
||||
if (pkg.defaultExtension && normalized.split('/').pop().indexOf('.') == -1)
|
||||
defaultExtension = '.' + pkg.defaultExtension;
|
||||
|
||||
// apply paths checking without defaultExtension, then as defaultExtension exact match
|
||||
if (pkg.paths) {
|
||||
var subPath = normalized.substr(pkgName.length + 1);
|
||||
var mapped = applyPaths(pkg.paths, subPath) || defaultExtension && pkg.paths[subPath + defaultExtension];
|
||||
var mapped = pkg.paths[subPath];
|
||||
if (mapped)
|
||||
normalized = pkgName + '/' + mapped;
|
||||
}
|
||||
|
||||
// apply default extension if not in meta and not the package itself
|
||||
if (defaultExtension) {
|
||||
if (normalized.split('/').pop().indexOf('.') == -1)
|
||||
normalized += defaultExtension;
|
||||
}
|
||||
// apply defaultJSExtensions if defaultExtension not set
|
||||
else if (defaultJSExtension) {
|
||||
normalized += '.js';
|
||||
// if we have meta for this package, don't do defaultExtensions
|
||||
if (!pkg.meta || !pkg.meta[normalized.substr(pkgName.length + 1)]) {
|
||||
// apply defaultExtension
|
||||
if (pkg.defaultExtension) {
|
||||
if (normalized.split('/').pop().indexOf('.') == -1)
|
||||
normalized += '.' + pkg.defaultExtension;
|
||||
}
|
||||
// apply defaultJSExtensions if defaultExtension not set
|
||||
else if (defaultJSExtension) {
|
||||
normalized += '.js';
|
||||
}
|
||||
}
|
||||
}
|
||||
// add back defaultJSExtension if not a package
|
||||
|
||||
@ -844,7 +844,7 @@ asyncTest('Package configuration CommonJS config example', function() {
|
||||
'json': 'json.json',
|
||||
'dir/': 'dir/index.js',
|
||||
'dir2': 'dir2/index.json',
|
||||
'dir/*': '*.ts'
|
||||
//'dir/': './'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -855,13 +855,13 @@ asyncTest('Package configuration CommonJS config example', function() {
|
||||
System['import']('tests/testpkg/json'),
|
||||
System['import']('tests/testpkg/dir/'),
|
||||
System['import']('tests/testpkg/dir2'),
|
||||
System['import']('tests/testpkg/dir/test')
|
||||
//System['import']('tests/testpkg/dir/test')
|
||||
]).then(function(m) {
|
||||
ok(m[0].prop == 'value');
|
||||
ok(m[1].prop == 'value');
|
||||
ok(m[2] == 'dirindex');
|
||||
ok(m[3].json == 'index');
|
||||
ok(m[4] == 'ts');
|
||||
//ok(m[4] == 'ts');
|
||||
start();
|
||||
}, err);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user