The Compilation object has many methods and hooks available. On this page, we will list the available methods and properties.
function
Returns Stats object for the current compilation.
function (module, callback)
Adds a module to the current compilation.
Parameters:
module
- module to be addedcallback
- a callback after the module has been addedfunction (module)
Fetches a module from a compilation by its identifier.
Parameters:
module
- module to be fetched. The identifier is extracted from the module by the compilation using module.identifier()
method.function (module)
Attempts to search for a module by its identifier.
Parameters:
module
- module to be searched for. The identifier is extracted from the module by the compilation using module.identifier()
method.function (module, optional, origin, dependencies)
Builds the given module.
Parameters:
module
- the module to be built.optional
- optional flag.origin
- origin module from which this module build was requested.dependencies
- optional dependencies of the module to be built.function (module, callback)
Process the given module dependencies.
Parameters:
module
- module to be processed for the dependencies.callback
- function to be invoked when dependencies of the module had been processed.function (context, entry, name, callback)
Adds an entry to the compilation.
Parameters:
context
- context path for entry.entry
- entry dependency.name
- the name of entry.callback
- function to be invoked when addEntry finishes.function (module, thisCallback)
Triggers a re-build of the module.
Parameters:
module
- module to be rebuilt.thisCallback
- function to be invoked when the module finishes rebuilding.function (callback)
Finishes compilation and invokes the given callback.
Parameters:
callback
- function to be invoked when the compilation has been finished.function (callback)
Seals the compilation.
Parameters:
callback
- function to be invoked when the compilation has been sealed.function
Unseals the compilation.
Parameters:
callback
- function to be invoked when the compilation has been unsealed.function (module, blocks)
Adds errors and warnings of the given module to the compilation errors and warnings.
Parameters:
module
- the module whose errors and warnings are to be reported.blocks
- a set of dependency blocks to report from.function (groupOptions, module, loc, request)
Adds module to an existing chunk group or creates a new one. Returns a chunkGroup
.
Parameters:
groupOptions
- options for the chunk group.module
- a module that references the chunk group.loc
- the location from which the chunk group is referenced (inside of the module).request
- the request from which the chunk group is referenced.function (name)
Creates and adds a new chunk to the compilation.chunks
. Returns that chunk
.
Parameters:
name
- the name of the chunk.function (module)
Assigns depth
to the given module and its dependency blocks recursively.
Parameters:
module
- the module to assign depth to.function (module, dependency)
Returns the reference to the dependency from a given module.
Parameters:
module
- the module at question.dependency
- the dependency to get reference to.function (inputChunkGroups)
Creates the Chunk
graph from the Module
graph. The process is done in two phases. Phase one: traverse the module graph and build a basic chunks graph in chunkDependencies
. Phase two: traverse every possible way through the basic chunk graph and track the available modules. While traversing, processDependenciesBlocksForChunkGroups
connects chunks with each other and Blocks
with Chunks
. It stops traversing when all modules for a chunk are already available and it doesn't connect unneeded chunks.
Parameters:
inputChunkGroups
- chunk groups that are processed.function (module, block)
Removes relation of the module to the dependency block.
Parameters:
module
- a module relationship to be removed.block
- dependency block.function (module, chunk)
Patches ties of module and chunk after removing dependency reasons. Called automatically by removeReasonsOfDependencyBlock
.
Parameters:
module
- a module to patch tie.chunk
- a chunk to patch tie.function (block, chunk)
Removes given chunk from a dependencies block module and chunks after removing dependency reasons. Called automatically by removeReasonsOfDependencyBlock
.
Parameters:
block
- block tie for Chunk
.chunk
- a chunk to remove from dependencies.function
function
function
function
function
function (filename, data)
Returns the interpolated path.
Parameters:
filename
- used to get asset path with hash.data
- data object.function (filename, data)
Returns interpolated path and asset information.
Parameters:
filename
- used to get asset path with hash.data
- data object.function (name, outputOptions, plugins)
Allows running another instance of webpack inside of webpack. However, as a child with different settings and configurations applied. It copies all hooks and plugins from the parent (or top-level compiler) and creates a child Compiler
instance. Returns the created Compiler
.
Parameters:
name
- name for the child Compiler
.outputOptions
- output options object.plugins
- webpack plugins that will be applied.function
function (file, source, assetInfo = {})
Parameters:
file
- file name of the assetsource
- the source of the assetassetInfo
- additional asset informationfunction (file, newSourceOrFunction, assetInfoUpdateOrFunction)
Parameters:
file
- file name of the assetnewSourceOrFunction
- new asset source or function converting old to newassetInfoUpdateOrFunction
- new asset info or function converting old to newfunction (file)
Parameters:
file
- file name of the assetfunction
Returns array of all assets under the current compilation.
function (name)
Parameters:
name
- the name of the asset to return