deno icon indicating copy to clipboard operation
deno copied to clipboard

Deno compile tries to resolve wasm imports for explicitly instantiated modules

Open CertainLach opened this issue 3 months ago • 4 comments

Version: Deno 2.5.6

Trying to compile a workspace with wasm files, encountering the error:

error: Import "dom" not a dependency and not in import map from "file:///......../_fresh/59458a871d2aa5b4360d.wasm"

Wasm imports should not be resolved in any way here, as they are always passed explicitly in WebAssembly.instantiate:

  WebAssembly.instantiateStreaming(fetch(new URL("wasmFile.wasm", import.meta.url)), {
    dom: ...
  })

CertainLach avatar Nov 29 '25 22:11 CertainLach

Are you using source phase imports? If so, this would be the same issue as #31240.

0f-0b avatar Nov 29 '25 23:11 0f-0b

I'm not even importing wasm using import statement, in code it is used by WebAssembly.instantiate(fetch(...))

CertainLach avatar Nov 29 '25 23:11 CertainLach

Oh, got it, so using --include it is still being analyzed as wasm module imported using import statement

Should it then be safe to not add it to the module roots by default, as it would be automatically added by any import if it exists?

It is only broken with deno compile, and works normally otherwise.

CertainLach avatar Nov 29 '25 23:11 CertainLach

Related: https://github.com/denoland/deno/issues/27505

CertainLach avatar Nov 30 '25 00:11 CertainLach