Registry / devops / shader-minifier-wasm

shader-minifier-wasm

JSON →
library0.2.1jsnpmunverified

A WebAssembly port of shader-minifier for minifying GLSL/HLSL shader code. Powered by .NET's Blazor WebAssembly, it provides fast, lossless minification ideal for shader golf or reducing shader payload size. Version 0.2.1 is the latest (stable, infrequent releases). Key differentiator: runs entirely in-WASM, enabling serverless/browser-based minification with no native dependencies. Note: large bundle size (~MB) due to Blazor runtime makes it unsuitable for lightweight browser use without careful asset management.

npm install shader-minifier-wasm
INSTALL
IMPORT
SIG · SHADER-MINIFIER-WA
S
shader-minifier-wasm
devopsjavascriptv0.2.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.

minify
import { minify } from 'shader-minifier-wasm'
const minify = require('shader-minifier-wasm')
ESM-only; default export is an object, use named import 'minify'.
minify (type)
import type { MinifyOptions, MinifyResult } from 'shader-minifier-wasm'
Types available since v0.2.0, use explicit type import for better tree-shaking.
Init (internal)
import { init } from 'shader-minifier-wasm'
Library auto-initializes WASM on first minify call; explicit init() may be needed in workers.

Minifies a GLSL shader object and logs the minified output as text.

import { minify } from 'shader-minifier-wasm'; const shaders = { fragment: ` out vec4 fragColor; void main() { fragColor = vec4(1., 1., 1., 1.); } ` }; async function main() { try { const result = await minify(shaders, { format: 'text' }); console.log(result); } catch (err) { console.error('Minification failed:', err); } } main();
Debug
Known issues
gotchaLarge bundle size: node_modules/shader-minifier-wasm/dist/AppBundle/_framework can be >5MB. Not suitable for direct browser ESM import without copying assets.
fix
Copy the _framework folder to your static assets and serve it. Use a web worker for heavy load.
affects: *
gotchaFirst call to minify() triggers WASM download and compilation, causing significant delay (~1-3s). Subsequent calls are fast.
fix
Pre-warm by calling minify() early (e.g., on page load) or use a loading indicator.
affects: *
deprecatedThe library uses deprecated Blazor WebAssembly 3.1 APIs; may not work in newer .NET runtimes.
fix
No fix available; consider switching to native shader-minifier CLI or a WASM-free port.
affects: <=0.2.1
breakingv0.2.0 changed output format option from 'string' to 'text'. Old code using 'string' will throw.
fix
Replace { format: 'string' } with { format: 'text' }.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Could not load shader-minifier-wasm. Make sure the _framework folder is available.
WASM files (_framework) not copied to public/static assets in browser environment.
fix
Copy node_modules/shader-minifier-wasm/dist/AppBundle/_framework to your web root (e.g., public/framework) and set publicPath accordingly.
TypeError: minify is not a function
Default import used instead of named import.
fix
Use import { minify } from 'shader-minifier-wasm' instead of import minify from ...
AbortError: The operation was aborted
WASM memory allocation failed (out of memory) when processing large shaders.
fix
Break large shaders into smaller chunks, or increase browser memory limits.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
shader-minifier-wasm — npm install shader-minifier-wasm · libregistry