https://github.com/rainbowatcher/wasmup
wasm pack, made easy
https://github.com/rainbowatcher/wasmup
Last synced: 3 months ago
JSON representation
wasm pack, made easy
- Host: GitHub
- URL: https://github.com/rainbowatcher/wasmup
- Owner: rainbowatcher
- License: mit
- Created: 2024-07-18T02:46:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-10T04:17:08.000Z (4 months ago)
- Last Synced: 2026-02-10T09:43:55.055Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 636 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/rainbowatcher/wasmup/actions)

[](https://www.npmjs.com/package/wasmup)
# wasmup
Wasm build, made easy
> [!WARNING]
> It's in early development status, use in your own risk.
## features
- Build a set of code that can run seamlessly in Node.js, Deno, Bun, and browsers.
- No setup needed, just use directly.
- The generated package.json in pretty order.
- Add parameter validation to functions.
## Usage
Requires Node.js `>=20.19.0`.
```sh
pnpm install -D wasmup
```
```jsonc
{
// ...
"scripts": {
"build": "wasmup build --clean .",
},
}
```
### Runtime usage (Node.js / Bun / Deno / Web)
Use the same ESM API in all runtimes:
```ts
import init, { hello_world } from "your-wasm-package"
await init()
console.log(hello_world())
```
For sync initialization:
1. `initSync` is only supported in Node.js, Bun and Deno.
2. `initSync` is not supported in browsers.
For browser deployment:
1. Keep `index_bg.wasm` accessible by URL.
2. `index_bg.wasm` should be deployed next to the generated JS entry (or with an equivalent URL mapping).
### Configuration
The Wasmup configuration file may be named any of the following:
- `wasmup.config.js`
- `wasmup.config.cjs`
- `wasmup.config.mjs`
- `wasmup.config.ts`
- `wasmup.config.mts`
- `wasmup.config.cts`
- `wasmup.config.json`
It should be placed in the root directory of your project and export an configuration objects. Here’s an example:
```ts
import { defineConfig } from "wasmup"
export default defineConfig({
clean: true,
output: "packages/toml-edit-js",
scope: "rainbowatcher",
})
```
### wasm-opt options
you can pass wasm-opt params by config in Cargo.toml, details ref to this link: [cargo-toml-configuration](https://rustwasm.github.io/docs/wasm-pack/cargo-toml-configuration.html)
```toml
[package.metadata.wasm-pack.profile.release]
wasm-opt = [
# Optimize level 4
"-O4",
# Run passes to convergence, continuing while binary size decreases
"--converge",
"--strip-debug",
"--strip-dwarf",
# flattens out code, removing nesting
"--flatten",
# inline small functions
"--inlining",
# removes unreachable code
"--dead-code-elimination",
"--minify-imports-and-exports-and-modules",
# Grand Unified Flow Analysis
"--gufa",
]
```
## License
[MIT](./LICENSE) © Made by ❤️