MCPcopy
hub / github.com/vitejs/vite / BasicMinimalPluginContext

Class BasicMinimalPluginContext

packages/vite/src/node/server/pluginContainer.ts:670–715  ·  packages/vite/src/node/server/pluginContainer.ts::BasicMinimalPluginContext

Source from the content-addressed store, hash-verified

668}
669
670export class BasicMinimalPluginContext<Meta = PluginContextMeta> {
671 constructor(
672 public meta: Meta,
673 private _logger: Logger,
674 ) {}
675
676 class="cm">// FIXME: properly support this later
677 class="cm">// eslint-disable-next-line @typescript-eslint/class-literal-property-style
678 get pluginName(): string {
679 return class="st">''
680 }
681
682 debug(rawLog: string | RollupLog | (() => string | RollupLog)): void {
683 const log = this._normalizeRawLog(rawLog)
684 const msg = buildErrorMessage(log, [`debug: ${log.message}`], false)
685 debugPluginContainerContext?.(msg)
686 }
687
688 info(rawLog: string | RollupLog | (() => string | RollupLog)): void {
689 const log = this._normalizeRawLog(rawLog)
690 const msg = buildErrorMessage(log, [`info: ${log.message}`], false)
691 this._logger.info(msg, { clear: true, timestamp: true })
692 }
693
694 warn(rawLog: string | RollupLog | (() => string | RollupLog)): void {
695 const log = this._normalizeRawLog(rawLog)
696 const msg = buildErrorMessage(
697 log,
698 [colors.yellow(`warning: ${log.message}`)],
699 false,
700 )
701 this._logger.warn(msg, { clear: true, timestamp: true })
702 }
703
704 error(e: string | RollupError): never {
705 const err = (typeof e === class="st">'string' ? new Error(e) : e) as RollupError
706 throw err
707 }
708
709 private _normalizeRawLog(
710 rawLog: string | RollupLog | (() => string | RollupLog),
711 ): RollupLog {
712 const logValue = typeof rawLog === class="st">'function' ? rawLog() : rawLog
713 return typeof logValue === class="st">'string' ? new Error(logValue) : logValue
714 }
715}
716
717class MinimalPluginContext<T extends Environment = Environment>
718 extends BasicMinimalPluginContext

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected