intern.registerLoader(function (config) {
    var loaderConfig = config.loader.config || {};
    loaderConfig.baseURL = loaderConfig.baseURL || config.basePath;
    if (intern.environment === 'browser') {
        return intern.loadScript('node_modules/systemjs/dist/system.src.js').then(function () {
            return configAndLoad(SystemJS);
        });
    }
    else {
        var SystemJS_1 = require('systemjs');
        return configAndLoad(SystemJS_1);
    }
    function configAndLoad(loader) {
        intern.log('Loaded SystemJS loader');
        intern.log('Using loader', loader);
        intern.log('Configuring loader with:', loaderConfig);
        loader.config(loaderConfig);
        intern.log('Loading suites:', config.suites);
        return config.suites.reduce(function (previous, suite) {
            if (previous) {
                return previous.then(function () { return loader.import(suite); });
            }
            else {
                return loader.import(suite);
            }
        }, null);
    }
});
//# sourceMappingURL=systemjs.js.map