liveBook · Manning

Import

As explained in Server-Side WebAssembly

An import is a component dependency that supplies a function, resource, or other interface element from an external module, component, or host.

An import is an explicitly declared dependency that supplies a function, resource, or interface element from another component or host. In Wasm components, imports define the capabilities a component may use, replacing hidden or unexpected dependencies with a controlled interface. section 3.1.3 section 3.5

Imports also provide the communication boundary in a shared-nothing design. For example, my_app.wasm imports a secret-store interface from my_secret_store.wasm and calls its get method with my-key. The components keep separate memories; arguments are copied across the boundary, while returned resources are represented by handles managed through a resource table. section 3.1.2

This boundary provides practical security and maintenance benefits:

  • Limits each component to its specified imports rather than allowing access to arbitrary dependencies. section 3.1.3
  • Contains the effect of a vulnerable component because components do not share memory. section 3.1.3
  • Allows a patched component to be relinked without recompiling unchanged business logic. section 3.1.3
Figure 3.2 The interaction between two isolated Wasm components starting from a function call to communicating with an adapter component, doing required memory copies, and returning a resource that can be accessed via a resource table
A screenshot of a computer

AI-generated content may be incorrect.

Follow the call from an importing application through isolated component memories, adapters, copied values, and returned resource handles. section 3.1.2

How Server-Side WebAssembly covers it

How deep it goes
Traces an imported function call through isolated memories, copied arguments, resource handles, and resource tables.
Examples
Uses my_app.wasm importing a secret-store from my_secret_store.wasm and calling get with my-key.
What it assumes
Assumes familiarity with Wasm modules and exported memory, then replaces direct memory interaction with interface-based imports and exports.
What you can do after
Evaluate component boundaries and replace vulnerable imported components without rebuilding unchanged business logic.
How it connects
Connects imports with Wasm components, exports, shared-nothing isolation, interfaces, resource tables, and host runtimes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.