On this page

new RuntimeTemplate(): RuntimeTemplate
Attributes
compilation:Compilation
contentHashReplacement:string
globalObject:string
requestShortener:RequestShortener
assignOr(target, value): string
Attributes
target:string
value:string
Returns:string

Returns a self-defaulting assignment, using the ||= logical assignment operator when supported and falling back to target = target || value otherwise. target is evaluated twice in the fallback, so it must be side-effect free. The expression evaluates to the resulting value. Models || only, so target must never hold a legitimate falsy value (0, "", false) — it would be overwritten; use it for object/array defaults.


asyncModuleFactory({ block, chunkGraph, runtimeRequirements, request }): string
Attributes
the async block
chunkGraph:ChunkGraph
the chunk graph
request:string
request string used originally
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Async module factory.


basicFunction(args, body): string
Attributes
args:string
body:string | string[]
Returns:string

Returns basic function.


blockPromise({ block, message, chunkGraph, runtimeRequirements, originModule }): string
Attributes
the async block
chunkGraph:ChunkGraph
the chunk graph
message:string
the message
originModule:Module
the module the import() is emitted into
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Returns expression.


comment({ request, chunkName, chunkReason, message, exportName }): string
Attributes
chunkName:string | null
name of the chunk referenced
chunkReason:string
reason information of the chunk
exportName:string
name of the export
message:string
additional message
request:string
request string used originally
Returns:string

Returns comment.


concatenation(...args?): string
Attributes
args:(string | { expr: string })[]
Returns:string

Returns result expression.


cssServerStyleRegistry(): string
Returns:string

Expression for the global registry that collects CSS server-side when there is no DOM (SSR). An SSR host reads it from globalThis; it is keyed by the style/chunk identifier and namespaced by output.uniqueName.


defineEsModuleFlagStatement({ exportsArgument, runtimeRequirements }): string
Attributes
exportsArgument:string
the name of the exports object
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Define es module flag statement.


destructureArray(items, value): string
Attributes
items:string[]
value:string
Returns:string

Returns destructure array code.


destructureObject(items, value): string
Attributes
items:string[]
value:string
Returns:string

Destructure object.


emptyFunction(): string
Returns:string

Returns empty function code.


exportFromImport({ moduleGraph, chunkGraph, module, request, exportName, originModule, asiSafe, isCall, callContext, defaultInterop, importVar, initFragments, runtime, runtimeRequirements, dependency, mangleableNamespace }): string
Attributes
asiSafe:boolean
true, if location is safe for ASI, a bracket can be emitted
callContext:boolean | null
when false, call context will not be preserved
chunkGraph:ChunkGraph
the chunk graph
defaultInterop:boolean
when true and accessing the default exports, interop code will be generated
dependency:ModuleDependency
module dependency
exportName:string | string[]
the export name
importVar:string
the identifier name of the import variable
initFragments:InitFragment<GenerateContext>[]
init fragments will be added here
isCall:boolean
true, if expression will be called
mangleableNamespace:boolean
true, when a whole-namespace value may use a decoupled namespace object that keeps the original export names
module:Module
the module
moduleGraph:ModuleGraph
the module graph
originModule:Module
the origin module
request:string
the request
runtime:RuntimeSpec
runtime for which this code will be generated
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Export from import.


expressionFunction(expression, args?): string
Attributes
expression:string
args:string
Returns:string

Expression function.


forEach(variable, array, body): string
Attributes
variable:string
array:string
body:string | string[]
Returns:string

Returns for each code.


getBuiltinModule(request, access?): string
Attributes
request:string
access:string
Returns:string

Reads a node builtin via process.getBuiltinModule(), guarded to stay falsy off node so universal ["node", "web"] bundles don't crash (also falsy on node <22.3).


iife(args, body): string
Attributes
args:string
body:string
Returns:string

Returns iIFE code.


importStatement({ update, module, originModule, moduleGraph, chunkGraph, runtimeRequirements, importVar, request, weak, dependency }): [string, string]
Attributes
chunkGraph:ChunkGraph
the chunk graph
dependency:ModuleDependency
module dependency
importVar:string
name of the import variable
module:Module
the module
moduleGraph:ModuleGraph
the module graph
originModule:Module
module in which the statement is emitted
request:string
the request that should be printed as comment
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
update:boolean
whether a new variable should be created or the existing one updated
weak:boolean
true, if this is a weak dependency
Returns:[string, string]

Returns the import statement and the compat statement.


isIIFE(): boolean
Returns:boolean

isModule(): boolean
Returns:boolean

isNeutralPlatform(): boolean
Returns:boolean

isUniversalTarget(): boolean
Returns:boolean

Whether the bundle targets node and web at once (universal ["node", "web"] + output.module), like isUniversalTarget in WebpackOptionsApply.


isWebLikePlatformExpression(): string
Returns:string

Runtime expression that is truthy in browser-like environments (a DOM document or a worker self) and falsy in Node.js. Single source of truth for branching a universal ("node-or-web") target at runtime.


method(prop, args, body): string
Attributes
prop:string
args:string
body:string | string[]
Returns:string

Renders an object-literal method, using method shorthand when supported and falling back to a prop: function/arrow property otherwise.


