These types are not exported by webpack, but they are available to TypeScript consumers.
These properties are added by the HotModuleReplacementPlugin
booleanCustom values available in the loader context.
[index: {string}]any
NormalModuleLoaderContext<OptionsType> & LoaderRunnerLoaderContext<OptionsType> & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditionsstringstring | RawSourceMapAdditionalDataRawLoaderDefinitionFunction<OptionsType, ContextAdditions> | LoaderDefinitionFunction<OptionsType, ContextAdditions>PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>falseThese properties are added by the LoaderPlugin
importModule(request, options, callback): void
importModule(request, options?): Promise<any>
loadModule(request, callback): void
Resolves 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
(err?: Error | null, content?: string | Buffer<ArrayBufferLike>, sourceMap?: string | RawSourceMap | null, additionalData?: AdditionalData) => voidstringstringanyEnvironmentarrowFunction: truenumber{ 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" }[]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]
]stringstring | OptionsTypestringstringstringstringstringstringstringaddContextDependency(context): void
Add a directory as dependency of the loader result.
addDependency(file): void
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.
addMissingDependency(context): void
async(): (err?: Error | null, content?: string | Buffer<ArrayBufferLike>, sourceMap?: string | RawSourceMap | null, additionalData?: AdditionalData) => void
(err?: Error | null, content?: string | Buffer<ArrayBufferLike>, sourceMap?: string | RawSourceMap | null, additionalData?: AdditionalData) => voidMake this loader async.
cacheable(flag?): void
Make 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
voidRemove all dependencies of the loader result. Even initial dependencies and these of other loaders.
dependency(file): void
alias 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
CompilationCompilerNormalModulestringnumberHashFunctionstring"development" | "none" | "production"stringbooleannumberbooleanaddBuildDependency(dep): void
emitError(error): void
Emits 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?): void
Emits a new file (asset) to the compilation output directory. This allows loaders to generate additional files alongside the main module output.
emitWarning(warning): void
Emits a warning for this module. The warning will be displayed to the user during compilation.
getLogger(name?): WebpackLogger
stringWebpackLoggerGets a logger instance scoped to this loader and module. Useful for emitting debug or compilation information in a structured way.
getOptions(): OptionsType
OptionsTypeExtracts and parses the options of the current loader. Parses string options as JSON or a query string.
getOptions(schema): OptionsType
SchemaOptionsTypeExtracts 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> }
ResolveOptionsWithDependencyTypeCreates 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): void
stringstring(err: ErrorWithDetail | null, res?: string | false, req?: ResolveRequest) => voidvoidResolves 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.
NormalModuleLoaderContext<OptionsType> & LoaderRunnerLoaderContext<OptionsType> & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditionsstringstringobjectNormalModuleLoaderContext<OptionsType> & LoaderRunnerLoaderContext<OptionsType> & LoaderPluginLoaderContext & HotModuleReplacementPluginLoaderContext & ContextAdditionsBufferstring | RawSourceMapAdditionalDataLoaderDefinitionFunction<OptionsType, ContextAdditions> & { pitch?: PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>; raw?: false }PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>falseRawLoaderDefinitionFunction<OptionsType, ContextAdditions> & { pitch?: PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>; raw: true }PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>true