Registry / devops / spglsl

spglsl

JSON →
library0.3.1jsnpmunverified

spglsl (v0.3.1) is a WebGL GLSL minifier and compiler based on Google ANGLE. It preprocesses directives, removes whitespace, applies constant folding, and mangles non-exported functions and variable names. Optimized for js13k game jams and similar size-constrained WebGL projects, it is distributed as a precompiled WASM binary via npm, runs on Node.js (>=14.17.4), and includes Rollup/Vite plugins. Unlike other GLSL minifiers (e.g., glsl-minify), spglsl provides full ANGLE-based compilation validation and controllable mangling via globals map. Release cadence is low; last major update 2022.

npm install spglsl
INSTALL
IMPORT
SIG · SPGLSL
S
spglsl
devopsjavascriptv0.3.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.

spglslAngleCompile
✓ import { spglslAngleCompile } from 'spglsl'
✗ const { spglslAngleCompile } = require('spglsl')
ESM import only; CJS require may work but is not officially supported.
rollupPluginSpglsl
✓ import { rollupPluginSpglsl } from 'spglsl'
✗ import rollupPluginSpglsl from 'spglsl'
Named export, not default export.
SpglslAngleCompileOptions
✓ import type { SpglslAngleCompileOptions } from 'spglsl'
TypeScript type import for options; not needed at runtime.

Minifies and mangles a GLSL fragment shader using spglsl, with renamed uniforms and varying.

import { spglslAngleCompile } from 'spglsl'; import { readFileSync } from 'fs'; async function main() { const result = await spglslAngleCompile({ mainFilePath: 'shader.frag', mainSourceCode: readFileSync('shader.frag', 'utf8'), minify: true, mangle: true, mangle_global_map: { myUniform: 'u', myVarying: 'v' } }); if (!result.valid) { console.error(result.infoLog); throw new Error('Compilation failed'); } console.log(result.output); } main().catch(console.error);
spglsl --version
Debug
Known issues
breakingspglsl is WASM-based and may fail on Node.js <14.17.4 due to missing WebAssembly support.
fix
Upgrade Node.js to >=14.17.4.
affects: <0.1.0
gotchaMax call stack size exceeded error when processing very large shaders (e.g., >1000 lines) due to recursive AST visitor.
fix
Split shader into smaller files or increase Node.js --stack-size.
affects: >=0.1.0
deprecatedrollupPluginSpglsl is no longer maintained and may break with Rollup >=3.
fix
Use a custom plugin or fork.
affects: >=0.2.0
Errors
Common errors & fixes
Cannot find module 'spglsl'
Package not installed or path incorrect.
fix
Run 'npm install spglsl' and ensure it's in node_modules.
spglslAngleCompile is not a function
Incorrect import (default import instead of named import).
fix
Use 'import { spglslAngleCompile } from "spglsl";'.
error: no viable overloaded '='
Unsupported GLSL syntax (e.g., struct assignment).
fix
Rewrite using supported constructs or disable minify.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
spglsl — npm install spglsl · libregistry