"use strict";
/// <reference types="@dojo/loader"/>
/**
 * A loader script for setting up the Dojo loader.
 *
 * Note that loader scripts must be simple scripts, not modules.
 */
intern.registerLoader(function (options) {
    var globalObj = typeof window !== 'undefined' ? window : global;
    return intern.loadScript('node_modules/@dojo/loader/loader.js').then(function () {
        var require = globalObj.require;
        intern.log('Using Dojo 2 loader');
        options.baseUrl = options.baseUrl || intern.config.basePath;
        intern.log('Configuring loader with:', options);
        require.config(options);
        return function (modules) {
            var handle;
            return new Promise(function (resolve, reject) {
                handle = require.on('error', function (error) {
                    intern.emit('error', error);
                    reject(error);
                });
                intern.log('Loading modules:', modules);
                require(modules, function () { resolve(); });
            }).then(function () { handle.remove(); }, function (error) {
                handle && handle.remove();
                throw error;
            });
        };
    });
});
//# sourceMappingURL=dojo2.js.map