WGSL-Plus (v1.0.1) is a comprehensive WGSL shader toolchain providing preprocessing with C-style macros (#define, #ifdef, #include), minification, obfuscation, and pretty-printing for WebGPU shaders. It supports conditional compilation, file linking, and multiple output formats (WGSL, SPIR-V via naga, GLSL, MSL). Unlike basic formatters, it adds macro expansion and obfuscation suitable for production builds. Updated irregularly on GitHub.
npm install wgsl-plusNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Compile WGSL source with macros and conditional compilation, outputting formatted WGSL.
Add option `minify: false` if you expect readable output.
Use `compile()` for macro expansion; `prettify()` for formatting; `minify()` for minification.
Avoid using obfuscate for now; wait for the dedicated function.
Place all `#define` and `#include` lines at the top of the file, before any `@` or `fn` tokens.
Pass `{ cwd: __dirname }` in the compile options to resolve includes relative to the calling file.Run the source through `compile()` first, then send `result.code` to the GPU.
Use an absolute path or set `cwd` option: `compile(source, { cwd: __dirname })`.Use `const { compile } = require('wgsl-plus');` or `import { compile } from 'wgsl-plus'`.No dependency data recorded yet.