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

naga-wasm

v30.1.0

Published

naga shader translator (wgpu) compiled to WebAssembly

Readme

naga-wasm

npm CI node

The naga shader translator from wgpu, compiled to WebAssembly.

Translate between WGSL, GLSL, SPIR-V, HLSL and MSL from JavaScript, in Node or the browser, without shelling out to the naga CLI.

  • Frontends: WGSL, GLSL, SPIR-V
  • Backends: WGSL, GLSL, SPIR-V, HLSL, MSL

Install

npm install naga-wasm

Usage

import { translate } from "naga-wasm";

const glsl = translate({
	from: "wgsl",
	to: "glsl",
	source: wgsl,
	options: { version: "300 es", stage: "fragment", entryPoint: "main" },
});

In Node the WebAssembly module loads on import. In the browser, call init() once before anything else:

import { init, translate } from "naga-wasm";

await init();

init() resolves the binary next to the module, which Vite and webpack 5 handle. To host it yourself, pass a URL, Response or bytes:

await init({ module_or_path: new URL("/naga_bg.wasm", location.href) });

The binary is exported as naga-wasm/naga_bg.wasm.

Handles

translate is a shortcut for the handle API. Parse once to write several outputs:

import { parseWgsl, validate, writeGlsl, writeHlsl } from "naga-wasm";

using module = parseWgsl(source);
using info = validate(module);

const glsl = writeGlsl(module, info, {
	version: "330",
	stage: "vertex",
	entryPoint: "vs_main",
});
const hlsl = writeHlsl(module, info, { shaderModel: "6_0" });

Handles hold WebAssembly memory. Release them with using or free().

| Function | Returns | | ----------------------------------------------------------------- | ------------- | | parseWgsl(source) | Module | | parseGlsl(source, { stage, defines? }) | Module | | parseSpirv(words) | Module | | validate(module) | ModuleInfo | | writeWgsl(module, info, { flags? }) | string | | writeGlsl(module, info, { version, stage, entryPoint, flags? }) | string | | writeHlsl(module, info, { shaderModel? }) | string | | writeMsl(module, info, { langVersion? }) | string | | writeSpirv(module, info, { flags? }) | Uint32Array |

parseSpirv accepts a Uint8Array or Uint32Array.

flags override naga's writer flags one at a time and keep the rest at their defaults:

writeGlsl(module, info, {
	version: "300 es",
	stage: "vertex",
	entryPoint: "vs_main",
	flags: { forcePointSize: true },
});

Errors

Failures throw a NagaError with:

  • kind: "parse", "validation" or "write"
  • message: a one-line summary
  • formatted: naga's full report, including source spans
import { NagaError, parseWgsl } from "naga-wasm";

try {
	parseWgsl("fn main( {");
} catch (error) {
	if (error instanceof NagaError) console.error(error.formatted);
}
error: expected identifier, found "{"
  ┌─ wgsl:1:10
  │
1 │ fn main( {
  │          ^ expected identifier

Versioning

The major version follows naga's major version. Minor and patch releases belong to this package. The bundled naga version is exported as nagaVersion and noted in each release.

License

This project is licensed under either of:

at your option.