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

fragmint

v0.0.3

Published

Minimal, zero-dependency parser for modern frontend framework templates. Produces a compact AST of tagnames and attributes for further tooling and analysis.

Readme

Fragmint

Fragmint is a lightweight, zero-dependency library for parsing HTML templates from various frontend frameworks and libraries. It provides a unified interface to extract and analyze attributes and tag usage across various template syntaxes.

Purpose

The main purpose of Fragmint is to provide a simple and extensible way to work with HTML-like templates in a framework-agnostic manner. It allows you to extract attributes, and their values, from your component templates, regardless of whether you're using Angular, React, Vue, Svelte, or Lit.

Why

Because I want to check the usage of web component libraries, their across various code bases

Usage

To use Fragmint, you need to select a parsing strategy explicitly. This is useful when you know the framework in advance or want to enforce a specific parsing behavior.

import { angular, parse } from 'fragmint';

const source = '<div class="foo" [bar]="baz"></div>';
const ast = parse(source, angular);

console.log(ast);

API

parse(source: string, plugin: ParserPlugin): ASTNode[][]

Parses the source code using the specified plugin.

  • source: The source code to parse.
  • plugin: The parsing plugin to use. By default, it uses the html plugin.
  • Returns: An array of arrays of ASTNode objects. Each inner array represents a parsed template.

ParserPlugin

A ParserPlugin is an object that defines how to parse a specific template syntax. Fragmint exports the following built-in strategies:

  • angular
  • html
  • jsx
  • lit
  • svelte
  • vue

Each strategy has the following properties:

  • name: The name of the strategy (e.g., 'vue', 'angular').
  • extractTemplates: A function that extracts one or more templates from the source code.
  • extractAttributes: A function that extracts attributes from a template.

ASTNode

Represents a node in the Abstract Syntax Tree (AST) of a template. It can be an ElementNode or a TextNode.

export type ASTNode = ElementNode | TextNode

ElementNode

export interface ElementNode {
  /** The type of the node */
  type: 'Element'
  /** The tag name for 'Element' nodes (e.g., 'div', 'my-component', 'SomeElement'). */
  tag: string;
  /** An array of attributes for 'Element' nodes. */
  attributes: ASTAttribute[];
  /** An array of child nodes. */
  children: ASTNode[];
  /** The start and end offsets of the node in the source code. */
  loc: { start: number; end: number };
  /** The original source string for the node. */
  raw: string;
}

TextNode

export interface TextNode {
  /** The type of the node */
  type: 'Text';
  /** The start and end offsets of the node in the source code. */
  loc: { start: number; end: number };
  /** The original source string for the node. */
  raw: string;
}

ASTAttribute

export interface ASTAttribute {
  /** The raw name of the attribute as it appears in the template. */
  name: string;
  /** The raw value of the attribute, including quotes or braces. Null for boolean attributes. */
  value: string | null;
  /** A flag indicating if the attribute's value is defined staticly or computed (e.g., a variable or expression). */
  computed?: boolean;
  /** The original source string for the entire attribute (e.g., 'attr="value"'). */
  raw: string;
  /** The start and end offsets of the attribute in the source code. */
  loc: { start: number; end: number };
}