On this page

class webpack.NormalModule extends Module
new NormalModule(normalModuleCreateDataNormalModuleObject_1): NormalModule
Attributes
normalModuleCreateDataNormalModuleObject_1:NormalModuleCreateDataNormalModuleObject_1<string>
Returns:NormalModule
Attributes
binary:boolean
buildInfo:BuildInfo
buildMeta:BuildMeta
chunksIterable:Iterable<Chunk>
codeGenerationDependencies:Dependency[]
context:string | null
debugId:number
dependencies:Dependency[]
depth:number | null
Returns the depth. Updates the depth using the provided value.
error:Error | null
errors:any
exportsArgument:string
Gets exports argument.
extractSourceMap:boolean
factoryMeta:FactoryMeta
generator:Generator
generatorOptions:GeneratorOptions
hasEqualsChunks:any
hash:string
Returns the hash of the module.
id:string | number | null
Returns the module id assigned by the chunk graph. Updates the module id using the provided value.
index:number | null
Returns the pre-order index. Updates the pre-order index using the provided value.
index2:number | null
Returns the post-order index. Updates the post-order index using the provided value.
issuer:Module | null
Returns the issuer. Updates the issuer using the provided value.
isUsed:any
layer:string | null
loaders:LoaderItem[]
matchResource:string
moduleArgument:string
Gets module argument.
needId:boolean
optimizationBailout:(string | ((requestShortener: RequestShortener) => string))[]
Gets optimization bailout.
optional:boolean
parser:Parser
parserOptions:ParserOptions
presentationalDependencies:Dependency[]
rawRequest:string
renderedHash:string
Returns the rendered hash of the module.
request:string
resolveOptions:ResolveOptions
resource:string
resourceResolveData:ResourceSchemeData & Partial<ResolveRequest>
type:string
used:any
usedExports:boolean | SortableSet<string> | null
userRequest:string
useSimpleSourceMap:boolean
useSourceMap:boolean
warnings:any
addBlock(block): void
Attributes

Adds a DependencyBlock to DependencyBlock relationship. This is used for when a Module has a AsyncDependencyBlock tie (for code-splitting)


addCacheDependencies(fileDependencies, contextDependencies, missingDependencies, buildDependencies): void
Attributes
fileDependencies:LazySet<string>
set where file dependencies are added to
contextDependencies:LazySet<string>
set where context dependencies are added to
missingDependencies:LazySet<string>
set where missing dependencies are added to
buildDependencies:LazySet<string>
set where build dependencies are added to
Returns:void

Adds the provided file dependencies to the module.


addChunk(chunk): boolean
Stability: 0Deprecated
Attributes
chunk:Chunk
Returns:boolean

Adds the provided chunk to the module.


addCodeGenerationDependency(codeGenerationDependency): void
Attributes
codeGenerationDependency:Dependency
Returns:void

Adds code generation dependency.


addDependency(dependency): void
Attributes
dependency:Dependency
Returns:void

Adds the provided dependency to the dependencies block.


addError(error): void
Attributes
error:Error
Returns:void

Adds the provided error to the module.


addPresentationalDependency(presentationalDependency): void
Attributes
presentationalDependency:Dependency
Returns:void

Adds presentational dependency.


addWarning(warning): void
Attributes
warning:Error
Returns:void

Adds the provided warning to the module.


applyNoParseRule(rule, content): boolean
Attributes
rule:string | RegExp | ((content: string) => boolean)
rule
content:string
content
Returns:boolean
result

build(options, compilation, resolver, fs, callback): void
Attributes
compilation:Compilation
the compilation
the resolver
the file system
callback:(err?: WebpackError) => void
callback function
Returns:void

Builds the module using the provided compilation context.


chunkCondition(chunk, compilation): boolean
Attributes
chunk:Chunk
compilation:Compilation
Returns:boolean

Returns true if the module can be placed in the chunk.


cleanupForCache(): void
Returns:void

Assuming this module is in the cache. Remove internal references to allow freeing some memory.


clearDependenciesAndBlocks(): void
Returns:void

Clear dependencies and blocks.


clearWarningsAndErrors(): void
Returns:void

