npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ghostty-webgpu/shaderc

v0.0.4

Published

Runtime ShaderToy and Ghostty GLSL compiler for WebGPU and WebGL2

Readme

ghostty-web-shaderc

Compile Ghostty and ShaderToy GLSL strings to WebGPU WGSL and WebGL2 GLSL, at runtime, in the browser or in Node.

import { compileGhosttyShader } from '@ghostty-webgpu/shaderc'

const shader = await compileGhosttyShader(`
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord / iResolution.xy;
    fragColor = texture(iChannel0, uv) * vec4(1.0, 0.8, 0.6, 1.0);
}
`)

console.log(shader.wgsl.match(/fn mainImage[\s\S]*?\n}/)?.[0])
console.log(shader.webgl)
fn mainImage(fragColor: ptr<function, vec4<f32>>, fragCoord: vec2<f32>) {
    var fragCoord_1: vec2<f32>;
    var uv: vec2<f32>;

    fragCoord_1 = fragCoord;
    let _e62 = fragCoord_1;
    let _e63 = global.iResolution;
    uv = (_e62 / _e63.xy);
    let _e67 = uv;
    let _e68 = textureSample(_ghosttyChannel0Texture, _ghosttyChannel0Sampler, _e67);
    (*fragColor) = (_e68 * vec4<f32>(1f, 0.8f, 0.6f, 1f));
    return;
}
{
  uniformBlock: 'GhosttyUniforms_block_0Fragment',
  channel0: '_group_0_binding_1_fs'
}

The example prints two things: the mainImage function from shader.wgsl, and shader.webgl, the two names you bind in WebGL2. shader.wgsl is the full program for a WebGPU pipeline. shader.glsl is the full program for a WebGL2 program, and the example does not print it. Ghostty shaders are plain GLSL files, and browsers cannot run them directly. This package is the missing compile step.

  • Same source, both APIs. One mainImage shader becomes WGSL and GLSL ES 3.00 with the same uniform layout and the same coordinates.
  • Errors point at your lines. A diagnostic reports the line and column in your source, not in the generated wrapper.
  • Strict-CSP friendly. Naga compiles the shader inside a WebAssembly module. The page needs wasm-unsafe-eval, not unsafe-eval.
  • Compiler only. You keep control of render targets, animation, and GPU resources. ghostty-webgpu is a separate project, and installing this package adds no shader support to it.

The showcase compiles the shader in your browser and shows the input and both outputs. The Matrix shader is by its listed authors, with its license in SHADER_LICENSES.md.

One shader goes in and two programs come out. The renderer on the right is yours to write.

Quick start

The package is not on npm yet. Install the tarball from the v0.0.2 release. You need Node 24.12 or later. That is the engines floor in package.json, CI runs Node 24, and Node 24 runs the .ts examples below without a build step.

  1. Install it.

    npm install @ghostty-webgpu/shaderc

    The same URL installs with pnpm add, yarn add, and bun add. See Package managers.

  2. Save the example above as demo.mts and run it.

    node demo.mts

    You see the output above.

  3. Compile a file from the command line.

    cat > shader.glsl <<'EOF'
    void mainImage(out vec4 fragColor, in vec2 fragCoord) {
        fragColor = texture(iChannel0, fragCoord / iResolution.xy);
    }
    EOF
    npx --no-install ghostty-web-shaderc shader.glsl --out shader.json

    shader.json holds wgsl, glsl, and the WebGL binding names.

Getting started takes this to a working draw call.

Package managers

The tarball install was run end to end, with the demo script and the CLI, on Node 24.22.1 with these tools:

  • npm 11.19.1: npm install <tarball-url>
  • pnpm 8.11.0: pnpm add <tarball-url>
  • Yarn 1.22.22: yarn add <tarball-url>
  • Bun 1.4.4: bun add <tarball-url>

All four worked. Bun also runs the demo (bun demo.mts) and the CLI (bunx --no-install ghostty-web-shaderc). Yarn 2 and later were not tried.

In a browser

Install the same tarball into your web project and import the package from your bundler entry. A Vite 8.3.5 production build of this page emitted the 2.0 MB naga_bg-*.wasm file as an asset, and the compiled shader came back in Chromium:

// main.ts
import { compileGhosttyShader } from '@ghostty-webgpu/shaderc'

const shader = await compileGhosttyShader(`
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    fragColor = texture(iChannel0, fragCoord / iResolution.xy);
}
`)
document.body.textContent = shader.wgsl

Vite is the only bundler tested. Run in the browser covers Web Workers, serving the WASM file yourself, and the CSP.

What you can do

How it works

compileGhosttyShader wraps your mainImage in a generated GLSL prefix and suffix. The prefix declares the Ghostty uniform block and the iChannel0 texture. Naga parses the result, validates it, and writes WGSL and GLSL ES 3.00. The package then checks that the output matches the fixed binding contract and maps every diagnostic back to your source lines. See How it works.

Docs

Status

Pre-1.0 (0.0.x), experimental. The API and the ghostty-v1 uniform layout can change between patch releases.

  • Not on npm. The installable artifact is the GitHub release tarball.
  • Supports one ShaderToy image pass with iChannel0. No buffer passes, audio, video, or extra channels.
  • Compatibility covers the tested fixtures and pixel tests, not every GLSL extension. A shader that runs in desktop Ghostty can fail here. See Compatibility.
  • Tested in CI on Chromium (software GPU), Node, and Bun. iOS Safari 26.5 was checked by hand on the WebGL2 path. Firefox and desktop Safari are untested.

License

MIT. Bundled example shaders keep their own licenses, listed in examples/showcase/SHADER_LICENSES.md. See also THIRD_PARTY_NOTICES.md.