{"id":27552,"library":"wgsl-wasm-transpiler-bundler","title":"wgsl-wasm-transpiler-bundler","description":"A Rust-based WGSL shader compiler and cross-transpiler that converts WGSL to GLSL, HLSL, Metal, or SPIR-V. v0.0.1 is an early release with no regular release cadence yet. Differentiators: runs in Node.js and browser via WASM, single-function API, supports SPIR-V binary and assembly output. Requires manual WASM initialization via `init()` before any compilation calls. Competing with naga and glslang, but lighter and purely WGSL→others.","status":"active","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/reczkok/wgsl-wasm-transpiler","tags":["javascript","typescript"],"install":[{"cmd":"npm install wgsl-wasm-transpiler-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add wgsl-wasm-transpiler-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add wgsl-wasm-transpiler-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM; named export only. No default export.","wrong":"import compileShader from 'wgsl-wasm-transpiler-bundler'","symbol":"compileShader","correct":"import { compileShader } from 'wgsl-wasm-transpiler-bundler'"},{"note":"Required before compileShader. Returns a promise in browser (await), sync in Node (call once).","wrong":"const init = require('wgsl-wasm-transpiler-bundler')","symbol":"init","correct":"import { init } from 'wgsl-wasm-transpiler-bundler'"},{"note":"Returns string array like ['wgsl','glsl','hlsl','metal','spirv','spirv-asm'].","symbol":"getSupportedFormats","correct":"import { getSupportedFormats } from 'wgsl-wasm-transpiler-bundler'"}],"quickstart":{"code":"import { init, compileShader } from 'wgsl-wasm-transpiler-bundler';\n\nconst wgsl = `@fragment fn main() -> @location(0) vec4<f32> {\n  return vec4<f32>(1.0, 0.0, 0.0, 1.0);\n}`;\n\n// Browser: await init(); Node: init(); then use\nawait init();\nconst glsl = compileShader(wgsl, 'glsl');\nconsole.log(glsl);","lang":"typescript","description":"Initialize WASM and compile a trivial WGSL fragment shader to GLSL."},"warnings":[{"fix":"Always call init() (and await in browser) before any other API function.","message":"Calling compileShader before init() throws: 'WASM not initialized' or panics.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Use await init() in both environments; it works in Node too.","message":"init() is synchronous in Node.js but asynchronous in browser. If you await in Node, it's fine, but forgetting await in browser will cause a runtime error.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Validate WGSL before passing. Use getSupportedFormats() to check format. Wrap in try/catch.","message":"compileShader throws on invalid WGSL or unsupported format. Unclear error messages may mention Rust panics.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"search_vec":"'api':50 'assembl':57 'base':9 'binari':55 'browser':44 'bundler':5 'cadenc':37 'call':68 'compet':69 'compil':12,67 'convert':18 'cross':15 'cross-transpil':14 'differenti':39 'earli':31 'function':49 'glsl':21 'glslang':73 'hlsl':22 'init':64 'initi':62 'javascript':80 'lighter':75 'manual':60 'metal':23 'naga':71 'node.js':42 'other':79 'output':58 'pure':77 'regular':35 'releas':32,36 'requir':59 'run':40 'rust':8 'rust-bas':7 'shader':11 'singl':48 'single-funct':47 'spir':26,53 'spir-v':25,52 'support':51 'transpil':4,16 'typescript':81 'v':27,54 'v0.0.1':28 'via':45,63 'wasm':3,46,61 'wgsl':2,10,19,78 'wgsl-wasm-transpiler-bundl':1 'yet':38","created_at":"2026-05-01T17:46:51.451881+00:00","updated_at":"2026-05-01T17:46:51.451881+00:00","problems":[{"fix":"Use import { compileShader } from 'wgsl-wasm-transpiler-bundler'","cause":"Importing default instead of named export.","error":"TypeError: compileShader is not a function"},{"fix":"Ensure you are using the correct path to the WASM file and call init() with await.","cause":"WASM binary not loaded or init() not called properly.","error":"RuntimeError: unreachable (or WebAssembly.instantiate(): expected magic word)"},{"fix":"Use 'spirv' for binary or 'spirv-asm' for text. Run getSupportedFormats() to see all.","cause":"Using wrong format string; must be exactly one of the supported formats.","error":"Error: Unknown format: 'spirv_binary'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/reczkok/wgsl-wasm-transpiler","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/wgsl-wasm-transpiler-bundler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","http-networking","database","auth-security","communication"],"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}}