Registry / devops / wgslmin-wasm

wgslmin-wasm

JSON →
library0.1.1jsnpmunverified

A WGSL shader minifier built as a WebAssembly module for WebGPU applications. Version 0.1.1, released as an alpha/pre-release. It runs in both browsers and Node.js, providing whitespace removal, identifier renaming, syntax optimization, and optional external binding mangling. The package ships TypeScript types and requires manual initialization of the WASM module before use. Unlike other WGSL tools, it offers fine-grained control over minification passes and supports browser bundlers like Vite and Webpack.

npm install wgslmin-wasm
INSTALL
IMPORT
SIG · WGSLMIN-WASM
W
wgslmin-wasm
devopsjavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

initialize
✓ import { initialize } from 'wgslmin-wasm'
✗ import initialize from 'wgslmin-wasm'
The package exports named exports, not a default export.
minify
✓ import { minify } from 'wgslmin-wasm'
✗ const minify = require('wgslmin-wasm').minify
CommonJS require works but is less common; ESM is the preferred pattern for new code.
isInitialized
✓ import { isInitialized } from 'wgslmin-wasm'
Check if WASM is initialized before calling minify.

Initializes the WASM module, minifies a WGSL shader, and logs original vs minified output.

import { initialize, minify } from 'wgslmin-wasm'; await initialize(); // Auto-finds WASM in Node.js const source = ` @vertex fn main() -> @builtin(position) vec4f { return vec4f(0.0, 0.0, 0.0, 1.0); } `; const result = minify(source, { minifyWhitespace: true, minifyIdentifiers: true, minifySyntax: true, }); console.log('Original:', source.length, 'bytes'); console.log('Minified:', result.code);
Debug
Known issues
breakinginitialize() must be called before minify().
fix
Call await initialize() at startup, before any minify() call.
affects: >=0.0.1
gotchamangleExternalBindings: true breaks WebGPU reflection APIs like getBindGroupLayout.
fix
Keep mangleExternalBindings: false (default) if you rely on binding names for reflection.
affects: >=0.1.0
breakingWASM file must be served/specified correctly in browser; auto-detection only works in Node.js.
fix
Provide wasmURL option pointing to the .wasm file location.
affects: >=0.0.1
gotchaminifyIdentifiers: true renames internal identifiers but preserves entry points; unexpected renaming may occur if not using keepNames.
fix
Use keepNames array to preserve critical identifiers.
affects: >=0.0.1
deprecatedNo known deprecations at version 0.1.1.
fix
N/A
affects: >=0.1.1
Errors
Common errors & fixes
Error: WASM module not initialized. Call initialize() first.
minify() called before initialize() resolves.
fix
Ensure await initialize() completes before any minify() call.
RuntimeError: memory access out of bounds
Invalid or corrupted .wasm file, or mismatch between JS and WASM versions.
fix
Reinstall package: npm install wgslmin-wasm@latest
TypeError: Cannot read properties of undefined (reading 'minify')
Import path mistake or the library wasn't correctly imported.
fix
Use named import: import { minify } from 'wgslmin-wasm'
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
45 hits · last 30 days
node
40
OpenAI (training)
1
Resources
wgslmin-wasm — npm install wgslmin-wasm · libregistry