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

@diamondjs/compiler

v2.2.2

Published

DiamondJS template compiler

Readme

💎 @diamondjs/compiler

The half of DiamondJS that absorbs the complexity, so the runtime — and your head — don't have to.

You write Aurelia-inspired template syntax; the compiler produces completely transparent JavaScript that both humans and AI models can debug instantly, with a [Diamond] semantic hint comment above every generated call.


What is this?

The build-time template compiler: parser (parse5, with source locations), code generator, hint emitter, converter-pipe codegen, security diagnostics, and VLQ source maps. It turns this:

<!-- counter.html — what you write -->
<div class="counter">
  <button click.calls="decrement()">-</button>
  <span>${count}</span>
  <button click.calls="increment()">+</button>
</div>

into a plain instance createTemplate() method on your component class:

// What the compiler produces — what you debug
createTemplate() {
  const div = document.createElement('div');
  div.className = 'counter';

  const button1 = document.createElement('button');
  // [Diamond] Event binding: click → decrement()
  DiamondCore.on(button1, 'click', () => this.decrement());
  button1.textContent = '-';

  const span = document.createElement('span');
  // [Diamond] Binding reactive property 'count' → textContent
  DiamondCore.bind(span, 'textContent', () => this.count);
  // …
}

No JSX transform, no proxy magic, no custom format. Errors point at your .html template, not the compiled JS — source maps are required, not optional.

# Usually installed via the dev meta-package (with the Parcel transformer + toolchain):
npm install --save-dev @diamondjs/dev

# Or standalone:
npm install --save-dev @diamondjs/compiler

Usage

Most projects never call the compiler directly — @diamondjs/parcel-transformer-diamond invokes it during bundling. The programmatic surface:

import { DiamondCompiler } from '@diamondjs/compiler';

const compiler = new DiamondCompiler();
const result = compiler.compile(templateSource, { filePath: 'counter.html', sourceMap: true });
// result.code, result.map, result.diagnostics

What it compiles

The full v2.x template grammar: set/rawSet and the binding commands (.bind, .two-way, .calls, .capture, .delegate, .trigger, .one-time), ${interpolation}, if/else-if, repeat.for, exhaustive switch/case/default, attribute spread (...attrs.bind), converter pipes with the ParseResult contract, and error-into converter error surfaces.

Diagnostics — the stink gate's fuel

Every compile emits typed diagnostics routed by severity, never by code prefix:

| Severity | Meaning | Gate behavior | |----------|---------|---------------| | error | Retired/unknown command — broken source | FAIL | | warn | Latent hole nobody declared (unsafe sink without raw, dead switch) | FAIL (hard gate) | | declared | Intentional raw escape hatch | Baselined; drift lands in code review, not a build block | | info | Advisory | Never gated |

The stink-check bin in @diamondjs/dev runs this taxonomy over your whole template tree as a CI gate.

Design constraints

  • Compiler < 5,000 LOC — modular, each pass independently comprehensible (currently ~45% of budget)
  • Complexity belongs in the compiler, not in the runtime or the developer's head
  • Show your work — every transformation is visible in compiled output

Part of DiamondJS — the first JavaScript framework designed for the human-LLM collaborative development era.

License

MIT