forked from daren.hsu/line_push
update
This commit is contained in:
+6
-4
@@ -1,17 +1,19 @@
|
||||
import {StyleResources, StyleResourcesLoaderNormalizedOptions} from '..';
|
||||
import type {LoaderContext} from '../types';
|
||||
import type {StyleResources, StyleResourcesLoaderNormalizedOptions} from '..';
|
||||
|
||||
import {isPromise, errorMessage} from '.';
|
||||
import {errorMessage} from './error-message';
|
||||
|
||||
export const injectResources = async (
|
||||
ctx: LoaderContext,
|
||||
options: StyleResourcesLoaderNormalizedOptions,
|
||||
source: string,
|
||||
resources: StyleResources,
|
||||
) => {
|
||||
const {injector} = options;
|
||||
|
||||
const dist: any = injector(source, resources);
|
||||
const dist: unknown = injector.call(ctx, source, resources);
|
||||
|
||||
const content = isPromise(dist) ? await dist : dist;
|
||||
const content = await dist;
|
||||
|
||||
if (typeof content !== 'string') {
|
||||
throw new Error(errorMessage.invalidInjectorReturn);
|
||||
|
||||
Reference in New Issue
Block a user