These types are not exported by webpack, but they are available to TypeScript consumers.
These properties are added by the HotModuleReplacementPlugin
<boolean>Custom values available in the loader context.
[index: {string}]<any>
this{NormalModuleLoaderContext& LoaderRunnerLoaderContext & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditions} content<string>sourceMap<string>|<RawSourceMap>additionalData<AdditionalData>- Returns: {string | void | Buffer
| Promise<string | Buffer >}
<RawLoaderDefinitionFunction><OptionsType>
,
<ContextAdditions>
> |
<LoaderDefinitionFunction>
<
<OptionsType>
,
<ContextAdditions>
><OptionsType>
,
<ContextAdditions>
>These properties are added by the LoaderPlugin
importModule(request, options, callback): voidloadModule(request, callback): voidResolves the given request to a module, applies all configured loaders and calls back with the generated source, the sourceMap and the module instance (usually an instance of NormalModule). Use this function if you need to know the source code of another module to generate the result.
The properties are added by https://github.com/webpack/loader-runner
callback{(err?: Error | null, content?: string | Buffer, sourceMap?: string | RawSourceMap | null, additionalData?: AdditionalData) => void} context<string>The directory of the module. Can be used as context for resolving other stuff. eg '/workspaces/ts-loader/examples/vanilla/src'currentRequest<string>data<any>environment<Environment>Tell what kind of ES-features may be used in the generated runtime-code. Example: { arrowFunction: true }loaderIndex<number>The index in the loaders array of the current loader. In the example: in loader1: 0, in loader2: 1loaders{{ data?: object; fragment: string; ident: string; normal?: Function; normalExecuted: boolean; options?: string | object; path: string; pitch?: Function; pitchExecuted: boolean; query: string; raw?: boolean; request: string; type?: "module" | "commonjs" }[]} An array of all the loaders. It is writeable in the pitch phase. loaders = [{request: string, path: string, query: string, module: function}] In the example: [ { request: "/abc/loader1.js?xyz", path: "/abc/loader1.js", query: "?xyz", module: [Function] }, { request: "/abc/node_modules/loader2/index.js", path: "/abc/node_modules/loader2/index.js", query: "", module: [Function] } ]previousRequest<string>query<string>|<OptionsType>remainingRequest<string>request<string>resource<string>The resource inclusive query and fragment. Example: "/abc/resource.js?query#frag"resourceFragment<string>The resource fragment. Example: "#frag"resourcePath<string>The resource path. In the example: "/abc/resource.js"resourceQuery<string>The resource query string. Example: "?query"target<string>Target of compilation. Example: "web"
addContextDependency(context): voidAdd a directory as dependency of the loader result.
addDependency(file): voidAdds a file as dependency of the loader result in order to make them watchable. For example, html-loader uses this technique as it finds src and src-set attributes. Then, it sets the url's for those attributes as dependencies of the html file that is parsed.
addMissingDependency(context): voidasync(): (err?: Error | null, content?: string | Buffer<ArrayBufferLike>, sourceMap?: string | RawSourceMap | null, additionalData?: AdditionalData) => voidMake this loader async.
cacheable(flag?): voidMake this loader result cacheable. By default it's cacheable. A cacheable loader must have a deterministic result, when inputs and dependencies haven't changed. This means the loader shouldn't have other dependencies than specified with this.addDependency. Most loaders are deterministic and cacheable.
clearDependencies(): void<void>Remove all dependencies of the loader result. Even initial dependencies and these of other loaders.
dependency(file): voidalias of addDependency Adds a file as dependency of the loader result in order to make them watchable. For example, html-loader uses this technique as it finds src and src-set attributes. Then, it sets the url's for those attributes as dependencies of the html file that is parsed.
getContextDependencies(): string<string>getDependencies(): string<string>getMissingDependencies(): string<string>These properties are added by the NormalModule
<Compilation><Compiler><NormalModule><string><number><HashFunction><string><"development">
|
<"none">
|
<"production"><string><boolean><number><boolean>addBuildDependency(dep): voidemitError(error): voidEmits an error for this module. The error will be displayed to the user and typically causes the compilation to fail.
emitFile(name, content, sourceMap?, assetInfo?): voidEmits a new file (asset) to the compilation output directory. This allows loaders to generate additional files alongside the main module output.
emitWarning(warning): voidEmits a warning for this module. The warning will be displayed to the user during compilation.
getLogger(name?): WebpackLogger<string><WebpackLogger>Gets a logger instance scoped to this loader and module. Useful for emitting debug or compilation information in a structured way.
getOptions(): voidExtracts and parses the options of the current loader. Parses string options as JSON or a query string.
schema{Schema}- Returns: {OptionsType}
Extracts and parses the options of the current loader. Parses string options as JSON or a query string, and optionally validates them against a provided schema.
getResolve(options?): { (context: string, request: string, callback: (err: ErrorWithDetail | null, res?: string | false, req?: ResolveRequest) => void): void; (context: string, request: string): Promise<string>Creates a resolve function with specific options. The returned function can be used as a Promise-based resolver or a callback-based resolver.
resolve(context, request, callback): voidResolves a module request (e.g., a relative path or module name) to an absolute file path. It uses Webpack's internal resolver, taking into account configured aliases and extensions.
this{NormalModuleLoaderContext& LoaderRunnerLoaderContext & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditions} remainingRequest<string>previousRequest<string>data<object>- Returns: {string | void | Buffer
| Promise<string | Buffer >}
this{NormalModuleLoaderContext& LoaderRunnerLoaderContext & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditions} content{Buffer}sourceMap<string>|<RawSourceMap>additionalData<AdditionalData>- Returns: {string | void | Buffer
| Promise<string | Buffer >}
<{LoaderDefinitionFunction>
<
<OptionsType>
,
<ContextAdditions>
& { pitch?: PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>; raw?: false }}
<OptionsType>
,
<ContextAdditions>
><{RawLoaderDefinitionFunction>
<
<OptionsType>
,
<ContextAdditions>
& { pitch?: PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>; raw: true }}
<OptionsType>
,
<ContextAdditions>
>