The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.
The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.
The loader context represents the properties that are available inside of a loader assigned to the this
property.
Add the directory as a dependency for the loader results so that any changes to the files in the directory can be listened to.
Add a file as a dependency on the loader results so that any changes to them can be listened to. For example, sass-loader
, less-loader
use this trick to recompile when the imported style files change.
Alias of this.addDependency()
.
Add a non-existent file as a dependency on the loader results to make them listenable.
Tells Rspack that this loader will be called asynchronously. Returns this.callback
.
A function that sets the cacheable flag:
By default, the processing results of the loader are marked as cacheable. Calling this method and passing false
turns off the loader's ability to cache processing results.
A function that can be called synchronously or asynchronously in order to return multiple results. The expected arguments are:
Error
or null
, which marks the current module as a compilation failure.string
or Buffer
, which indicates the contents of the file after the module has been processed by the loader.Removes all dependencies of the loader result.
The directory where the current module is located.
A data object shared between the pitch and the normal phase.
Emit an error. Unlike throw
and this.callback(err)
in the loader, it does not mark the current module as a compilation failure, it just adds an error to Rspack's Compilation and displays it on the command line at the end of this compilation.
Emit a warning.
Emit a file.
Extracts the given loader option, accepting an optional JSON schema as an argument.
Create a resolver like this.resolve
.
Resolve a request.
context
must be the absolute path to a directory. This directory is used as the starting location for resolving.request
is the request to be resolved.callback
is a callback function that gives the resolved path.The value of mode
is read when Rspack is run.
The possible values are: 'production'
, 'development'
, 'none'
The value of target
is read when Rspack is run.
The path string of the current module. For example '/abc/resource.js?query#hash'
.
The path string of the current module, excluding the query and fragment parameters. For example '/abc/resource.js?query#hash'
in '/abc/resource.js'
.
The query parameter for the path string of the current module. For example '?query'
in '/abc/resource.js?query#hash'
.
The fragment parameter of the current module's path string. For example '#hash'
in '/abc/resource.js?query#hash'
.
The directory where the project is configured in config
Whether a source map should be generated.
Get the logger of this compilation, through which messages can be logged.