KC's Workspace
    Preparing search index...
    interface TransformPluginContext {
        debug: (
            log: string | RolldownLog | (() => string | RolldownLog),
            pos?: number | { column: number; line: number },
        ) => void;
        environment: Environment;
        fs: RolldownFsModule;
        getModuleInfo: (moduleId: string) => ModuleInfo | null;
        info: (
            log: string | RolldownLog | (() => string | RolldownLog),
            pos?: number | { column: number; line: number },
        ) => void;
        meta: PluginContextMeta;
        warn: (
            log: string | RolldownLog | (() => string | RolldownLog),
            pos?: number | { column: number; line: number },
        ) => void;
        addWatchFile(id: string): void;
        emitFile(file: EmittedAsset | EmittedChunk | EmittedPrebuiltChunk): string;
        error(
            e: string | RolldownError,
            pos?: number | { column: number; line: number },
        ): never;
        getCombinedSourcemap(): SourceMap;
        getFileName(referenceId: string): string;
        getModuleIds(): IterableIterator<string>;
        load(
            options: { id: string; resolveDependencies?: boolean } & Partial<
                PartialNull<ModuleOptions>,
            >,
        ): Promise<ModuleInfo>;
        parse(input: string, options?: ParserOptions | null): Program;
        resolve(
            source: string,
            importer?: string,
            options?: PluginContextResolveOptions,
        ): Promise<ResolvedId | null>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    environment: Environment

    Vite-specific environment instance

    Provides abstract access to the file system.

    meta: PluginContextMeta

    An object containing potentially useful metadata.

    Methods

    getModuleInfo: (moduleId: string) => ModuleInfo | null

    Get additional information about the module in question.

    Type Declaration

      • (moduleId: string): ModuleInfo | null
      • Parameters

        • moduleId: string

        Returns ModuleInfo | null

        Module information for that module. null if the module could not be found.

    • Adds additional files to be monitored in watch mode so that changes to these files will trigger rebuilds.

      Parameters

      • id: string

      Returns void

    • Emits a new file that is included in the build output. You can emit chunks, prebuilt chunks or assets.

      Returns string

      A referenceId for the emitted file that can be used in various places to reference the emitted file.

    • Get the combined source maps of all previous plugins.

      Returns SourceMap

    • Get the file name of a chunk or asset that has been emitted via this.emitFile.

      Parameters

      • referenceId: string

      Returns string

      The file name of the emitted file. Relative to output.dir.

    • Get all module ids in the current module graph.

      Returns IterableIterator<string>

      An iterator of module ids. It can be iterated via

      for (const moduleId of this.getModuleIds()) {
      // ...
      }

      or converted into an array via Array.from(this.getModuleIds()).

    • Loads and parses the module corresponding to the given id, attaching additional meta information to the module if provided. This will trigger the same load, transform and moduleParsed hooks as if the module was imported by another module.

      Parameters

      Returns Promise<ModuleInfo>

    • Use Rolldown's internal parser to parse code to an ESTree-compatible AST.

      Parameters

      Returns Program

    • Resolve imports to module ids (i.e. file names) using the same plugins that Rolldown uses, and determine if an import should be external.

      When calling this function from a resolveId hook, you should always check if it makes sense for you to pass along the options.

      Parameters

      Returns Promise<ResolvedId | null>

      If Promise<null> is returned, the import could not be resolved by Rolldown or any plugin but was not explicitly marked as external by the user. If an absolute external id is returned that should remain absolute in the output either via the makeAbsoluteExternalsRelative option or by explicit plugin choice in the resolveId hook, external will be "absolute" instead of true.

    Logging Methods

    debug: (
        log: string | RolldownLog | (() => string | RolldownLog),
        pos?: number | { column: number; line: number },
    ) => void

    Same as PluginContext.debug, but a position param can be supplied.

    info: (
        log: string | RolldownLog | (() => string | RolldownLog),
        pos?: number | { column: number; line: number },
    ) => void

    Same as PluginContext.info, but a position param can be supplied.

    warn: (
        log: string | RolldownLog | (() => string | RolldownLog),
        pos?: number | { column: number; line: number },
    ) => void

    Same as PluginContext.warn, but a position param can be supplied.

    • Same as PluginContext.error, but the id of the current module will also be added and a position param can be supplied.

      Parameters

      • e: string | RolldownError
      • Optionalpos: number | { column: number; line: number }

      Returns never