Developer utility

Compile a Narrow Numeric JavaScript Subset to WebAssembly

Wasmize Lite is a browser workbench for testing the shape of a small Vite or Astro WebAssembly transform. Add `/** @wasm */` before a function, and the tool checks whether its single numeric return expression fits the supported subset. Eligible functions become a minimal WebAssembly module with an asynchronous JavaScript wrapper. This is a prototype for a narrow arithmetic grammar. It is not a general JavaScript-to-WebAssembly compiler or a production-ready plugin generator.

What it does

  • Find named functions preceded by a `/** @wasm */` marker and report which marked candidates are eligible or rejected.
  • Parse single-return arithmetic expressions using numeric literals, named parameters, parentheses, unary minus, addition, subtraction, multiplication, and division.
  • Compile eligible functions as exported WebAssembly functions with 64-bit floating-point parameters and return values.
  • Preview asset-based or inline-base64 JavaScript wrappers and download the generated `.wasm` module.
  • Build a downloadable prototype Vite/Astro plugin scaffold with example configuration, source files, a playground, and documentation.

How to use Wasmize Lite

  1. Load an example or write source

    Start with an eligible, rejected, unmarked, or mixed example, or enter your own JavaScript or TypeScript-style function in the editor.

  2. Mark the candidate

    Place `/** @wasm */` immediately before a named function whose body is one numeric return expression.

  3. Choose an output shape

    Select a separate `.wasm` asset wrapper or an inline base64 wrapper, then press Compile.

  4. Read the transform report

    Check which functions passed or failed, then read the diagnostics, generated wrapper, exported names, and module byte size.

  5. Export the experiment

    Copy the wrapper, download the generated WebAssembly module, or set a package name and download the prototype scaffold ZIP.

Formats, compatibility, and limits

Inputs

  • JavaScript or TypeScript-style source containing named functions optionally marked with `/** @wasm */`.
  • Numeric parameters and a single arithmetic return expression for each eligible function.
  • An output mode: separate `.wasm` asset or inline base64.
  • An optional package name for the generated scaffold.

Outputs

  • A real minimal WebAssembly binary containing eligible 64-bit floating-point functions.
  • Generated asynchronous JavaScript wrapper source for asset or inline loading.
  • Eligibility diagnostics, export names, and compiled byte size.
  • A downloadable ZIP showing a prototype Vite/Astro plugin package structure.

Compatibility

  • Runs locally in modern browsers with WebAssembly and standard file-download APIs.
  • Copying generated code requires clipboard permission; downloads remain available if clipboard access is denied.
  • The downloaded scaffold targets current Vite-style plugin APIs but still requires engineering work before production use.

Known limits

  • This is not a general JavaScript or TypeScript compiler. It supports only named, marked functions with one numeric return expression.
  • Control flow, calls, closures, objects, arrays, strings, async code, browser APIs, ambient globals, and most JavaScript syntax are rejected.
  • All generated function parameters and return values use WebAssembly `f64`; JavaScript integer and type semantics are not reproduced.
  • Candidate discovery uses a deliberately small source pattern rather than a full JavaScript parser.
  • The downloaded plugin scaffold is illustrative: Rollup asset emission and the scaffold’s inline placeholder replacement are not fully wired for production builds.
  • The workbench generates wrappers but does not execute user functions or benchmark WebAssembly against JavaScript.

Privacy and processing

  • Source code and package settings stay in browser memory and are not uploaded by the workbench.
  • Compilation, wrapper generation, and ZIP assembly happen on the page.
  • The tool does not persist source in local storage or IndexedDB; refreshing clears the editor session.

What Wasmize Lite actually compiles

The analyser finds marked, named functions and checks their parameters before parsing a small expression grammar into an internal syntax tree. It emits eligible expressions directly as WebAssembly `f64` instructions, then packages them in a minimal binary with type, function, export, and code sections. The JavaScript wrapper instantiates that binary once and exposes asynchronous functions. When a candidate falls outside the supported grammar, the report explains why instead of pretending the generated WebAssembly would be equivalent.

Questions about Wasmize Lite

Can Wasmize Lite compile any JavaScript function?

No. It only compiles a narrow arithmetic subset: named marked functions with numeric parameters and one return expression using numbers, parameters, parentheses, unary minus, and the four basic arithmetic operators.

Is the downloaded Vite plugin ready for production?

No. The ZIP is a prototype for inspecting the transform and wrapper structure. Its documentation calls out unfinished asset emission and inline replacement, and the package still needs tests and integration work before production use.

Does the workbench generate real WebAssembly?

Yes, eligible expressions are encoded into a valid minimal WebAssembly binary that you can download. The workbench does not run the function or claim semantic coverage beyond its documented numeric subset.

Does my source code leave the browser?

The workbench performs analysis and binary generation locally and does not submit editor contents to an application backend or save them in browser storage.