Skip to content
WASM Analyzer LogoWASM Analyzer LogoWASM Analyzer
GitHub

Imports

In WebAssembly terms, Imports are the external functions, tables, memories and globals a Wasm module or component requires. In order to use an instance of the specific Wasm module or component, it is necessary to pass the various entities listed under this tab to an instance of the module or component.





Examples


Passing imports into a Wasm module from might look something like this:

// Creating an object with references to the imports specified in the WebAssembly file.
const importsObject = {
  imports: {
    imported_function: aFunction,
    imported_table: aTable,
    imported_memory: aMemory,
    imported_global: aGlobal,
  },
};

// Fetching and instantiating a module or object from the WebAssembly file.
WebAssembly.instantiateStreaming(
  fetch("moduleOrComponent.wasm"),
  importsObject
).then((result) => {
  // Process result
});




Additional reading


For further information about the Imports concept, have a look at Mozilla’s documentation on the subject.

You can also read about how Wasm imports are displayed in the Nor2 Wasm Inspector in the Imports page section of our WASM Analyzer documentation.