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

next-dev-optimizer

v0.0.1

Published

Incremental optimization engine for faster Next.js development

Readme

next-speed-engine

A dependency-graph-aware compiler, watcher, incremental cache, and HMR engine for Next.js — built on clean architecture so any single piece can be swapped without touching business logic.

node typescript license


Why

Next.js dev mode owns the watcher, bundler, and HMR socket — but a lot of useful work (incremental SWC transforms, dependency-graph analytics, granular HMR boundaries, profiling) is hard to reach from inside the bundler. next-speed-engine is a standalone, framework-agnostic engine that does that work cleanly behind ports/adapters, then plugs into Next either as a sidecar dev process or as a next.config.js webpack plugin.

It is intentionally small, strictly typed (strict + exactOptionalPropertyTypes), and zero-magic.

Features

  • Watcher — chokidar with debounced batching, atomic-write coalescing, large-tree-friendly defaults.
  • AST parser — SWC-backed, extracts static + dynamic imports, exports, re-exports, and module features.
  • Dependency graph — directed in-memory graph with O(V+E) SCC cycle detection and constant-time BFS for affected/downstream sets.
  • Incremental cache — content-hash + producer-signature + dependency-fingerprint invalidation; memory, disk, or layered (memory L1 over disk L2).
  • Compile pipeline — bounded parallel SWC transforms with cache-aware skip, per-batch results, and graceful per-module failures.
  • HMR — typed WebSocket protocol, handshake, heartbeat, granular update / prune / reload envelopes, and a tree-shakable browser client with React Fast Refresh integration.
  • Profiler — event-driven, lock-free counters/gauges/histograms with console + JSON reporters.
  • Benchmark harness — warmup, percentiles, structured BenchmarkResult for CI gating.

Install

npm install next-speed-engine

Node 20+ required. ESM-only ("type": "module").

Quick start

As a CLI sidecar

npx next-speed

This boots the engine with defaultConfig() (project root = process.cwd()), starts the watcher and the HMR WebSocket on ws://localhost:3030.

Programmatic

import { createContainer, defaultConfig } from "next-speed-engine";

const config = defaultConfig();
const container = createContainer(config);

await container.service.start();

process.on("SIGINT", async () => {
  await container.service.stop();
  process.exit(0);
});

Browser HMR client

import { createHmrClient } from "next-speed-engine/client";

createHmrClient({
  url: "ws://localhost:3030",
  onUpdate: (u) => console.log(`hot update: ${u.patches.length} module(s)`),
}).connect();

The client lazy-resolves react-refresh/runtime and calls performReactRefresh() for .tsx/.jsx patches; non-eligible modules trigger a controlled full reload.

Documentation

| Topic | Document | |-------|----------| | Architecture — layers, ports/adapters, request flow | docs/architecture.md | | ConfigurationEngineConfig reference + tuning | docs/configuration.md | | Watcher — chokidar adapter, batching, debounce | docs/watcher.md | | Dependency graph — model, traversals, cycle detection | docs/dependency-graph.md | | Cache — incremental cache, layering, invalidation | docs/cache.md | | Compile pipeline — parallel batches, dependency fingerprinting | docs/compile-pipeline.md | | HMR — wire protocol, boundary resolver, client runtime | docs/hmr.md | | Profiler — events, histograms, reporters | docs/profiler.md | | API reference — every public export | docs/api.md | | Next.js integration — sidecar vs plugin patterns | docs/integration-nextjs.md | | Contributing | CONTRIBUTING.md | | Changelog | CHANGELOG.md |

Project layout

next-speed-engine/
├── src/
│   ├── core/                Pure domain (entities, value objects, ports, errors)
│   ├── application/         Use cases, services, typed event bus
│   ├── infrastructure/      Adapters: SWC, chokidar, ws, memory/disk cache, profiler
│   ├── presentation/
│   │   ├── cli/             CLI entry (`next-speed`)
│   │   └── client/          Browser HMR runtime
│   ├── config/              EngineConfig + defaults
│   ├── shared/              Cross-cutting utils (hash, fs, concurrency)
│   ├── container/           Composition root (DI)
│   ├── client.ts            Browser barrel  → next-speed-engine/client
│   └── index.ts             Server barrel   → next-speed-engine
├── benchmarks/              Benchmark scenarios
├── tests/                   (skeleton — see tests/README.md)
└── docs/                    Long-form documentation

Scripts

| Script | What it does | |--------|-------------| | npm run build | Emit dist/ | | npm run typecheck | tsc --noEmit (strict) | | npm run dev | Run CLI via ts-node | | npm start | Run compiled CLI | | npm run bench | Run benchmark harness | | npm run clean | Remove dist/ and .cache/ |

Architecture in one diagram

┌─────────────────── presentation (CLI, browser HMR client) ───────────────────┐
│ ┌──────────────── infrastructure (SWC, chokidar, ws, fs, profiler) ────────┐ │
│ │ ┌─────────── application (use cases, services, event bus) ────────────┐  │ │
│ │ │ ┌───────────────── core (entities, ports, errors) ──────────────┐   │  │ │
│ │ │ │                       Pure TypeScript                         │   │  │ │
│ │ │ └───────────────────────────────────────────────────────────────┘   │  │ │
│ │ └─────────────────────────────────────────────────────────────────────┘  │ │
│ └─────────────────────────────────────────────────────────────────────────-─┘ │
└───────────────────────────────────────────────────────────────────────────────┘

The dependency rule is strict: outer layers depend on inner layers, never the reverse. Swap SWC for esbuild, chokidar for parcel-watcher, or ws for SSE — only container/ changes.

Status

0.x — API may evolve. Production use is supported behind a pinned version. See CHANGELOG.md for notable changes.

License

MIT