Home / Function/ instantiateFromUrl() — vite Function Reference

instantiateFromUrl() — vite Function Reference

Architecture documentation for the instantiateFromUrl() function in wasm.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  1424df8c_6dcf_6693_4489_c5347c3f6f44["instantiateFromUrl()"]
  d496a62e_d9d8_41d4_a984_96f1dbd5f4bd["wasm.ts"]
  1424df8c_6dcf_6693_4489_c5347c3f6f44 -->|defined in| d496a62e_d9d8_41d4_a984_96f1dbd5f4bd
  0d75a8a7_f26a_435d_13a5_1589846184a8["wasmHelper()"]
  0d75a8a7_f26a_435d_13a5_1589846184a8 -->|calls| 1424df8c_6dcf_6693_4489_c5347c3f6f44
  51afdf58_3045_64b1_cf5b_929b1091e877["get()"]
  1424df8c_6dcf_6693_4489_c5347c3f6f44 -->|calls| 51afdf58_3045_64b1_cf5b_929b1091e877
  style 1424df8c_6dcf_6693_4489_c5347c3f6f44 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/wasm.ts lines 42–59

const instantiateFromUrl = async (url: string, opts?: WebAssembly.Imports) => {
  // https://github.com/mdn/webassembly-examples/issues/5
  // WebAssembly.instantiateStreaming requires the server to provide the
  // correct MIME type for .wasm files, which unfortunately doesn't work for
  // a lot of static file servers, so we just work around it by getting the
  // raw buffer.
  const response = await fetch(url)
  const contentType = response.headers.get('Content-Type') || ''
  if (
    'instantiateStreaming' in WebAssembly &&
    contentType.startsWith('application/wasm')
  ) {
    return WebAssembly.instantiateStreaming(response, opts)
  } else {
    const buffer = await response.arrayBuffer()
    return WebAssembly.instantiate(buffer, opts)
  }
}

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does instantiateFromUrl() do?
instantiateFromUrl() is a function in the vite codebase, defined in packages/vite/src/node/plugins/wasm.ts.
Where is instantiateFromUrl() defined?
instantiateFromUrl() is defined in packages/vite/src/node/plugins/wasm.ts at line 42.
What does instantiateFromUrl() call?
instantiateFromUrl() calls 1 function(s): get.
What calls instantiateFromUrl()?
instantiateFromUrl() is called by 1 function(s): wasmHelper.

Analyze Your Own Codebase

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

Try Supermodel Free