1 | import {errorMessage, isFunction, loadResources} from './utils';
|
2 |
|
3 | import type {Loader, LoaderCallback} from '.';
|
4 |
|
5 | const 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 |
|
22 | export default loader;
|