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

shields-wasm

v1.6.0

Published

WebAssembly bindings for the shields badge rendering engine

Readme

shields-wasm

WebAssembly bindings for shields.rs. The core Rust engine is reused unchanged; this crate only marshals a JS object into BadgeParams and returns the rendered SVG. Runs anywhere WASM does — Node, Deno, Bun, browsers, and edge runtimes (Cloudflare Workers, Vercel Edge).

Build

wasm-pack build --target nodejs --release          # -> pkg/ (embeds ~3000 Simple Icons)
wasm-pack build --target nodejs --release \
  --no-default-features --out-dir pkg-slim          # -> pkg-slim/ (custom SVG logos only)

Use --target web / --target bundler for browser and bundler targets.

| build | .wasm raw | .wasm gzip | named logos (logo: "rust") | |-------|-------------|--------------|------------------------------| | full | 6.7 MB | 2.7 MB | yes | | slim | 0.9 MB | 0.35 MB | no (custom SVG data only) |

The full build's size is almost entirely the embedded Simple Icons set. Prefer the slim build unless you need named-logo lookup.

Usage

npm install shields-wasm

The published package targets Node (CommonJS). For browser / bundler / edge consumers, build the --target web or --target bundler variant locally (see Build).

const { renderBadge } = require('shields-wasm'); // ESM: import { renderBadge } from 'shields-wasm'

const svg = renderBadge({
  style: 'flat',                 // flat | flat-square | plastic | social | for-the-badge
  label: 'build',
  message: 'passing',
  messageColor: 'brightgreen',
  logo: 'rust',                  // named (Simple Icons) or an SVG data URI; full build only
  logoColor: 'white',
  idSuffix: 'b1',                // dedupe SVG element ids when inlining several badges
  logoWidth: 14,
});

All fields are optional. Unknown keys are ignored (serde-wasm-bindgen does not enforce deny_unknown_fields).

Benchmark

bench.mjs compares throughput against badge-maker, the JS renderer shields.io itself uses:

wasm-pack build --target nodejs --release
pnpm install         # dev dep: badge-maker
pnpm bench

Representative run (Node v22, 200k iterations/cell):

| workload | shields-wasm | badge-maker | speedup | |---------------|--------------|-------------|---------| | flat | ~2.6 µs | ~24 µs | ~9× | | for-the-badge | ~2.3 µs | ~15 µs | ~6× | | plastic | ~2.5 µs | ~27 µs | ~11× | | social | ~2.4 µs | ~31 µs | ~13× |

The per-call cost includes JS↔WASM marshaling (deserializing the options object and copying the SVG string out), so native Rust is faster still; this is the number a Node caller actually sees.

Publishing

CI (.github/workflows/publish-wasm.yml) publishes shields-wasm to npm on every v* tag, using npm Trusted Publishing (OIDC) — no NPM_TOKEN secret, and every release carries provenance.

The publish step uses the npm CLI, not pnpm, on purpose: pnpm's OIDC trusted-publishing support is currently broken (fails with 404 on pnpm 11, pnpm#11513). pnpm is fine for installs and scripts (pnpm install, pnpm bench) — the disk savings live there; the publish job installs no dependencies, so npm costs nothing extra.

Trusted Publishing can only be configured on a package that already exists, so the first release needs a one-time manual bootstrap:

  1. Build and publish once from your machine to create the package:
    npm login
    wasm-pack build bindings/wasm --target nodejs --release
    cd bindings/wasm/pkg && npm publish --access public
  2. On npmjs.com → the shields-wasm package → Settings → Trusted Publisher, add a GitHub Actions publisher:
    • Repository: Jannchie/shields.rs
    • Workflow filename: publish-wasm.yml
  3. Done. Every subsequent git tag vX.Y.Z && git push --tags publishes tokenlessly. The workflow stamps the npm version from the tag, so the crate's Cargo.toml version does not need bumping per release.