removes all warnings and errors


codeGeneration(context): CodeGenerationResult
Attributes
context for code generation
result

Generates code and runtime requirements for this module.


createSource(context, content, sourceMap?, associatedObjectForCache?): Source
Attributes
context:string
the compilation context
content:string | Buffer<ArrayBufferLike>
the content
sourceMap:string | RawSourceMap | null
an optional source map
associatedObjectForCache:object
object for caching
Returns:Source
the created source

createSourceForAsset(context, name, content, sourceMap?, associatedObjectForCache?): Source
Attributes
context:string
the compilation context
name:string
the asset name
content:string | Buffer<ArrayBufferLike>
the content
sourceMap:string | RawSourceMap
an optional source map
associatedObjectForCache:object
object for caching
Returns:Source
the created source

deserialize(objectDeserializerContext): void
Attributes
objectDeserializerContext:ObjectDeserializerContext
Returns:void

Restores this instance from the provided deserializer context.


getChunks(): Chunk[]
Stability: 0Deprecated
Returns:Chunk[]

getConcatenationBailoutReason(context): string | undefined
Attributes
Returns:string | undefined
reason why this module can't be concatenated, undefined when it can be concatenated

Returns the reason this module cannot be concatenated, when one exists.


getCurrentLoader(loaderContext, index?): LoaderItem | null
Attributes
loaderContext:AnyLoaderContext
loader context
index:number
index
Returns:LoaderItem | null
loader

getErrors(): Error[] | undefined
Returns:Error[] | undefined

Returns list of errors if any.


getExportsType(moduleGraph, strict?): ExportsType
Attributes
moduleGraph:ModuleGraph
strict:boolean
Returns:ExportsType

Returns export type.


getNumberOfChunks(): number
Stability: 0Deprecated
Returns:number

getNumberOfErrors(): number
Returns:number

Gets number of errors.


getNumberOfWarnings(): number
Returns:number

Gets number of warnings.


getResource(): string | null
Returns:string | null
return the resource path

getRootBlock(): DependenciesBlock

getSideEffectsConnectionState(moduleGraph): ConnectionState
Attributes
moduleGraph:ModuleGraph
the module graph
how this module should be connected to referencing modules when consumed for side-effects only

Gets side effects connection state.


getSourceBasicTypes(): ReadonlySet<string>
Returns:ReadonlySet<string>

Basic source types are high-level categories like javascript, css, webassembly, etc. We only have built-in knowledge about the javascript basic type here; other basic types may be added or changed over time by generators and do not need to be handled or detected here. Some modules, e.g. RemoteModule, may return non-basic source types like "remote" and "share-init" from getSourceTypes(), but their generated output is still JavaScript, i.e. their basic type is JS.


getSourceTypes(): ReadonlySet<string>
Returns:ReadonlySet<string>
types available (do not mutate)

Returns the source types this module can generate.


getUnsafeCacheData(): UnsafeCacheData
cached data

Module should be unsafe cached. Get data that's needed for that. This data will be passed to restoreFromUnsafeCache later.


getWarnings(): Error[] | undefined
Returns:Error[] | undefined

Returns list of warnings if any.


hasChunkCondition(): boolean
Returns:boolean

hasReasonForChunk(chunk, moduleGraph, chunkGraph): boolean
Attributes
chunk:Chunk
moduleGraph:ModuleGraph
chunkGraph:ChunkGraph
Returns:boolean

Checks whether this module contains the chunk.


hasReasons(moduleGraph, runtime): boolean
Attributes
moduleGraph:ModuleGraph
runtime:RuntimeSpec
Returns:boolean

Checks whether this module contains the module graph.


identifier(): string
Returns:string
a unique identifier of the module

Returns the unique identifier used to reference this module.


invalidateBuild(): void
Returns:void

Invalidates the cached state associated with this value.


isAccessibleInChunk(chunkGraph, chunk, ignoreChunk?): boolean
Attributes
chunkGraph:ChunkGraph
chunk:Chunk
ignoreChunk:Chunk
Returns:boolean

Checks whether this module is accessible in chunk.


