Home / Function/ load() — vite Function Reference

load() — vite Function Reference

Architecture documentation for the load() function in pluginContainer.ts from the vite codebase.

Function typescript ViteCore ConfigEngine calls 10 called by 5

Entity Profile

Dependency Diagram

graph TD
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779["load()"]
  285b1044_dd20_6f59_7cf5_0ad094eeacee["EnvironmentPluginContainer"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|defined in| 285b1044_dd20_6f59_7cf5_0ad094eeacee
  94464637_e13d_00af_69ed_f92d6e6cc584["load()"]
  94464637_e13d_00af_69ed_f92d6e6cc584 -->|calls| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779
  979a55e8_d076_d451_f023_e6c68b6790de["load()"]
  979a55e8_d076_d451_f023_e6c68b6790de -->|calls| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779
  6aa50cd4_4412_2a02_b76b_495614715811["compilePostCSS()"]
  6aa50cd4_4412_2a02_b76b_495614715811 -->|calls| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779
  788c7102_1f9e_48db_0312_d3566b067276["makeScssWorker()"]
  788c7102_1f9e_48db_0312_d3566b067276 -->|calls| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779
  bdac5327_5085_933f_41df_0fc270134a38["loadAndTransform()"]
  bdac5327_5085_933f_41df_0fc270134a38 -->|calls| bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779
  740b85c6_7fbd_cec6_1dc6_e19314ddecba["handleHookPromise()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 740b85c6_7fbd_cec6_1dc6_e19314ddecba
  b833b0dd_eb2f_de4b_778c_254bf2bbc75d["_updateModuleLoadAddedImports()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| b833b0dd_eb2f_de4b_778c_254bf2bbc75d
  c42acd29_f3d2_c03f_de55_553d650a5fbf["throwClosedServerError()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| c42acd29_f3d2_c03f_de55_553d650a5fbf
  52da5dad_0e46_dc8f_fae0_b17308d247cc["getCachedFilterForPlugin()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 52da5dad_0e46_dc8f_fae0_b17308d247cc
  3ac77420_8a39_d233_cf59_650944f4a9fa["isFutureDeprecationEnabled()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 3ac77420_8a39_d233_cf59_650944f4a9fa
  43459d27_10c2_86a0_84b1_ecf5663dca68["warnFutureDeprecation()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 43459d27_10c2_86a0_84b1_ecf5663dca68
  58719e23_70bd_67e0_1ed8_f61c19ec725b["getHookHandler()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 58719e23_70bd_67e0_1ed8_f61c19ec725b
  2aff86e8_0c9d_22cb_6536_c1321e1aaa1d["isObject()"]
  bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 -->|calls| 2aff86e8_0c9d_22cb_6536_c1321e1aaa1d
  style bff62ce1_58a6_b7b5_ef28_a3e2a2bc0779 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/pluginContainer.ts lines 478–527

  async load(id: string): Promise<LoadResult | null> {
    let ssr = this.environment.config.consumer === 'server'
    const topLevelConfig = this.environment.getTopLevelConfig()
    const options = { ssr }
    const ctx = new LoadPluginContext(this)
    for (const plugin of this.getSortedPlugins('load')) {
      if (this._closed && this.environment.config.dev.recoverable)
        throwClosedServerError()

      const filter = getCachedFilterForPlugin(plugin, 'load')
      if (filter && !filter(id)) continue

      ctx._plugin = plugin

      if (
        isFutureDeprecationEnabled(
          topLevelConfig,
          'removePluginHookSsrArgument',
        )
      ) {
        Object.defineProperty(options, 'ssr', {
          get() {
            warnFutureDeprecation(
              topLevelConfig,
              'removePluginHookSsrArgument',
              `Used in plugin "${plugin.name}".`,
            )
            return ssr
          },
          set(v) {
            ssr = v
          },
        })
      }

      const handler = getHookHandler(plugin.load)
      const result = await this.handleHookPromise(
        handler.call(ctx as any, id, options),
      )
      if (result != null) {
        if (isObject(result)) {
          ctx._updateModuleInfo(id, result)
        }
        this._updateModuleLoadAddedImports(id, ctx._addedImports)
        return result
      }
    }
    this._updateModuleLoadAddedImports(id, ctx._addedImports)
    return null
  }

Domain

Subdomains

Frequently Asked Questions

What does load() do?
load() is a function in the vite codebase, defined in packages/vite/src/node/server/pluginContainer.ts.
Where is load() defined?
load() is defined in packages/vite/src/node/server/pluginContainer.ts at line 478.
What does load() call?
load() calls 10 function(s): _updateModuleInfo, _updateModuleLoadAddedImports, getCachedFilterForPlugin, getHookHandler, handleHookPromise, isFutureDeprecationEnabled, isObject, load, and 2 more.
What calls load()?
load() is called by 5 function(s): compilePostCSS, load, load, loadAndTransform, makeScssWorker.

Analyze Your Own Codebase

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

Try Supermodel Free