Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BlackAsLight/wasm-bundler
Easily, via the cli, convert wasm binary files into js files to be bundled up together as one single file.
https://github.com/BlackAsLight/wasm-bundler
browser bundle convert deno embed javascript transpile typescript wasm webassembly
Last synced: 3 months ago
JSON representation
Easily, via the cli, convert wasm binary files into js files to be bundled up together as one single file.
- Host: GitHub
- URL: https://github.com/BlackAsLight/wasm-bundler
- Owner: BlackAsLight
- License: mit
- Created: 2024-03-25T04:49:37.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-26T03:25:26.000Z (8 months ago)
- Last Synced: 2024-04-20T08:44:53.061Z (7 months ago)
- Topics: browser, bundle, convert, deno, embed, javascript, transpile, typescript, wasm, webassembly
- Language: TypeScript
- Homepage: https://jsr.io/@doctor/wasm-bundler
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wasm Bundler
Wasm Bundler is a simple script that enables one to embed their `.wasm` file into their javascript code by creating a `.js` file
that has the wasm binary file gzipped and stringified to base64 for load. This file can then, if one desired, be bundled into
other code of yours via your desired bundler. The generated code does need the `@doctor/encoding-stream/base64` dependency to
function properly.## Example 1
### Example Command
Assuming there was a `static/wasm/app.js` and `static/wasm/app_bg.wasm` file already in your code base.
```
deno run --allow-read --allow-write @doctor/wasm-bundler static/wasm/app_bg.wasm ./app.js static/wasm/embed.js
```
### Output
```js
import { DecodeBase64Stream } from '@doctor/encoding-stream/base64'
import x from './app.js'x(new Response(
ReadableStream.from((async function* () {
yield 'Imagine Repeated Base64 Strings Here!'
})())
.pipeThrough(new DecodeBase64Stream())
.pipeThrough(new DecompressionStream('gzip'))
))
```## Example 2
### Example Import
Assuming there was a `static/wasm/app.js` and `static/wasm/app_bg.wasm` file already in your code base.
```ts
import { WasmToJs } from '@doctor/wasm-bundler/mod'(await Deno.open('./static/wasm/app_bg.wasm'))
.readable
.pipeThrough(new WasmToJs('./app.js'))
.pipeTo(Deno.stdout.writable)
```