missingModule({ request }): string
Attributes
request:string
request string used originally
Returns:string

Returns generated error IIFE.


missingModulePromise({ request }): string
Attributes
request:string
request string used originally
Returns:string

Missing module promise.


missingModuleStatement({ request }): string
Attributes
request:string
request string used originally
Returns:string

Missing module statement.


moduleExports({ module, chunkGraph, request, weak, runtimeRequirements }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
module:Module | null
the module
request:string
the request that should be printed as comment
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
weak:boolean
if the dependency is weak (will create a nice error message)
Returns:string

Returns the expression.


moduleId({ module, chunkGraph, request, weak }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
module:Module
the module
request:string
the request that should be printed as comment
weak:boolean
if the dependency is weak (will create a nice error message)
Returns:string

Returns the expression.


moduleNamespace({ module, chunkGraph, request, strict, weak, runtimeRequirements }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
module:Module
the module
request:string
the request that should be printed as comment
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
strict:boolean
if the current module is in strict esm mode
weak:boolean
if the dependency is weak (will create a nice error message)
Returns:string

Returns the expression.


moduleNamespacePromise({ chunkGraph, block, module, request, message, strict, weak, dependency, runtimeRequirements, originModule }): string
Attributes
the current dependencies block
chunkGraph:ChunkGraph
the chunk graph
dependency:Dependency
dependency
message:string
a message for the comment
module:Module
the module
originModule:Module
the module the import() is emitted into
request:string
the request that should be printed as comment
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
strict:boolean
if the current module is in strict esm mode
weak:boolean
if the dependency is weak (will create a nice error message)
Returns:string

Module namespace promise.


moduleRaw({ module, chunkGraph, request, weak, runtimeRequirements }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
module:Module | null
the module
request:string
the request that should be printed as comment
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
weak:boolean
if the dependency is weak (will create a nice error message)
Returns:string

Returns the expression.


objectHasOwn(object, property): string
Attributes
object:string
property:string
Returns:string

Returns an own-property check, using Object.hasOwn when supported and falling back to Object.prototype.hasOwnProperty.call otherwise.


optionalChaining(object, access): string
Attributes
object:string
access:string
Returns:string

Guards an access/call on object with optional chaining when supported, otherwise an equivalent && short-circuit. object is evaluated twice in the fallback, so it must be side-effect free.


renderConst(): "const" | "let" | "var"
Returns:"const" | "let" | "var"

Renders return const when it is supported, otherwise let when supported, otherwise var.


renderLet(): "let" | "var"
Returns:"let" | "var"

Renders return let when it is supported, otherwise var.


renderNodePrefixForCoreModule(mod): string
Attributes
mod:string
Returns:string

Renders node prefix for core module.


returningFunction(returnValue, args?): string
Attributes
returnValue:string
args:string
Returns:string

Returning function.


runtimeConditionExpression({ chunkGraph, runtime, runtimeCondition, runtimeRequirements }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
runtime:RuntimeSpec
runtime for which this code will be generated
runtimeCondition:string | boolean | SortableSet<string>
only execute the statement in some runtimes
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Runtime condition expression.


supportNodePrefixForCoreModules(): boolean
Returns:boolean

supportsAnalyzableEsm(): boolean
Returns:boolean

supportsArrowFunction(): boolean
Returns:boolean

supportsAsyncFunction(): boolean
Returns:boolean

supportsBigIntLiteral(): boolean
Returns:boolean

supportsConst(): boolean
Returns:boolean

supportsDestructuring(): boolean
Returns:boolean

supportsDynamicImport(): boolean
Returns:boolean

supportsEcmaScriptModuleSyntax(): boolean
Returns:boolean

supportsForOf(): boolean
Returns:boolean

supportsGenerator(): boolean
Returns:boolean

supportsLet(): boolean
Returns:boolean

supportsLogicalAssignment(): boolean
Returns:boolean

supportsMethodShorthand(): boolean
Returns:boolean

supportsModulePreload(): boolean
Returns:boolean

supportsObjectHasOwn(): boolean
Returns:boolean

supportsOptionalChaining(): boolean
Returns:boolean

supportsSpread(): boolean
Returns:boolean

supportsSymbol(): boolean
Returns:boolean

supportTemplateLiteral(): boolean
Returns:boolean

syncModuleFactory({ dependency, chunkGraph, runtimeRequirements, request }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
dependency:Dependency
the dependency
request:string
request string used originally
runtimeRequirements:Set<string>
if set, will be filled with runtime requirements
Returns:string

Sync module factory.


throwMissingModuleErrorBlock({ request }): string
Attributes
request:string
request string used originally
Returns:string

Throw missing module error block.


throwMissingModuleErrorFunction({ request }): string
Attributes
request:string
request string used originally
Returns:string

Throw missing module error function.


weakError({ chunkGraph, module, request, idExpr, type }): string
Attributes
chunkGraph:ChunkGraph
the chunk graph
idExpr:string
expression to use as id expression
module:Module
the module
request:string
the request that should be printed as comment
type:"promise" | "expression" | "statements"
which kind of code should be returned
Returns:string

Returns the code.