1 | import {errorMessage, isFunction, loadResources} from './utils';
|
2 |
|
3 | import type {Loader, LoaderCallback} from '.';
|
4 |
|
5 |
|
6 | const loader: Loader = function (source) {
|
7 | this.cacheable();
|
8 |
|
9 | const callback = this.async();
|
10 |
|
11 | if (!isFunction<LoaderCallback>(callback)) {
|
12 | throw new Error(errorMessage.syncCompilation);
|
13 | }
|
14 |
|
15 |
|
16 | if (typeof source !== 'string') {
|
17 | throw new Error(errorMessage.impossible);
|
18 | }
|
19 |
|
20 |
|
21 | loadResources(this, source, callback);
|
22 | };
|
23 |
|
24 |
|
25 | export default loader;
|