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

treesift

v1.2.1

Published

A powerful JavaScript/TypeScript AST analysis library for React components and beyond

Readme

🌳 TreeSift

A minimal, zero-bloat Abstract Syntax Tree (AST) analysis library for JavaScript and TypeScript — built for component discovery, documentation pipelines, design systems, and visual tooling.


⚡ What is TreeSift?

TreeSift helps you understand your code, automatically.

It parses and analyzes component source files, extracting structured metadata — like names, props, hooks, patterns, and design conventions — ready for use in documentation tools, design systems, and UI builders.

Whether you're mapping a large codebase, generating docs, or creating intelligent design workflows, TreeSift is designed to be the foundation.


✅ Features

| Capability | Description | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 🏷 Component Name Detection | Intelligently detects component names and their declaration types (function, class, arrow function, forwardRef). Handles both default and named exports with proper naming convention validation. | | 🧾 Props Analysis | Comprehensive props analysis including direct props access, destructured parameters, and variable declarations. Tracks prop types and optionality for better type inference. | | ⚓ React Hook Detection | Sophisticated hook detection system that identifies both built-in React hooks (useState, useEffect, etc.) and custom hooks following the 'use' prefix convention. Extracts hook arguments and usage patterns. | | 🎛 CVA Configuration Analysis | Deep analysis of Class Variance Authority (CVA) configurations, extracting base styles, variants, default variants, and compound variants. Perfect for documenting component styling systems. | | 🎨 ClassNames Utility Analysis | Advanced detection of className utility usage (cn, clsx, classnames) with support for conditional classes, template literals, nested utility calls, and location tracking. | | 🧵 Styling Library Detection | Smart detection of styling approaches with confidence scoring. Identifies Tailwind CSS, styled-components, Emotion, and CSS Modules through import analysis, class patterns, and API usage. | | 📦 Import/Export Resolution | Robust tracking of component dependencies and module relationships. Analyzes both default and named exports, handling various export patterns including re-exports. | | 🧱 JSX Element Analysis | Detailed analysis of JSX elements within components, including built-in HTML elements, custom components, props, attributes, children elements, and component composition patterns. |


🧠 Designed For

  • 📚 Documentation Generators
  • 🧩 Design System Metadata Extraction
  • 🔬 Static Code Analysis
  • Visual UI Builders & Render Engines

TreeSift is meant to integrate deeply with your development tooling — from pipelines to playgrounds.


💡 Example Usage

import { TreeSift } from 'treesift';

const result = TreeSift.analyze('/path/to/Component.tsx');

console.log(result);
/*
{
  name: 'MyComponent',
  filePath: 'test',
  exportType: 'default',
  type: 'FunctionDeclaration',
  props: [
    { name: 'data', type: 'any', isOptional: true },
    { name: 'title', type: 'any', isOptional: true }
  ],
  hooks: [
    { name: 'useState', arguments: ['0'] },
    { name: 'useEffect', arguments: ['() => {...}', '[count]'] }
  ],
  cvaConfigs: [
    {
      variableName: 'buttonVariants',
      configObject: {
        base: 'px-4 py-2 rounded',
        variants: {
          intent: {
            primary: 'bg-blue-500 text-white',
            secondary: 'bg-gray-200 text-gray-800'
          },
          size: {
            small: 'text-sm',
            large: 'text-lg'
          }
        },
        defaultVariants: {
          intent: 'primary',
          size: 'small'
        },
        compoundVariants: []
      }
    }
  ],
  classNames: {
    importSource: 'clsx',
    importName: 'cn',
    usages: [
      {
        line: 33,
        column: 30,
        arguments: ['font-bold', 'count > 5 ? "text-red-500" : "text-green-500"']
      }
    ]
  },
  classNamesUsage: {
    hasClassNames: true,
    importSource: 'clsx',
    usage: [
      {
        type: 'cn',
        arguments: [
          { type: 'string', value: 'font-bold' },
          { type: 'conditional', value: { condition: 'count > 5', trueValue: 'text-red-500', falseValue: 'text-green-500' } }
        ],
        location: { line: 33, column: 30 }
      }
    ]
  },
  dependencies: {
    packages: [
      'react',
      './hooks/useCustom',
      '../utils/helpers',
      'clsx',
      'class-variance-authority',
      'tailwindcss/tailwind.css'
    ]
  },
  jsxStructure: [
    { name: 'section', props: [], children: [], attributes: [] },
    { name: 'h1', props: [], children: [], attributes: [{ name: 'className', value: 'text-2xl font-bold' }] },
    { name: 'CustomComponent', props: [{ name: 'someProp', value: 'count', isSpread: false }], children: [], attributes: [] },
    { name: 'div', props: [], children: [{ type: 'text', content: 'Class Component' }], attributes: [] },
    { name: 'button', props: [], children: [{ type: 'text', content: 'Click me' }], attributes: [{ name: 'className', value: null, isSpread: false }] }
  ],
  contexts: { consumes: [], provides: [] },
  hocWrappers: [],
  stylingLibrary: {
    type: 'tailwind',
    confidence: 100,
    indicators: [
      'Imports from clsx',
      'Imports from tailwindcss/tailwind.css',
      'Imports CSS file: tailwindcss/tailwind.css',
      'Uses Tailwind-like class: text-2xl font-bold'
    ]
  }
}
*/