Menci / Menci/vite-plugin-wasm

Support for Source Phase imports

Open
#77 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
431
Forks
27
PR merge metrics
No merged PRs in 30d

Description

It's been great to see the updates here. While the instance phase imports per the wasm-bindgen style remain specified and supported, the ESM Integration now also supports source phase imports of WebAssembly modules of the form:

import source mod from './mod.wasm';
mod instanceof WebAssembly.Module; // true

returning the compiled module which can be instantiated explicitly later on or many times.

It could be nice to allow this to be inlined by this plugin in the same way instance inlining is currently done, but to get a handle to the compiled webassembly module record.

Note that the builtins: ['js-string'] WebAssembly.compile option is also supposed to be passed to compilation now for both instance and source phases to allow string builtin imports.

Happy to engage in further implementation discussion as necessary here or otherwise.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the plugin's existing instance-phase WebAssembly import handling and locate where WebAssembly compilation is performed. Determine how source-phase imports can be inlined while exposing a compiled WebAssembly.Module, and verify that the js-string builtin option is passed for both source and instance phases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wasm
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.