const defaultDestructor = mod => mod.default;
export default (loader, destructor = defaultDestructor) => {
    if (loader && typeof loader.then === 'function') {
        // import('modPath');
        return loader.then(mod => destructor(mod));
    } else if (typeof loader === 'function') {
        // require('bundle-loader?lazy!modPath');
        return new Promise(resolve => loader(mod => resolve(destructor(mod))))
    } else {
        return new Promise((resolve, reject) => reject('invalid loader'));
    }
}