mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
env -> production, trailing slash adjustments
This commit is contained in:
parent
894036ec6b
commit
29cd9fd761
18
lib/core.js
18
lib/core.js
@ -39,13 +39,11 @@ function getMapMatch(map, name) {
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
function setConditional(mode) {
|
||||
function setProduction(isProduction) {
|
||||
this.set('@system-env', this.newModule({
|
||||
browser: isBrowser,
|
||||
node: !!this._nodeRequire,
|
||||
env: mode,
|
||||
production: mode == 'production',
|
||||
development: mode == 'development'
|
||||
production: isProduction
|
||||
}));
|
||||
}
|
||||
|
||||
@ -82,7 +80,7 @@ hookConstructor(function(constructor) {
|
||||
// support the empty module, as a concept
|
||||
this.set('@empty', this.newModule({}));
|
||||
|
||||
setConditional.call(this, 'development');
|
||||
setProduction.call(this, false);
|
||||
};
|
||||
});
|
||||
|
||||
@ -327,11 +325,8 @@ SystemJSLoader.prototype.config = function(cfg) {
|
||||
if (cfg.pluginFirst)
|
||||
loader.pluginFirst = cfg.pluginFirst;
|
||||
|
||||
if (cfg.env) {
|
||||
if (cfg.env != 'production' && cfg.env != 'development')
|
||||
throw new TypeError('The config environment must be set to "production" or "development".');
|
||||
setConditional.call(loader, cfg.env);
|
||||
}
|
||||
if (cfg.production)
|
||||
setProduction.call(loader, true);
|
||||
|
||||
if (cfg.paths) {
|
||||
for (var p in cfg.paths)
|
||||
@ -402,6 +397,9 @@ SystemJSLoader.prototype.config = function(cfg) {
|
||||
throw new TypeError('"' + p + '" is not a valid package name.');
|
||||
|
||||
// trailing slash allows paths matches here
|
||||
// NB deprecate this to just remove trailing /
|
||||
// as decanonicalize doesn't respond to trailing /
|
||||
// and paths wildcards should deprecate
|
||||
var prop = loader.decanonicalize(p + (p[p.length - 1] != '/' ? '/' : ''));
|
||||
|
||||
// allow trailing '/' in package config
|
||||
|
||||
@ -386,11 +386,6 @@
|
||||
|
||||
var subPath = normalized.substr(pkgName.length + 1);
|
||||
|
||||
// allow for direct package name normalization with trailling "/" (no main)
|
||||
// that is normalize('pkg/') does not apply main, while normalize('./', 'pkg/') does
|
||||
if (!subPath && normalized.length == pkgName.length + 1 && name[0] != '.')
|
||||
return pkgName + subPath;
|
||||
|
||||
return applyPackageConfigSync(loader, loader.packages[pkgName] || {}, pkgName, subPath, isPlugin);
|
||||
};
|
||||
});
|
||||
@ -458,11 +453,6 @@
|
||||
.then(function(pkg) {
|
||||
var subPath = normalized.substr(pkgName.length + 1);
|
||||
|
||||
// allow for direct package name normalization with trailling "/" (no main)
|
||||
// that is normalize('pkg/') does not apply main, while normalize('./', 'pkg/') does
|
||||
if (!subPath && normalized.length == pkgName.length + 1 && name[0] != '.')
|
||||
return Promise.resolve(pkgName + subPath);
|
||||
|
||||
return applyPackageConfig(loader, pkg, pkgName, subPath, isPlugin);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user