EnvironmentPluginContainer Class — vite Architecture
Architecture documentation for the EnvironmentPluginContainer class in pluginContainer.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 285b1044_dd20_6f59_7cf5_0ad094eeacee["EnvironmentPluginContainer"] 3b8df068_35d0_2c94_3ad1_e93c93d1d613["pluginContainer.ts"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|defined in| 3b8df068_35d0_2c94_3ad1_e93c93d1d613 e09c4724_afb2_8289_1ee6_375b57d306ac["constructor()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| e09c4724_afb2_8289_1ee6_375b57d306ac b833b0dd_eb2f_de4b_778c_254bf2bbc75d["_updateModuleLoadAddedImports()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| b833b0dd_eb2f_de4b_778c_254bf2bbc75d dd2702df_a5d5_5b3e_9167_da46e2046bc0["_getAddedImports()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| dd2702df_a5d5_5b3e_9167_da46e2046bc0 0c657f10_5f2a_d708_4034_b4fc6ee0c7fa["getModuleInfo()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| 0c657f10_5f2a_d708_4034_b4fc6ee0c7fa 740b85c6_7fbd_cec6_1dc6_e19314ddecba["handleHookPromise()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| 740b85c6_7fbd_cec6_1dc6_e19314ddecba c133d729_0fb3_09cc_2678_0fd71cdf65b3["options()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| c133d729_0fb3_09cc_2678_0fd71cdf65b3 bb020589_65d7_d25c_54ff_9633445ea428["resolveRollupOptions()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| bb020589_65d7_d25c_54ff_9633445ea428 5551e407_98e1_a15d_289d_2913c0ed600b["_getPluginContext()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| 5551e407_98e1_a15d_289d_2913c0ed600b be3526c9_4f67_b6dd_9a14_dd784ae26c08["hookParallel()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| be3526c9_4f67_b6dd_9a14_dd784ae26c08 4037a852_6412_11ad_da74_ea3d0ff0c661["buildStart()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| 4037a852_6412_11ad_da74_ea3d0ff0c661 c3f72447_6ade_7e1a_5913_f1b30ae4a31f["resolveId()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| c3f72447_6ade_7e1a_5913_f1b30ae4a31f bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779["load()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 dcf6f9d5_316b_0287_6984_8729d3e6c0aa["transform()"] 285b1044_dd20_6f59_7cf5_0ad094eeacee -->|method| dcf6f9d5_316b_0287_6984_8729d3e6c0aa
Relationship Graph
Source Code
packages/vite/src/node/server/pluginContainer.ts lines 175–658
class EnvironmentPluginContainer<Env extends Environment = Environment> {
private _pluginContextMap = new Map<Plugin, PluginContext>()
private _resolvedRollupOptions?: InputOptions
private _processesing = new Set<Promise<any>>()
private _seenResolves: Record<string, true | undefined> = {}
// _addedFiles from the `load()` hook gets saved here so it can be reused in the `transform()` hook
private _moduleNodeToLoadAddedImports = new WeakMap<
EnvironmentModuleNode,
Set<string> | null
>()
getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks']
getSortedPlugins: PluginHookUtils['getSortedPlugins']
moduleGraph: EnvironmentModuleGraph | undefined
watchFiles: Set<string> = new Set()
minimalContext: MinimalPluginContext<Env>
private _started = false
private _buildStartPromise: Promise<void> | undefined
private _closed = false
/**
* @internal use `createEnvironmentPluginContainer` instead
*/
constructor(
public environment: Env,
public plugins: readonly Plugin[],
public watcher?: FSWatcher | undefined,
autoStart = true,
) {
this._started = !autoStart
this.minimalContext = new MinimalPluginContext(
{ ...basePluginContextMeta, watchMode: true },
environment,
)
const utils = createPluginHookUtils(plugins)
this.getSortedPlugins = utils.getSortedPlugins
this.getSortedPluginHooks = utils.getSortedPluginHooks
this.moduleGraph =
environment.mode === 'dev' ? environment.moduleGraph : undefined
}
private _updateModuleLoadAddedImports(
id: string,
addedImports: Set<string> | null,
): void {
const module = this.moduleGraph?.getModuleById(id)
if (module) {
this._moduleNodeToLoadAddedImports.set(module, addedImports)
}
}
private _getAddedImports(id: string): Set<string> | null {
const module = this.moduleGraph?.getModuleById(id)
return module
? this._moduleNodeToLoadAddedImports.get(module) || null
: null
}
getModuleInfo(id: string): ModuleInfo | null {
const module = this.moduleGraph?.getModuleById(id)
if (!module) {
return null
}
if (!module.info) {
module.info = new Proxy(
{ id, meta: module.meta || EMPTY_OBJECT } as ModuleInfo,
// throw when an unsupported ModuleInfo property is accessed,
// so that incompatible plugins fail in a non-cryptic way.
{
get(info: any, key: string) {
if (key in info) {
return info[key]
}
// Don't throw an error when returning from an async function
if (key === 'then') {
return undefined
}
throw Error(
Domain
Source
Frequently Asked Questions
What is the EnvironmentPluginContainer class?
EnvironmentPluginContainer is a class in the vite codebase, defined in packages/vite/src/node/server/pluginContainer.ts.
Where is EnvironmentPluginContainer defined?
EnvironmentPluginContainer is defined in packages/vite/src/node/server/pluginContainer.ts at line 175.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free