Skip to content

napi-rs/wasm-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5664ce4 · Apr 2, 2025

History

71 Commits
Mar 26, 2025
Apr 15, 2024
Apr 15, 2024
Oct 22, 2024
Apr 15, 2024
Apr 15, 2024
Apr 15, 2024
Apr 15, 2024
Nov 20, 2024
Apr 15, 2024
Apr 15, 2024
Apr 15, 2024
Apr 15, 2024
Jul 15, 2024
Apr 15, 2024
Apr 2, 2025
Mar 17, 2025
Apr 15, 2024
Apr 15, 2024
Apr 15, 2024
Jul 15, 2024
Jul 15, 2024
Jul 15, 2024
Jul 15, 2024

Repository files navigation

@napi-rs/wasm-tools

https://github.com/napi-rs/wasm-tools/actions

https://github.com/rustwasm/walrus bindings

Install this package

pnpm add @napi-rs/wasm-tools -D
yarn add @napi-rs/wasm-tools -D

Usage

// Generate dwarf info and emit wasm

import { join } from 'node:path'
import { readFile, writeFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'

import { ModuleConfig } from '@napi-rs/wasm-tools'

const __dirname = join(fileURLToPath(import.meta.url), '..')

const wasm = await readFile(join(__dirname, 'panic.wasm32-wasi.wasm'))

const binary = new ModuleConfig()
  .generateDwarf(true)
  .generateNameSection(true)
  .generateProducersSection(true)
  .preserveCodeTransform(true)
  .parse(wasm)
  .emitWasm(true)

await writeFile(join(__dirname, 'panic.wasm32-wasi.wasm'), binary)