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

Class PluginContext

packages/vite/src/node/server/pluginContainer.ts:744–1031  ·  packages/vite/src/node/server/pluginContainer.ts::PluginContext

Source from the content-addressed store, hash-verified

742}
743
744class PluginContext
745 extends MinimalPluginContext
746 implements Omit<RollupPluginContext, class="st">'cache'>
747{
748 ssr = false
749 _scan = false
750 _activeId: string | null = null
751 _activeCode: string | null = null
752 _resolveSkips?: Set<Plugin>
753 _resolveSkipCalls?: readonly SkipInformation[]
754
755 override get pluginName(): string {
756 return this._plugin.name
757 }
758
759 constructor(
760 public _plugin: Plugin,
761 public _container: EnvironmentPluginContainer,
762 ) {
763 super(_container.minimalContext.meta, _container.environment)
764 }
765
766 fs: RollupFsModule = fsModule
767
768 parse(code: string, opts: any): ESTree.Program {
769 return rolldownParseAst(code, opts)
770 }
771
772 async resolve(
773 id: string,
774 importer?: string,
775 options?: {
776 attributes?: Record<string, string>
777 custom?: CustomPluginOptions
778 isEntry?: boolean
779 skipSelf?: boolean
780 },
781 ): Promise<ResolvedId | null> {
782 let skipCalls: readonly SkipInformation[] | undefined
783 if (options?.skipSelf === false) {
784 skipCalls = this._resolveSkipCalls
785 } else if (this._resolveSkipCalls) {
786 const skipCallsTemp = [...this._resolveSkipCalls]
787 const sameCallIndex = this._resolveSkipCalls.findIndex(
788 (c) =>
789 c.id === id && c.importer === importer && c.plugin === this._plugin,
790 )
791 if (sameCallIndex !== -1) {
792 skipCallsTemp[sameCallIndex] = {
793 ...skipCallsTemp[sameCallIndex],
794 called: true,
795 }
796 } else {
797 skipCallsTemp.push({ id, importer, plugin: this._plugin })
798 }
799 skipCalls = skipCallsTemp
800 } else {
801 skipCalls = [{ id, importer, plugin: this._plugin }]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected