콘텐츠로 이동

PluginBuild

Defined in: core/index.ts:1589

onAstFunction(options, callback): void

Defined in: core/index.ts:1647

RegExp

(info) => HookResult<AstFunctionResult>

void


onBuildEnd(callback): void

Defined in: core/index.ts:1639

Called once at bundle end. Dispatched for both success and failure. On failure, the first fatal diagnostic item is wrapped in an Error and passed (#2156). In watch mode it is called for the initial build and on every rebuild.

Called before onCloseBundle.

(error?) => void | Promise<void>

void


onBuildStart(callback): void

Defined in: core/index.ts:1630

Called once at bundle start. Same as esbuild onStart, Rollup/Vite/rolldown buildStart (#2156). In watch mode it is called for the initial build and on every rebuild (same as the Rollup 5+ policy).

No arguments — same as esbuild onStart. BuildOptions is already passed during the plugin’s own setup.

() => void | Promise<void>

void


onCloseBundle(callback): void

Defined in: core/index.ts:1646

Called once after output files are written (#2156). Same as Rollup closeBundle — used for temp file cleanup, notifying external systems of build completion, etc. In watch mode it is called for the initial build and on every rebuild.

() => void | Promise<void>

void


onGenerateBundle(callback): void

Defined in: core/index.ts:1621

(outputs) => void | Promise<void>

void


onLoad(options, callback): void

Defined in: core/index.ts:1603

RegExp

(args) => HookResult<{ contents: string | Uint8Array<ArrayBufferLike>; loader?: string; map?: unknown; meta?: Record<string, unknown>; }>

void


onRenderChunk(options, callback): void

Defined in: core/index.ts:1617

RegExp

(args) => HookResult<{ code: string; }>

void


onResolve(options, callback): void

Defined in: core/index.ts:1590

RegExp

(args) => HookResult<{ disabled?: boolean; external?: boolean; path?: string; }>

void


onResolveContext(options, callback): void

Defined in: core/index.ts:1669

Fills in the match results of require.context(dir, recursive, filter, mode) from the host runtime. (#1579) Since ZNTC has no regex executor of its own (#1771), this is delegated to the host’s RegExp — Node V8 / Bun JSC.

options.filter applies to dir (e.g. /^\./app/ to process only a specific directory). Callback return:

  • { context: string[] } — array of matched file paths (empty array = empty context)
  • null/undefined — try the next plugin (if all are null, the graph emits a require_context_no_handler diagnostic)

The callback argument filter is the regex body of require.context (without slashes), and flags are the regex flags. The host compiles it with new RegExp(filter, flags) and then matches.

RegExp

(args) => HookResult<{ context: string[]; }>

void


onTransform(options, callback): void

Defined in: core/index.ts:1613

RegExp

(args) => HookResult<{ code: string; map?: unknown; }>

void