Skip to content

Commit

Permalink
add require(jspm).import for server loading
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 17, 2014
1 parent 395cf1d commit 6dd4277
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions api.js
Expand Up @@ -32,11 +32,8 @@ API.setPackagePath = function(packagePath) {
API.setPackagePath('.');

API.normalize = function(name, parentName) {
return config.load()
.then(function() {
System.config(config.loader.getConfig());
})
.then(function() {
return API.configureLoader()
.then(function(System) {
return System.normalize(name, parentName);
});
};
Expand Down Expand Up @@ -73,6 +70,36 @@ API.install = function(name, target, options) {
}


API.import = function(moduleName, parentName) {
return API.configureLoader()
.then(function() {
return System.import(moduleName, { name: parentName });
});
}

// takes an optional config argument to configure
// returns the loader instance
var loaderConfigured = false;
API.configureLoader = function(cfg) {
return Promise.resolve()
.then(function() {
if (loaderConfigured)
return Promise.resolve(System);

return config.load()
.then(function() {
System.config(config.loader.getConfig());
loaderConfigured = true;
});
})
.then(function() {
if (cfg)
System.config(cfg);
return System;
});
}


/*
* Returns a promise for the full install tree of some form?
*/
Expand Down

0 comments on commit 6dd4277

Please sign in to comment.