{"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,"search_vec":"'14.17.4':57 '2022':91 'angl':14,74,94 'angle-bas':73 'appli':20 'base':11,75 'binari':51 'cadenc':85 'compil':10,76 'constant':21 'constrain':41 'control':79 'direct':17 'distribut':46 'e.g':66 'export':27 'fold':22 'full':72 'function':28 'game':35 'global':82 'glsl':7,64,68,93 'glsl-minifi':67 'googl':13 'includ':59 'jam':36 'javascript':92 'js13k':34 'last':88 'low':87 'major':89 'mangl':24,80 'map':83 'minifi':8,65,69 'name':31 'node.js':56 'non':26 'non-export':25 'npm':53 'optim':32 'plugin':61 'precompil':49 'preprocess':16 'project':43 'provid':71 'releas':84 'remov':18 'rollup/vite':60 'run':54 'similar':38 'size':40 'size-constrain':39 'spglsl':1,2,70 'typescript':96 'unlik':62 'updat':90 'v0.3.1':3 'valid':77 'variabl':30 'via':52,81 'wasm':50 'webgl':6,42,95 'whitespac':19","created_at":"2026-05-01T13:49:53.746898+00:00","updated_at":"2026-05-01T13:49:53.746898+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"spglsl","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/SalvatorePreviti/spglsl","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/spglsl","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}