UNPKG

2.61 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as TsconfigPaths from "tsconfig-paths";
3import * as Options from "./options";
4import * as Logger from "./logger";
5import * as fs from "fs";
6import { ResolvePluginInstance, Resolver } from "webpack";
7import { AsyncSeriesBailHook } from "tapable";
8import { ResolveContext, ResolveRequest } from "enhanced-resolve";
9export interface LegacyResolverPlugin {
10 readonly apply: (resolver: LegacyResolver) => void;
11}
12export interface LegacyResolver {
13 readonly apply: (plugin: LegacyResolverPlugin) => void;
14 readonly plugin: (source: string, cb: ResolverCallbackLegacy) => void;
15 readonly doResolve: doResolveLegacy | doResolve;
16 readonly join: (relativePath: string, innerRequest: Request) => Request;
17 readonly fileSystem: LegacyResolverFileSystem;
18 readonly getHook: (hook: string) => AsyncSeriesBailHook<[
19 ResolveRequest,
20 ResolveContext
21 ], null | ResolveRequest>;
22}
23export type doResolveLegacy = (target: string, req: Request, desc: string, callback: Callback) => void;
24export type doResolve = (hook: AsyncSeriesBailHook<[
25 ResolveRequest,
26 ResolveContext
27], null | ResolveRequest>, req: Request, message: string, resolveContext: LegacyResolveContext, callback: Callback) => void;
28export type ReadJsonCallback = (error: Error | undefined | null, result?: {}) => void;
29export type ReadJson = (path2: string, callback: ReadJsonCallback) => void;
30export type LegacyResolverFileSystem = typeof fs & {
31 readJson?: ReadJson;
32};
33export interface LegacyResolveContext {
34 log?: string;
35 stack?: string;
36 missing?: string;
37}
38export type ResolverCallbackLegacy = (request: Request, callback: Callback) => void;
39export type ResolverCallback = (request: Request, resolveContext: LegacyResolveContext, callback: Callback) => void;
40export interface Request {
41 readonly request?: Request | string;
42 readonly relativePath: string;
43 readonly path: string;
44 readonly context: {
45 readonly issuer: string;
46 };
47}
48export interface Callback {
49 (err?: Error, result?: string): void;
50 log?: string;
51 stack?: string;
52 missing?: string;
53}
54export declare class TsconfigPathsPlugin implements Exclude<ResolvePluginInstance, Function> {
55 source: string;
56 target: string;
57 log: Logger.Logger;
58 baseUrl: string | undefined;
59 absoluteBaseUrl: string;
60 extensions: ReadonlyArray<string>;
61 referenceMatchMap: Record<string, TsconfigPaths.MatchPathAsync>;
62 matchPath: TsconfigPaths.MatchPathAsync;
63 constructor(rawOptions?: Partial<Options.Options>);
64 apply(resolver: Resolver): void;
65}