Home / Function/ perEnvironmentState() — vite Function Reference

perEnvironmentState() — vite Function Reference

Architecture documentation for the perEnvironmentState() function in environment.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  16a00926_f0e9_60f1_3006_9132a6d78745["perEnvironmentState()"]
  0c33ff62_54e9_5c90_902b_b26728e71fca["environment.ts"]
  16a00926_f0e9_60f1_3006_9132a6d78745 -->|defined in| 0c33ff62_54e9_5c90_902b_b26728e71fca
  911f8f87_f452_e725_a168_2bab39345c79["clientInjectionsPlugin()"]
  911f8f87_f452_e725_a168_2bab39345c79 -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  c10ddb4f_144e_78b3_e0f7_d70979a75e3a["dynamicImportVarsPlugin()"]
  c10ddb4f_144e_78b3_e0f7_d70979a75e3a -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  39f26be8_b1d9_a756_3043_474687a6bbb7["buildHtmlPlugin()"]
  39f26be8_b1d9_a756_3043_474687a6bbb7 -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  b888666d_ce54_f0bf_184f_48d09f6a9ee8["manifestPlugin()"]
  b888666d_ce54_f0bf_184f_48d09f6a9ee8 -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0["buildReporterPlugin()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  d5b72255_236c_e62d_9524_5d6892ba1d7f["ssrManifestPlugin()"]
  d5b72255_236c_e62d_9524_5d6892ba1d7f -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  51afdf58_3045_64b1_cf5b_929b1091e877["get()"]
  16a00926_f0e9_60f1_3006_9132a6d78745 -->|calls| 51afdf58_3045_64b1_cf5b_929b1091e877
  style 16a00926_f0e9_60f1_3006_9132a6d78745 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/environment.ts lines 20–33

export function perEnvironmentState<State>(
  initial: (environment: Environment) => State,
): (context: PluginContext) => State {
  const stateMap = new WeakMap<Environment, State>()
  return function (context: PluginContext) {
    const { environment } = context
    let state = stateMap.get(environment)
    if (!state) {
      state = initial(environment)
      stateMap.set(environment, state)
    }
    return state
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does perEnvironmentState() do?
perEnvironmentState() is a function in the vite codebase, defined in packages/vite/src/node/environment.ts.
Where is perEnvironmentState() defined?
perEnvironmentState() is defined in packages/vite/src/node/environment.ts at line 20.
What does perEnvironmentState() call?
perEnvironmentState() calls 1 function(s): get.
What calls perEnvironmentState()?
perEnvironmentState() is called by 6 function(s): buildHtmlPlugin, buildReporterPlugin, clientInjectionsPlugin, dynamicImportVarsPlugin, manifestPlugin, ssrManifestPlugin.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free