跳到正文

Interface: TransformPluginContext

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2067

Extends

Properties

environment

ts
environment: Environment

Defined in: node_modules/.pnpm/vite@8.0.0-beta.10_@types+node@25.0.10_jiti@2.6.1_yaml@2.8.2/node_modules/vite/dist/node/index.d.ts:2696

Vite-specific environment instance

Inherited from

PluginContext.environment


fs

ts
fs: RolldownFsModule

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:1983

Provides abstract access to the file system.

Inherited from

PluginContext.fs


meta

ts
meta: PluginContextMeta

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:1843

An object containing potentially useful metadata.

Inherited from

PluginContext.meta

Methods

getModuleInfo()

ts
getModuleInfo: (moduleId) => ModuleInfo | null

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2021

Get additional information about the module in question.

./docs/plugin-context-getmoduleinfo.md

Parameters

moduleId

string

Returns

ModuleInfo | null

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

Inherited from

PluginContext.getModuleInfo


addWatchFile()

ts
addWatchFile(id): void;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2027

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

./docs/plugin-context-addwatchfile.md

Parameters

id

string

Returns

void

Inherited from

PluginContext.addWatchFile


emitFile()

ts
emitFile(file): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:1992

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

./docs/plugin-context-emitfile.md

Parameters

file

EmittedAsset | EmittedChunk | EmittedPrebuiltChunk

Returns

string

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

Inherited from

PluginContext.emitFile


getCombinedSourcemap()

ts
getCombinedSourcemap(): SourceMap;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2100

Get the combined source maps of all previous plugins.

Returns

SourceMap


getFileName()

ts
getFileName(referenceId): string;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:1999

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.

Inherited from

PluginContext.getFileName


getModuleIds()

ts
getModuleIds(): IterableIterator<string>;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2012

Get all module ids in the current module graph.

Returns

IterableIterator<string>

An iterator of module ids. It can be iterated via

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

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

Inherited from

PluginContext.getModuleIds


load()

ts
load(options): Promise<ModuleInfo>;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2037

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.

./docs/plugin-context-load.md

Parameters

options

object & Partial<PartialNull<ModuleOptions>>

Returns

Promise<ModuleInfo>

Inherited from

PluginContext.load


parse()

ts
parse(input, options?): Program;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2044

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

Parameters

input

string

options?

ParserOptions | null

Returns

Program

Inherited from

PluginContext.parse


resolve()

ts
resolve(
   source,
   importer?,
options?): Promise<ResolvedId | null>;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2062

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

source

string

importer?

string

options?

PluginContextResolveOptions

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.

Inherited from

PluginContext.resolve

Logging Methods

debug()

ts
debug: (log, pos?) => void;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2074

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

Parameters

log

string | RolldownLog | () => string | RolldownLog

pos?

number | { column: number; line: number; }

Returns

void

Overrides

PluginContext.debug


info()

ts
info: (log, pos?) => void;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2081

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

Parameters

log

string | RolldownLog | () => string | RolldownLog

pos?

number | { column: number; line: number; }

Returns

void

Overrides

PluginContext.info


warn()

ts
warn: (log, pos?) => void;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2088

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

Parameters

log

string | RolldownLog | () => string | RolldownLog

pos?

number | { column: number; line: number; }

Returns

void

Overrides

PluginContext.warn


error()

ts
error(e, pos?): never;

Defined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:2093

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

pos?

number | { column: number; line: number; }

Returns

never

Overrides

ts
PluginContext.error

Released under the MIT License.