confinode
Version:
Node application configuration reader
48 lines (47 loc) • 1.89 kB
TypeScript
import Loader from './Loader';
import { LoaderDescription } from './loaders';
/**
* The loader manager is responsible of selecting the appropriate loader for each file.
*/
export default class LoaderManager {
/**
* Loader descriptions per description name.
*/
private readonly descriptions;
/**
* The loaders for each extension.
*/
private readonly extensionsLoaders;
/**
* The file types, ordered from most precise to least.
*/
readonly availableTypes: ReadonlyArray<string>;
/**
* Create the loader manager.
*
* @param applicationName - The application name, used to name custom loaders.
* @param customLoaders - The custom loaders which will be added/replace the provided ones.
*/
constructor(applicationName: string, customLoaders: {
[name: string]: LoaderDescription;
});
/**
* Get the loader for the given file name.
*
* @param paths - The extra paths where modules are searched.
* @param syncOnly - Do not use loaders if they cannot load synchronously.
* @param fileName - The (base) name of the file to search.
* @param extension - The extension of the file if already known.
* @returns A generator of the most appropriate loader and its name, or undefined if none found.
*/
getLoaders(paths: string[], syncOnly: boolean, fileName: string, extension?: string): Generator<[Loader, string], [Loader, string], void> | undefined;
/**
* Create an iterator over the loaders. Throws if no available iterator found.
*
* @param paths - The extra paths where modules are searched.
* @param syncOnly - Do not use loaders if they cannot load synchronously.
* @param matching - The loaders matching the given file name.
* @returns The most appropriate loader and its name.
*/
private createLoaders;
}