Home / Function/ invalidateModule() — vite Function Reference

invalidateModule() — vite Function Reference

Architecture documentation for the invalidateModule() function in fullBundleEnvironment.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  55a72845_539c_1cc5_148b_2c87bf18e4db["invalidateModule()"]
  8fcd8920_61ef_93b8_499a_c18a48b852e5["FullBundleDevEnvironment"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|defined in| 8fcd8920_61ef_93b8_499a_c18a48b852e5
  c7929a5b_9791_180a_9c0b_4f479fb4cf3f["devHtmlHook()"]
  c7929a5b_9791_180a_9c0b_4f479fb4cf3f -->|calls| 55a72845_539c_1cc5_148b_2c87bf18e4db
  2ccc36f4_103c_b60e_efaa_01ea14db6138["handleHmrOutput()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| 2ccc36f4_103c_b60e_efaa_01ea14db6138
  dd164f22_a6d3_7e8d_43c3_45e219e70176["invalidateModule()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| dd164f22_a6d3_7e8d_43c3_45e219e70176
  010d4483_95f2_b44c_22ac_99a40a3261a6["has()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| 010d4483_95f2_b44c_22ac_99a40a3261a6
  76e38b65_cb19_7bed_a56c_352d99366e3b["set()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| 76e38b65_cb19_7bed_a56c_352d99366e3b
  350125bb_754e_f5e3_28c9_3c404a3e4edb["prepareError()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| 350125bb_754e_f5e3_28c9_3c404a3e4edb
  4e748f4a_42c0_e310_88f6_d950ac923c8d["get()"]
  55a72845_539c_1cc5_148b_2c87bf18e4db -->|calls| 4e748f4a_42c0_e310_88f6_d950ac923c8d
  style 55a72845_539c_1cc5_148b_2c87bf18e4db fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/environments/fullBundleEnvironment.ts lines 202–258

  protected override invalidateModule(
    m: {
      path: string
      message?: string
      firstInvalidatedBy: string
    },
    client: NormalizedHotChannelClient,
  ): void {
    ;(async () => {
      const invalidateCalledModules = this.invalidateCalledModules.get(client)
      if (invalidateCalledModules?.has(m.path)) {
        debug?.(
          `INVALIDATE: invalidate received from ${m.path}, but ignored because it was already invalidated`,
        )
        return
      }

      debug?.(
        `INVALIDATE: invalidate received from ${m.path}, re-triggering HMR`,
      )
      if (!invalidateCalledModules) {
        this.invalidateCalledModules.set(client, new Set([]))
      }
      this.invalidateCalledModules.get(client)!.add(m.path)

      let update: BindingClientHmrUpdate['update'] | undefined
      try {
        const _update = await this.devEngine.invalidate(
          m.path,
          m.firstInvalidatedBy,
        )
        update = _update.find(
          (u) => this.clients.get(u.clientId) === client,
        )?.update
      } catch (e) {
        client.send({
          type: 'error',
          err: prepareError(e as Error),
        })
        return
      }
      if (!update) return

      if (update.type === 'Patch') {
        this.logger.info(
          colors.yellow(`hmr invalidate `) +
            colors.dim(m.path) +
            (m.message ? ` ${m.message}` : ''),
          { timestamp: true },
        )
      }

      this.handleHmrOutput(client, [m.path], update, {
        firstInvalidatedBy: m.firstInvalidatedBy,
      })
    })()
  }

Domain

Subdomains

Called By

Frequently Asked Questions

What does invalidateModule() do?
invalidateModule() is a function in the vite codebase, defined in packages/vite/src/node/server/environments/fullBundleEnvironment.ts.
Where is invalidateModule() defined?
invalidateModule() is defined in packages/vite/src/node/server/environments/fullBundleEnvironment.ts at line 202.
What does invalidateModule() call?
invalidateModule() calls 6 function(s): get, handleHmrOutput, has, invalidateModule, prepareError, set.
What calls invalidateModule()?
invalidateModule() is called by 1 function(s): devHtmlHook.

Analyze Your Own Codebase

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

Try Supermodel Free