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

augmented-compile-shader

v2.0.0

Published

Shows the errors of WebGL and WebGPU shaders in the page, instead of the console

Readme

Augmented compileShader

Augmented WebGLRenderingContext.prototype.compileShader, and GPUDevice.prototype.createShaderModule

Small library to augment compileShader and provide an output of the errors directly in the DOM, instead of dumping all data in the console.

npm

Demo

  • Live shader editor: a fragment shader compiled as you type, in GLSL with WebGL 2 or in WGSL with WebGPU, with its errors reported at the top of the page

working

You can read more about this in Using hooks to make development of shaders a bit easier

2026 update

Disclaimer: this library is from 2015. It's a development aid: with WebGL it asks for the result of every compilation right away, which is slower than letting the browser compile in the background, so don't ship it

If you use three.js, it has had renderer.debug.onShaderError since r151 (2023), a callback that receives the program and the shaders that failed, to report them your own way. Without it three.js prints the error to the console, with the lines around it. Neither puts the error in the page, and neither works outside of three.js, which is what this library is for. With WebGPURenderer the WGSL is generated by three.js, so the lines reported are not code you wrote, unless it comes from wgslFn.

The library has been updated. What changed from the 2015 version:

  • it's an ES module
  • it works with WebGL 2, which is what three.js and most of the current code use. It used to hook WebGL 1 only
  • it works with WebGPU: the errors and the warnings of the WGSL shader modules are reported, with the part of the line they are about underlined
  • the report says if the error is in the vertex or in the fragment shader
  • errors that only show up when linking the program are reported too, like a varying that the vertex shader doesn't write
  • the code of the shader is shown as text. It used to be added as HTML, so a line with a < could break the report
  • there's one report in the page, and an error is listed once. Each shader that failed used to add another report with the same id
  • an error log without line numbers is shown whole, and a line number outside of the source doesn't throw anymore
  • a lost context is not reported as an error
  • there's clear() to remove the report, and uninstall() to remove the hooks

How to use

Use npm to install it

npm i augmented-compile-shader

and import it in your code, before any shader is compiled

import 'augmented-compile-shader';

That's all: from then on, the shaders that fail to compile in any WebGL context or WebGPU device of the page are listed at the top of it. It's a plain ES module, so it also works without a bundler (see demo/index.html).

It works with anything that ends up calling compileShader or createShaderModule, three.js included.

With WebGPU the report also lists the warnings, and it uses the label of the shader module to tell which one it is:

device.createShaderModule( { code, label: 'particles' } );

Only the shaders are reported. The other validation errors of WebGPU, like a pipeline that doesn't match its bind groups, still go to the console.

The report stays in the page. To remove it, for instance before compiling a new version of a shader:

import { clear } from 'augmented-compile-shader';

clear();

To stop reporting, and to start again:

import { install, uninstall } from 'augmented-compile-shader';

uninstall();
install();

As always: forks, pull requests and code critiques are welcome!

License

MIT licensed

Copyright (C) 2015 Jaume Sanchez Elias, https://www.clicktorelease.com