WebAssembly/module-linking

Question: Are module exports and imports permitted

Closed this issue · 3 comments

While there are examples in the explainer of importing and exporting module instances using double-level exports, I couldn't tell from reading the explainer document if there are plans to support exporting and importing modules using double-level imports.

Specifically, would the following be considered valid under this spec:

a.wasm

(module
  (export "m" (module
    (func (export "hi")
      ...
    )
  )
)

Then imported via:

(module
  (import "./a.wasm" "m" (module $a (module (export "m") (func (export "hi") ... ))))
  ...
)

Yes, the nesting you show is intended to be supported. AFAICS, there wouldn't be any desugaring associated with these two-level modules, though (as there are from two-level imports into imports-of-instances-exporting-fields).

Thanks, that is great to hear, closing as answered.

(as there are from two-level imports into imports-of-instances-exporting-fields).

Just to make sure I'm understanding, are you referring to treating two-level imports as a sugar for a single-level import + an alias?

Yep!