Home / Function/ resolveId() — vite Function Reference

resolveId() — vite Function Reference

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

Function typescript ViteCore ConfigEngine calls 12 called by 2

Entity Profile

Dependency Diagram

graph TD
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f["resolveId()"]
  285b1044_dd20_6f59_7cf5_0ad094eeacee["EnvironmentPluginContainer"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|defined in| 285b1044_dd20_6f59_7cf5_0ad094eeacee
  acb05845_9984_6792_9aae_b58486b613b5["resolveId()"]
  acb05845_9984_6792_9aae_b58486b613b5 -->|calls| c3f72447_6ade_7e1a_5913_f1b30ae4a31f
  dfa2b928_25a4_a78f_1e11_1e7e643cae09["resolve()"]
  dfa2b928_25a4_a78f_1e11_1e7e643cae09 -->|calls| c3f72447_6ade_7e1a_5913_f1b30ae4a31f
  4037a852_6412_11ad_da74_ea3d0ff0c661["buildStart()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 4037a852_6412_11ad_da74_ea3d0ff0c661
  740b85c6_7fbd_cec6_1dc6_e19314ddecba["handleHookPromise()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 740b85c6_7fbd_cec6_1dc6_e19314ddecba
  acb05845_9984_6792_9aae_b58486b613b5["resolveId()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| acb05845_9984_6792_9aae_b58486b613b5
  c42acd29_f3d2_c03f_de55_553d650a5fbf["throwClosedServerError()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| c42acd29_f3d2_c03f_de55_553d650a5fbf
  52da5dad_0e46_dc8f_fae0_b17308d247cc["getCachedFilterForPlugin()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 52da5dad_0e46_dc8f_fae0_b17308d247cc
  3ac77420_8a39_d233_cf59_650944f4a9fa["isFutureDeprecationEnabled()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 3ac77420_8a39_d233_cf59_650944f4a9fa
  43459d27_10c2_86a0_84b1_ecf5663dca68["warnFutureDeprecation()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 43459d27_10c2_86a0_84b1_ecf5663dca68
  58719e23_70bd_67e0_1ed8_f61c19ec725b["getHookHandler()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 58719e23_70bd_67e0_1ed8_f61c19ec725b
  14c1c6b3_e4b1_62ce_7196_077ecd00ef57["timeFrom()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 14c1c6b3_e4b1_62ce_7196_077ecd00ef57
  0850ad90_f980_60a3_ab1f_b17433109b74["prettifyUrl()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 0850ad90_f980_60a3_ab1f_b17433109b74
  23257aa1_5e3f_7e6e_1b43_875b139e4ec5["isExternalUrl()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| 23257aa1_5e3f_7e6e_1b43_875b139e4ec5
  a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath()"]
  c3f72447_6ade_7e1a_5913_f1b30ae4a31f -->|calls| a4adb1a7_cf54_091f_eb63_8217e684a8e1
  style c3f72447_6ade_7e1a_5913_f1b30ae4a31f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/pluginContainer.ts lines 352–476

  async resolveId(
    rawId: string,
    importer: string | undefined = join(
      this.environment.config.root,
      'index.html',
    ),
    options?: {
      kind?: ImportKind
      attributes?: Record<string, string>
      custom?: CustomPluginOptions
      /** @deprecated use `skipCalls` instead */
      skip?: Set<Plugin>
      skipCalls?: readonly SkipInformation[]
      /**
       * @internal
       */
      scan?: boolean
      isEntry?: boolean
    },
  ): Promise<PartialResolvedId | null> {
    if (!this._started) {
      this.buildStart()
      await this._buildStartPromise
    }
    const skip = options?.skip
    const skipCalls = options?.skipCalls
    const scan = !!options?.scan
    const ssr = this.environment.config.consumer === 'server'
    const ctx = new ResolveIdContext(this, skip, skipCalls, scan)
    const topLevelConfig = this.environment.getTopLevelConfig()

    const mergedSkip = new Set<Plugin>(skip)
    for (const call of skipCalls ?? []) {
      if (call.called || (call.id === rawId && call.importer === importer)) {
        mergedSkip.add(call.plugin)
      }
    }

    const resolveStart = debugResolve ? performance.now() : 0
    let id: string | null = null
    const partial: Partial<PartialResolvedId> = {}
    for (const plugin of this.getSortedPlugins('resolveId')) {
      if (this._closed && this.environment.config.dev.recoverable)
        throwClosedServerError()
      if (mergedSkip?.has(plugin)) continue

      const filter = getCachedFilterForPlugin(plugin, 'resolveId')
      if (filter && !filter(rawId)) continue

      ctx._plugin = plugin

      const normalizedOptions = {
        kind: options?.kind,
        attributes: options?.attributes ?? {},
        custom: options?.custom,
        isEntry: !!options?.isEntry,
        ssr,
        scan,
      }
      if (
        isFutureDeprecationEnabled(
          topLevelConfig,
          'removePluginHookSsrArgument',
        )
      ) {
        let ssrTemp = ssr
        Object.defineProperty(normalizedOptions, 'ssr', {
          get() {
            warnFutureDeprecation(
              topLevelConfig,
              'removePluginHookSsrArgument',
              `Used in plugin "${plugin.name}".`,
            )
            return ssrTemp
          },
          set(v) {
            ssrTemp = v
          },
        })
      }

Domain

Subdomains

Frequently Asked Questions

What does resolveId() do?
resolveId() is a function in the vite codebase, defined in packages/vite/src/node/server/pluginContainer.ts.
Where is resolveId() defined?
resolveId() is defined in packages/vite/src/node/server/pluginContainer.ts at line 352.
What does resolveId() call?
resolveId() calls 12 function(s): buildStart, getCachedFilterForPlugin, getHookHandler, handleHookPromise, isExternalUrl, isFutureDeprecationEnabled, normalizePath, prettifyUrl, and 4 more.
What calls resolveId()?
resolveId() is called by 2 function(s): resolve, resolveId.

Analyze Your Own Codebase

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

Try Supermodel Free