On this page

These types are not exported by webpack, but they are available to TypeScript consumers.

These properties are added by the HotModuleReplacementPlugin

Attributes

Custom values available in the loader context.

  • [index: {string}] <any>

  • this {NormalModuleLoaderContext|LoaderRunnerLoaderContext|LoaderPluginLoaderContext|HotModuleReplacementPluginLoaderContext|ContextAdditions}
  • content <string>
  • sourceMap <string>
  • additionalData {AdditionalData}
  • Returns: {string|void|Buffer|Promise<string|Buffer>}

Attributes
loader:<string>
options:
{string|Record<string, any>|null}

  • default {RawLoaderDefinitionFunction<OptionsType, ContextAdditions>|LoaderDefinitionFunction<OptionsType, ContextAdditions>}
  • pitch {PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>}
  • raw {false}

  • [index: {string}] <any>
Attributes
debug:<boolean>
Whether loaders should be in debug mode or not. debug will be removed as of webpack 3.
minimize:<boolean>
Where loaders can be switched to minimize mode.
options:<object>
A configuration object that can be used to configure older loaders.

These properties are added by the LoaderPlugin

importModule(request, options, callback): void
Attributes
Returns:
{void}
Attributes
Returns:
{Promise }
loadModule(request, callback): void
Attributes
request:<string>
callback:<object>
Returns:
{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

Attributes
callback:<object>
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: 1
loaders:<object[]>
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>
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): void
Attributes
context:<string>
Returns:
{void}

Add a directory as dependency of the loader result.

addDependency(file): void
Attributes
Returns:
{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
Attributes
context:<string>
Returns:
{void}
async(): object
Returns:<object>

Make this loader async.

cacheable(flag?): void
Attributes
Returns:
{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
Returns:
{void}

Remove all dependencies of the loader result. Even initial dependencies and these of other loaders.

dependency(file): void
Attributes
Returns:
{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[]
Returns:<string[]>
getDependencies(): string[]
Returns:<string[]>
getMissingDependencies(): string[]
Returns:<string[]>

These properties are added by the NormalModule

Attributes
_compilation:<Compilation>
_compiler:<Compiler>
hashDigest:<string>
hashDigestLength:<number>
hashFunction:
{HashFunction}
hashSalt:<string>
mode:
{"development"|"none"|"production"}
rootContext:<string>
sourceMap:<boolean>
utils:<object>
version:<number>
webpack:<boolean>
addBuildDependency(dep): void
Attributes
Returns:
{void}
emitError(error): void
Attributes
error:<Error>
Returns:
{void}
emitFile(name, content, sourceMap?, assetInfo?): void
Attributes
content:
{string|Buffer }
sourceMap:<string>
assetInfo:<AssetInfo>
Returns:
{void}
emitWarning(warning): void
Attributes
warning:<Error>
Returns:
{void}
getLogger(name?): WebpackLogger
Attributes
Returns:
{WebpackLogger}
getOptions(): void
Returns:
{OptionsType}
  • schema {Schema}
  • Returns: {OptionsType}
getResolve(options?): object
Attributes
Returns:<object>
resolve(context, request, callback): void
Attributes
context:<string>
request:<string>
callback:<object>
Returns:
{void}

  • 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>
  • additionalData {AdditionalData}
  • Returns: {string|void|Buffer|Promise<string|Buffer>}

Type:
{NormalModuleLoaderContext |LoaderRunnerLoaderContext |LoaderPluginLoaderContext|HotModuleReplacementPluginLoaderContext}

Type:
{NormalModuleLoaderContext |LoaderRunnerLoaderContext |LoaderPluginLoaderContext|HotModuleReplacementPluginLoaderContext}

Type:
{LoaderDefinitionFunction<OptionsType, ContextAdditions>|object}
  • pitch {PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>}
  • raw {false}

Type:
{RawLoaderDefinitionFunction<OptionsType, ContextAdditions>|object}
  • pitch {PitchLoaderDefinitionFunction<OptionsType, ContextAdditions>}
  • raw {true}