UNPKG

rolldown

Version:

Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.

68 lines (67 loc) 2.98 kB
import type { BindingPluginContext, ParserOptions } from '../binding'; import type { CustomPluginOptions, ModuleOptions, Plugin, ResolvedId } from './index'; import { MinimalPluginContext, MinimalPluginContextImpl } from '../plugin/minimal-plugin-context'; import { AssetSource } from '../utils/asset-source'; import { ModuleInfo } from '../types/module-info'; import { PluginContextData } from './plugin-context-data'; import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context'; import { PartialNull } from '../types/utils'; import type { LogHandler, LogLevelOption } from '../types/misc'; import { OutputOptions } from '../options/output-options'; import { Program } from '@oxc-project/types'; export interface EmittedAsset { type: 'asset'; name?: string; fileName?: string; originalFileName?: string | null; source: AssetSource; } export interface EmittedChunk { type: 'chunk'; name?: string; fileName?: string; id: string; importer?: string; } export type EmittedFile = EmittedAsset | EmittedChunk; export interface PluginContextResolveOptions { skipSelf?: boolean; custom?: CustomPluginOptions; } export interface PrivatePluginContextResolveOptions extends PluginContextResolveOptions { [SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]?: symbol; } export type GetModuleInfo = (moduleId: string) => ModuleInfo | null; export interface PluginContext extends MinimalPluginContext { emitFile(file: EmittedFile): string; getFileName(referenceId: string): string; getModuleIds(): IterableIterator<string>; getModuleInfo: GetModuleInfo; addWatchFile(id: string): void; load(options: { id: string; resolveDependencies?: boolean; } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>; parse(input: string, options?: ParserOptions | undefined | null): Program; resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>; } export declare class PluginContextImpl extends MinimalPluginContextImpl { private outputOptions; private context; private data; private onLog; private currentLoadingModule?; getModuleInfo: GetModuleInfo; constructor(outputOptions: OutputOptions, context: BindingPluginContext, plugin: Plugin, data: PluginContextData, onLog: LogHandler, logLevel: LogLevelOption, currentLoadingModule?: string | undefined); load(options: { id: string; resolveDependencies?: boolean; } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>; resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>; emitFile: PluginContext['emitFile']; private getAssetFileNames; getFileName(referenceId: string): string; getModuleIds(): IterableIterator<string>; addWatchFile(id: string): void; parse(input: string, options?: ParserOptions | undefined | null): Program; }