This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+6 -4
View File
@@ -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);