Options
All
  • Public
  • Public/Protected
  • All
Menu

The properties are added by https://github.com/webpack/loader-runner

Type parameters

  • OptionsType

Hierarchy

  • LoaderRunnerLoaderContext

Index

Properties

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: { 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"

Methods

  • addContextDependency(context: string): void
  • Add a directory as dependency of the loader result.

    Parameters

    • context: string

    Returns void

  • addDependency(file: string): 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.

    Parameters

    • file: string

    Returns void

  • addMissingDependency(context: string): void
  • Parameters

    • context: string

    Returns void

  • async(): (err?: null | Error, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void
  • Make this loader async.

    Returns (err?: null | Error, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void

      • (err?: null | Error, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData): void
      • Make this loader async.

        Parameters

        • Optional err: null | Error
        • Optional content: string | Buffer
        • Optional sourceMap: string | SourceMap
        • Optional additionalData: AdditionalData

        Returns void

  • cacheable(flag?: boolean): 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.

    Parameters

    • Optional flag: boolean

    Returns void

  • callback(err?: null | Error, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData): void
  • Parameters

    • Optional err: null | Error
    • Optional content: string | Buffer
    • Optional sourceMap: string | SourceMap
    • Optional additionalData: AdditionalData

    Returns void

  • clearDependencies(): void
  • Remove all dependencies of the loader result. Even initial dependencies and these of other loaders.

    Returns void

  • dependency(file: string): 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.

    Parameters

    • file: string

    Returns void

  • getContextDependencies(): string[]
  • Returns string[]

  • getDependencies(): string[]
  • Returns string[]

  • getMissingDependencies(): string[]
  • Returns string[]