{"id":26421,"library":"spglsl","title":"spglsl","description":"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.","status":"maintenance","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/SalvatorePreviti/spglsl","tags":["javascript","glsl","angle","webgl","typescript"],"install":[{"cmd":"npm install spglsl","lang":"bash","label":"npm"},{"cmd":"yarn add spglsl","lang":"bash","label":"yarn"},{"cmd":"pnpm add spglsl","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import only; CJS require may work but is not officially supported.","wrong":"const { spglslAngleCompile } = require('spglsl')","symbol":"spglslAngleCompile","correct":"import { spglslAngleCompile } from 'spglsl'"},{"note":"Named export, not default export.","wrong":"import rollupPluginSpglsl from 'spglsl'","symbol":"rollupPluginSpglsl","correct":"import { rollupPluginSpglsl } from 'spglsl'"},{"note":"TypeScript type import for options; not needed at runtime.","wrong":"","symbol":"SpglslAngleCompileOptions","correct":"import type { SpglslAngleCompileOptions } from 'spglsl'"}],"quickstart":{"code":"import { spglslAngleCompile } from 'spglsl';\nimport { readFileSync } from 'fs';\n\nasync function main() {\n  const result = await spglslAngleCompile({\n    mainFilePath: 'shader.frag',\n    mainSourceCode: readFileSync('shader.frag', 'utf8'),\n    minify: true,\n    mangle: true,\n    mangle_global_map: { myUniform: 'u', myVarying: 'v' }\n  });\n  if (!result.valid) {\n    console.error(result.infoLog);\n    throw new Error('Compilation failed');\n  }\n  console.log(result.output);\n}\nmain().catch(console.error);","lang":"typescript","description":"Minifies and mangles a GLSL fragment shader using spglsl, with renamed uniforms and varying."},"warnings":[{"fix":"Upgrade Node.js to >=14.17.4.","message":"spglsl is WASM-based and may fail on Node.js <14.17.4 due to missing WebAssembly support.","severity":"breaking","affected_versions":"<0.1.0"},{"fix":"Split shader into smaller files or increase Node.js --stack-size.","message":"Max call stack size exceeded error when processing very large shaders (e.g., >1000 lines) due to recursive AST visitor.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use a custom plugin or fork.","message":"rollupPluginSpglsl is no longer maintained and may break with Rollup >=3.","severity":"deprecated","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install spglsl' and ensure it's in node_modules.","cause":"Package not installed or path incorrect.","error":"Cannot find module 'spglsl'"},{"fix":"Use 'import { spglslAngleCompile } from \"spglsl\";'.","cause":"Incorrect import (default import instead of named import).","error":"spglslAngleCompile is not a function"},{"fix":"Rewrite using supported constructs or disable minify.","cause":"Unsupported GLSL syntax (e.g., struct assignment).","error":"error: no viable overloaded '='"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}