isAccessibleInChunkGroup(chunkGraph, chunkGroup, ignoreChunk?): boolean
Attributes
chunkGraph:ChunkGraph
chunkGroup:ChunkGroup
ignoreChunk:Chunk
Returns:boolean

Checks whether this module is accessible in chunk group.


isEntryModule(): boolean
Stability: 0Deprecated
Returns:boolean

isInChunk(chunk): boolean
Stability: 0Deprecated
Attributes
chunk:Chunk
Returns:boolean

Checks whether this module is in the provided chunk.


isOptional(moduleGraph): boolean
Attributes
moduleGraph:ModuleGraph
Returns:boolean

Checks whether this module is optional.


isProvided(exportName): boolean | null
Stability: 0Deprecated
Attributes
exportName:string
Returns:boolean | null

Checks whether this module provides the specified export.


libIdent(options): string | null
Attributes
options
Returns:string | null
an identifier for library inclusion

Gets the library identifier.


markModuleAsErrored(error): void
Attributes
error:Error
the error
Returns:void

nameForCondition(): string | null
Returns:string | null
absolute path which should be used for condition matching (usually the resource path)

Returns the path used when matching this module against rule conditions.


needBuild(context, callback): void
Attributes
context info
callback:(err?: WebpackError | null, needBuild?: boolean) => void
callback function, returns true, if the module needs a rebuild
Returns:void

Checks whether the module needs to be rebuilt for the current build state.


needRebuild(fileTimestamps, contextTimestamps): boolean
Stability: 0Deprecated: Use needBuild instead
Attributes
fileTimestamps:Map<string, number | null>
contextTimestamps:Map<string, number | null>
Returns:boolean

Checks whether it needs rebuild.


originalSource(): Source | null
Returns:Source | null
the original source for the module before webpack transformation

Gets the original source.


readableIdentifier(requestShortener): string
Attributes
requestShortener:RequestShortener
the request shortener
Returns:string
a user readable identifier of the module

Returns a human-readable identifier for this module.


removeChunk(chunk): void
Stability: 0Deprecated
Attributes
chunk:Chunk
Returns:void

Removes the provided chunk from the module.


removeDependency(dependency): void
Attributes
dependency:Dependency
Returns:void

Removes dependency.


restoreFromUnsafeCache(unsafeCacheData, normalModuleFactory): void
Attributes
unsafeCacheData:UnsafeCacheData
data from getUnsafeCacheData
normalModuleFactory:NormalModuleFactory
the normal module factory handling the unsafe caching
Returns:void

restore unsafe cache data


serialize(objectSerializerContext): void
Attributes
objectSerializerContext:ObjectSerializerContext
Returns:void

Serializes this instance into the provided serializer context.


shouldPreventParsing(noParseRule, request): boolean
Attributes
noParseRule:string | RegExp | ((content: string) => boolean) | (string | RegExp | ((content: string) => boolean))[] | undefined
no parse rule
request:string
request
Returns:boolean
check if module should not be parsed, returns "true" if the module should !not! be parsed, returns "false" if the module !must! be parsed

size(type?): number
Attributes
type:string
the source type for which the size should be estimated
Returns:number
the estimated size of the module (must be non-zero)

Returns the estimated size for the requested source type.


source(dependencyTemplates, runtimeTemplate, type?): Source
Stability: 0Deprecated: Use codeGeneration() instead
Attributes
dependencyTemplates:DependencyTemplates
runtimeTemplate:RuntimeTemplate
type:string
Returns:Source

Returns generated source.


updateCacheModule(module): void
Attributes
module:Module
fresh module
Returns:void

Assuming this module is in the cache. Update the (cached) module with the fresh module from the factory. Usually updates internal references and properties.


updateHash(hash, context): void
Attributes
hash:Hash
the hash used to track dependencies
Returns:void

Updates the hash with the data contributed by this instance.


Attributes

Restores this instance from the provided deserializer context.


Attributes
compilation:Compilation
the compilation
the attached hooks

Stability: 0Deprecated: In webpack 6, call getSourceBasicTypes() directly on the module instance instead of using this static method.
Attributes
module:Module
Returns:ReadonlySet<string>

Gets source basic types.