KC's Workspace
    Preparing search index...

    Make all properties in T optional

    interface OutputPlugin {
        augmentChunkHash?: ObjectHook<
            (this: PluginContext, chunk: RenderedChunk) => string | void,
            {},
        >;
        banner?: ObjectHook<AddonHook, {}>;
        footer?: ObjectHook<AddonHook, {}>;
        generateBundle?: ObjectHook<
            (
                this: PluginContext,
                ...parameters: [
                    outputOptions: NormalizedOutputOptions,
                    bundle: OutputBundle,
                    isWrite: boolean,
                ],
            ) => void
            | Promise<void>,
            {},
        >;
        intro?: ObjectHook<AddonHook, {}>;
        name: string;
        outputOptions?: ObjectHook<
            (
                this: MinimalPluginContext,
                options: OutputOptions,
            ) => OutputOptions | NullValue<void>,
            {},
        >;
        outro?: ObjectHook<AddonHook, {}>;
        renderChunk?: ObjectHook<
            (
                this: PluginContext,
                ...parameters: [
                    code: string,
                    chunk: RenderedChunk,
                    outputOptions: NormalizedOutputOptions,
                    meta: RenderedChunkMeta,
                ],
            ) => string | NullValue<void> | RolldownMagicString | { code: string | RolldownMagicString; map?: SourceMapInput; } | Promise<string | NullValue<void> | RolldownMagicString | { code: string | RolldownMagicString; map?: SourceMapInput; }>,
            { filter?: Pick<HookFilter, "code">
            | TopLevelFilterExpression[] },
        >;
        renderError?: ObjectHook<
            (
                this: PluginContext,
                ...parameters: [error: Error],
            ) => void | Promise<void>,
            { sequential?: boolean },
        >;
        renderStart?: ObjectHook<
            (
                this: PluginContext,
                ...parameters: [
                    outputOptions: NormalizedOutputOptions,
                    inputOptions: NormalizedInputOptions,
                ],
            ) => void
            | Promise<void>,
            { sequential?: boolean },
        >;
        version?: string;
        writeBundle?: ObjectHook<
            (
                this: PluginContext,
                ...parameters: [
                    outputOptions: NormalizedOutputOptions,
                    bundle: OutputBundle,
                ],
            ) => void
            | Promise<void>,
            { sequential?: boolean },
        >;
    }

    Hierarchy (View Summary)

    Index

    Properties

    name: string

    The name of the plugin, for use in error messages and logs.

    version?: string

    The version of the plugin, for use in inter-plugin communication scenarios.

    Build Hooks

    outputOptions?: ObjectHook<
        (
            this: MinimalPluginContext,
            options: OutputOptions,
        ) => OutputOptions | NullValue<void>,
        {},
    >

    Replaces or manipulates the output options object passed to RolldownBuild.generate | bundle.generate() or RolldownBuild.write | bundle.write().

    Returning null does not replace anything.

    If you just need to read the output options, it is recommended to use the renderStart hook as this hook has access to the output options after the transformations from all outputOptions hooks have been taken into account.

    Output Generation Hooks

    augmentChunkHash?: ObjectHook<
        (this: PluginContext, chunk: RenderedChunk) => string | void,
        {},
    >

    Can be used to augment the hash of individual chunks. Called for each Rolldown output chunk.

    Returning a falsy value will not modify the hash. Truthy values will be used as an additional source for hash calculation.

    banner?: ObjectHook<AddonHook, {}>

    A hook equivalent to output.banner option.

    footer?: ObjectHook<AddonHook, {}>

    A hook equivalent to output.footer option.

    generateBundle?: ObjectHook<
        (
            this: PluginContext,
            ...parameters: [
                outputOptions: NormalizedOutputOptions,
                bundle: OutputBundle,
                isWrite: boolean,
            ],
        ) => void
        | Promise<void>,
        {},
    >

    Called at the end of RolldownBuild.generate | bundle.generate() or immediately before the files are written in RolldownBuild.write | bundle.write().

    To modify the files after they have been written, use the writeBundle hook.

    intro?: ObjectHook<AddonHook, {}>

    A hook equivalent to output.intro option.

    outro?: ObjectHook<AddonHook, {}>

    A hook equivalent to output.outro option.

    renderChunk?: ObjectHook<
        (
            this: PluginContext,
            ...parameters: [
                code: string,
                chunk: RenderedChunk,
                outputOptions: NormalizedOutputOptions,
                meta: RenderedChunkMeta,
            ],
        ) => string | NullValue<void> | RolldownMagicString | { code: string | RolldownMagicString; map?: SourceMapInput; } | Promise<string | NullValue<void> | RolldownMagicString | { code: string | RolldownMagicString; map?: SourceMapInput; }>,
        { filter?: Pick<HookFilter, "code">
        | TopLevelFilterExpression[] },
    >

    Can be used to transform individual chunks. Called for each Rolldown output chunk file.

    Returning null will apply no transformations. If you change code in this hook and want to support source maps, you need to return a map describing your changes, see Source Code Transformations section.

    chunk is mutable and changes applied in this hook will propagate to other plugins and to the generated bundle. That means if you add or remove imports or exports in this hook, you should update RenderedChunk.imports | imports, RenderedChunk.importedBindings | importedBindings and/or RenderedChunk.exports | exports accordingly.

    renderError?: ObjectHook<
        (
            this: PluginContext,
            ...parameters: [error: Error],
        ) => void | Promise<void>,
        { sequential?: boolean },
    >

    Called when Rolldown encounters an error during RolldownBuild.generate | bundle.generate() or RolldownBuild.write | bundle.write().

    To get notified when generation completes successfully, use the generateBundle hook.

    renderStart?: ObjectHook<
        (
            this: PluginContext,
            ...parameters: [
                outputOptions: NormalizedOutputOptions,
                inputOptions: NormalizedInputOptions,
            ],
        ) => void
        | Promise<void>,
        { sequential?: boolean },
    >

    Called initially each time RolldownBuild.generate | bundle.generate() or RolldownBuild.write | bundle.write() is called.

    To get notified when generation has completed, use the generateBundle and renderError hooks.

    This is the recommended hook to use when you need access to the output options passed to RolldownBuild.generate | bundle.generate() or RolldownBuild.write | bundle.write() as it takes the transformations by all outputOptions hooks into account and also contains the right default values for unset options.

    It also receives the input options passed to rolldown | rolldown() so that plugins that can be used as output plugins, i.e. plugins that only use generate phase hooks, can get access to them.

    writeBundle?: ObjectHook<
        (
            this: PluginContext,
            ...parameters: [
                outputOptions: NormalizedOutputOptions,
                bundle: OutputBundle,
            ],
        ) => void
        | Promise<void>,
        { sequential?: boolean },
    >

    Called only at the end of RolldownBuild.write | bundle.write() once all files have been written.