Home / Function/ constructor() — vite Function Reference

constructor() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6ea66dc7_258c_4d4e_457c_a36e57776e88["constructor()"]
  f634223d_ed8e_a65b_08f8_a839ec17994a["DevEnvironment"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|defined in| f634223d_ed8e_a65b_08f8_a839ec17994a
  848a8a1e_7ae9_d904_37a5_8c77896712a6["constructor()"]
  848a8a1e_7ae9_d904_37a5_8c77896712a6 -->|calls| 6ea66dc7_258c_4d4e_457c_a36e57776e88
  36ef67eb_a698_1443_ac9d_7a0f8db79857["constructor()"]
  36ef67eb_a698_1443_ac9d_7a0f8db79857 -->|calls| 6ea66dc7_258c_4d4e_457c_a36e57776e88
  f297b990_b9f9_4d71_aa05_07419a0a6688["constructor()"]
  f297b990_b9f9_4d71_aa05_07419a0a6688 -->|calls| 6ea66dc7_258c_4d4e_457c_a36e57776e88
  4ae1a360_4ea9_bed5_a7fe_a0731ef954f2["constructor()"]
  4ae1a360_4ea9_bed5_a7fe_a0731ef954f2 -->|calls| 6ea66dc7_258c_4d4e_457c_a36e57776e88
  be964a75_40a0_c608_ed3a_1a730415cb0f["fetchModule()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| be964a75_40a0_c608_ed3a_1a730415cb0f
  dd164f22_a6d3_7e8d_43c3_45e219e70176["invalidateModule()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| dd164f22_a6d3_7e8d_43c3_45e219e70176
  657661b0_3b17_9113_8464_fda5dfafd706["mergeConfig()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| 657661b0_3b17_9113_8464_fda5dfafd706
  c7599009_1b74_ff3f_37a1_c8cb945418f8["setupOnCrawlEnd()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| c7599009_1b74_ff3f_37a1_c8cb945418f8
  743fd3ce_caa4_d18b_5e53_7a8e20b91e4c["normalizeHotChannel()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| 743fd3ce_caa4_d18b_5e53_7a8e20b91e4c
  cf8cccc0_fa2a_e8ac_480a_47c54435825c["isDepOptimizationDisabled()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| cf8cccc0_fa2a_e8ac_480a_47c54435825c
  acb05845_9984_6792_9aae_b58486b613b5["resolveId()"]
  6ea66dc7_258c_4d4e_457c_a36e57776e88 -->|calls| acb05845_9984_6792_9aae_b58486b613b5
  style 6ea66dc7_258c_4d4e_457c_a36e57776e88 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/environment.ts lines 105–179

  constructor(
    name: string,
    config: ResolvedConfig,
    context: DevEnvironmentContext,
  ) {
    let options = config.environments[name]
    if (!options) {
      throw new Error(`Environment "${name}" is not defined in the config.`)
    }
    if (context.options) {
      options = mergeConfig(
        options,
        context.options,
      ) as ResolvedEnvironmentOptions
    }
    super(name, config, options)

    this._pendingRequests = new Map()

    this.moduleGraph = new EnvironmentModuleGraph(name, (url: string) =>
      this.pluginContainer!.resolveId(url, undefined),
    )

    this._crawlEndFinder = setupOnCrawlEnd()

    this._remoteRunnerOptions = context.remoteRunner ?? {}

    this.hot = context.transport
      ? isWebSocketServer in context.transport
        ? context.transport
        : normalizeHotChannel(context.transport, context.hot)
      : normalizeHotChannel({}, context.hot)

    this.hot.setInvokeHandler({
      fetchModule: (id, importer, options) => {
        return this.fetchModule(id, importer, options)
      },
      getBuiltins: async () => {
        return this.config.resolve.builtins.map((builtin) =>
          typeof builtin === 'string'
            ? { type: 'string', value: builtin }
            : { type: 'RegExp', source: builtin.source, flags: builtin.flags },
        )
      },
    })

    this.hot.on(
      'vite:invalidate',
      async ({ path, message, firstInvalidatedBy }, client) => {
        this.invalidateModule(
          {
            path,
            message,
            firstInvalidatedBy,
          },
          client,
        )
      },
    )

    if (!context.disableDepsOptimizer) {
      const { optimizeDeps } = this.config
      if (context.depsOptimizer) {
        this.depsOptimizer = context.depsOptimizer
      } else if (isDepOptimizationDisabled(optimizeDeps)) {
        this.depsOptimizer = undefined
      } else {
        this.depsOptimizer = (
          optimizeDeps.noDiscovery
            ? createExplicitDepsOptimizer
            : createDepsOptimizer
        )(this)
      }
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the vite codebase, defined in packages/vite/src/node/server/environment.ts.
Where is constructor() defined?
constructor() is defined in packages/vite/src/node/server/environment.ts at line 105.
What does constructor() call?
constructor() calls 7 function(s): fetchModule, invalidateModule, isDepOptimizationDisabled, mergeConfig, normalizeHotChannel, resolveId, setupOnCrawlEnd.
What calls constructor()?
constructor() is called by 4 function(s): constructor, constructor, constructor, constructor.

Analyze Your Own Codebase

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

Try Supermodel Free