UNPKG

548 BPlain TextView Raw
1import {errorMessage, isFunction, loadResources} from './utils';
2
3import type {Loader, LoaderCallback} from '.';
4
5const loader: Loader = function (source) {
6 this.cacheable();
7
8 const callback = this.async();
9
10 if (!isFunction<LoaderCallback>(callback)) {
11 throw new Error(errorMessage.syncCompilation);
12 }
13
14 /* istanbul ignore if: not possible to test */
15 if (typeof source !== 'string') {
16 throw new Error(errorMessage.impossible);
17 }
18
19 void loadResources(this, source, callback);
20};
21
22export default loader;